I read many posts on this topic, but no one helped me.
I'm using Android Studio and following this guide
This is the project gradle:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
classpath 'com.google.gms:google-services:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
this is the app gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.1"
defaultConfig {
applicationId "com.xyv.appname"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.0.1'
compile 'com.android.support:design:25.0.1'
testCompile 'junit:junit:4.12'
compile 'com.google.firebase:firebase-core:10.0.1'
}
apply plugin: 'com.google.gms.google-services'
Here you can see where I added google-services.json inside my app:
These are my SDK tools:
Does anybody understand what's my error?
Thank you in advance
You may need to add
compile 'com.google.android.gms:play-services:9.6.1'
in your app build.gradle also. ref: Upgrade to Google Play Services:9.0.0 Error Failed to resolve: com.google.android.gms:play-services-measurement:9.0.0
If you recently bumped the version to 3.0.0 you should doublecheck that you have installed the correct version on your machine in the Android SDK manager.
Open the stand alone SDK Manager, in the Extras section the you will find "Google Play Services" update it .
I resolve my issue by updating android studio to 2.3 beta 2
I did just update an android studio and all is ruining well
Related
I am attempting to generate an apk to install to a device. I was able to do this with the same project prior to Android Studio version 3.0.0. I cannot post any error logs because the apk generates successfully, but when I try to install it on a device I get "App not installed", "File appears to be corrupt". I have been through a number of other threads to try and fix this but nothing has worked so far.
The previous version on the phone has been uninstalled.
Both Signed and unsigned have been tried.
Instant run has been disabled.
The apk has failed to install on at least 3 different devices.
I have tried downgrading my com.android.tools.build:gradle
Any help would be greatly appreciated, I feel like I've tried everything.
build.gradle (app):
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion '27.0.3'
defaultConfig {
applicationId "com.example.will3596.mobileapplication"
minSdkVersion 15
targetSdkVersion 26
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets { main { assets.srcDirs = ['src/main/assets', 'src/main/assets/'] } }
}
dependencies {
implementation 'com.android.support:support-vector-drawable:26.1.0'
implementation 'com.android.support:support-v4:26.1.0'
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:design:26.1.0'
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:26.+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.google.firebase:firebase-core:11.6.2'
compile 'com.google.firebase:firebase-auth:11.6.2'
compile 'com.google.firebase:firebase-database:11.6.2'
compile 'com.google.android.gms:play-services-maps:11.6.2'
compile 'com.google.android.gms:play-services-location:11.6.2'
compile 'com.google.firebase:firebase-storage:11.6.2'
compile 'com.android.support:palette-v7:26.+'
compile 'com.android.support:customtabs:26.+'
compile 'com.android.support:design:26.+'
compile 'com.android.support:cardview-v7:26.+'
compile 'com.android.support:mediarouter-v7:26.+'
compile 'com.android.support:multidex:1.0.2'
compile 'com.mcxiaoke.volley:library:1.0.19'
compile 'com.google.maps.android:android-maps-utils:0.4+'
testCompile 'junit:junit:4.12'
testCompile 'org.mockito:mockito-core:2.7.22'
androidTestCompile 'com.android.support:support-annotations:24.0.0'
androidTestCompile 'com.android.support.test:runner:0.5'
androidTestCompile 'com.android.support.test:rules:0.5'
}
apply plugin: 'com.google.gms.google-services'
build.gradle (project):
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.1'
classpath 'com.google.gms:google-services:3.1.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven{
url "https://maven.google.com"
}
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Let me know what else I can post to help get a solution.
Steps to generate debug apk from 3.0.0+
Build->Build APK(s).
I found the answer in another thread somewhere. In my android manifest, I had testOnly="true", set to false and it fixed.
I try to implement firebase into my app. But there is an interference between firebase and google play service.
Here is my build.gradle for the module:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.example.nefrin.client"
minSdkVersion 19
targetSdkVersion 25
versionCode 1
versionName "1.0"
// Enabling multidex support.
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dexOptions {
incremental true
javaMaxHeapSize "4g"
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.google.android.gms:play-services:11.0.4'
compile 'com.github.tajchert:nammu:1.1.3'
compile 'gun0912.ted:tedpermission:1.0.3'
compile 'com.github.jksiezni.permissive:permissive:0.2'
compile 'com.github.arimorty:floatingsearchview:2.0.3'
//compile 'net.sf.sprockets:sprockets-android:4.0.0'
compile 'com.github.michael-rapp:android-material-dialog:4.0.2'
compile 'com.github.bumptech.glide:glide:3.5.2'
compile 'com.google.firebase:firebase-auth:11.2.0'
}
apply plugin: 'com.google.gms.google-services'
And here is build.gradle for the project:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
classpath 'com.google.gms:google-services:3.1.0' // google-services plugin
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven {
url "https://jitpack.io"
}
maven {
url 'https://oss.sonatype.org/content/repositories/snapshots'
}
maven {
url "https://maven.google.com" // Google's Maven repository
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
When I try to run the app I get eventhough I didn't use cardview in my app:
Error:Execution failed for task ':app:prepareComAndroidSupportCardviewV72330Library'.
> Could not expand ZIP 'C:\Users\Nefrin\.gradle\caches\modules-2\files-2.1\com.android.support\cardview-v7\23.3.0\abdf83a0192c03ff190f941c6c885af18d257a2c\cardview-v7-23.3.0.aar'.
Android Studio is underlining the compile 'com.google.android.gms:play-services:11.0.4' and says:
All com.google.android.gms libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 11.2.0, 11.0.4. Examples include com.google.android.gms:play-services-basement:11.2.0 and com.google.android.gms:play-services:11.0.4 less... (Ctrl+F1)
There are some combinations of libraries, or tools and libraries, that are incompatible, or can lead to bugs. One such incompatibility is compiling with a version of the Android support libraries that is not the latest version (or in particular, a version lower than your targetSdkVersion.)
As the error says all the google libraries should use the same version.
So you should update the play-services library and use the same version as firebase:
compile 'com.google.android.gms:play-services:11.2.0'
compile 'com.google.firebase:firebase-auth:11.2.0'
You need to change this line of code:
compile 'com.google.android.gms:play-services:11.0.4'
with
compile 'com.google.android.gms:play-services:11.2.0'
Hope it helps.
Why i ask, on every solution i jsut have information that apply plugin on bottom, but i have this, but this not work on my side. I try to do this on 5 hours. Im got error after trying to implement google maps on my application. Maybe i miss something in code? I dont know where is problem, so please guys look at code, maybe you will have any idea whats wrong. Thanks fro advice.
This is error:
Error:Execution failed for task ':app:processDebugGoogleServices'.
> Please fix the version conflict either by updating the version of the google-services plugin (information about the latest version is available at https://bintray.com/android/android-tools/com.google.gms.google-services/) or updating the version of com.google.android.gms to 9.0.0.
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.company.andrzej.rolki.wroclawnarolkach"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
configurations.all {
resolutionStrategy.force 'com.android.support:support-annotations:22.1.0'
}
apply plugin: 'com.google.gms.google-services'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.google.firebase:firebase-ads:10.2.1'
compile 'com.jakewharton:butterknife:8.5.1'
compile 'com.android.support:support-v4:25.3.1'
compile 'com.google.android.gms:play-services-maps:10.2.1'
testCompile 'junit:junit:4.12'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1'
compile 'com.google.firebase:firebase-crash:10.2.1'
compile 'com.google.firebase:firebase-core:10.2.1'
compile 'com.google.android.gms:play-services-analytics:10.2.1'
compile 'com.google.android.gms:play-services-gcm:10.2.1'
compile 'com.google.android.gms:play-services-location:10.2.1'
}
apply plugin: 'com.google.gms.google-services'
And project
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.1'
classpath 'com.google.gms:google-services:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Remove apply plugin: 'com.google.gms.google-services' line from dependencies block. You wrote it twice.
I could not able to run the local unit tests in Module which is using android Data binding library.
First let me tell about the project structure how its configured.
project
| app
-MainLauncherActivity
| myLibrary
-CommonModuleActivity
I have created a new project, after that have added a new module "myLibrary".
the main "app" depends on "myLibrary" module. I have added one activity in "myLibrary" it supports databinding. I called module specific activity from main "app" activity on button click in it. it just works, could able to run the app.
But, Getting the below errors when i add a test case for the Module Activity.
AndroidStudio : 2.3
Gradle build tools version 2.3.0 -->
Error:java.lang.NoClassDefFoundError: android/databinding/DataBinderMapper
Gradle build tools version 2.2.3 -->
Error:java.lang.NoClassDefFoundError: android/databinding/ViewDataBinding
PROJECT IDE SCREENSHOT
project root gradle file:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
//classpath 'com.android.tools.build:gradle:2.3.0'
classpath 'com.android.tools.build:gradle:2.2.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
below is "app" build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.example.bindingtest"
minSdkVersion 21
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dataBinding {
enabled true
}
}
dependencies {
compile 'com.android.support:appcompat-v7:25.1.0'
//compile 'com.android.support.constraint:constraint-layout:1.0.0-beta4'
testCompile 'junit:junit:4.12'
compile project(':mylibrary')
}
below myLibrary build.gradle:
apply plugin: 'com.android.library'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
minSdkVersion 21
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dataBinding {
enabled true
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.1.0'
testCompile 'junit:junit:4.12'
testCompile "org.mockito:mockito-core:1.10.19"
}
LibraryActivity:
public class MyLibraryActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ActivityMyLibraryBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_my_library);
//set data to binding
}
}
Corresponding test case can be found in the attached screenshot.
Could some one tell me what am i doing wrong here to get it tested.
APP IS WORKING FINE, ONLY UNIT-TESTS ARE FAILING!!!
I know it's too late to answer that question , But I say to friends who may face this problem.
Any time You used to dataBinding and at unit test faced with NoClassDefFoundError
first add this lines in build.gradle(Module)
testOptions {
unitTests{
isIncludeAndroidResources=true
}
}
then add this library to the dependencies at build.gradle(Module)
kaptTest("androidx.databinding:databinding-compiler:7.0.4")
I think this is a known issue which you can review here. I've been tracking this issue since February. Doesn't seem to be fixed yet.
added android.enableExperimentalFeatureDatabinding=true in gradle.properties . According to the name of this property, I think it could work for sometimes but not always, you can try.
hello i want create a android apk.
and need to use from "com.mcxiaoke.volley" and "com.android.support:appcompat"
please give me a build app for my app.
current build app is :
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
//buildToolsVersion "23.0.2"
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "boxweb.asia.shopcenter"
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies
{
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.android.volley:volley:1.0.0'
}
but don't work and show error.
error is : http://up.vbiran.ir/uploads/45106145544003944084_Untitled-1.jpg
i can not download "https://jcenter.bintray.com/com/android/volley/volley/1.0.0/volley-1.0.0.pom" in android-studio but can download in browser.
help me to install plugin from file.
please help me
Adding volley support can done just by adding compile 'com.mcxiaoke.volley:library:1.0.19 to gradle.build dependencies module.
dependencies
{
compile 'com.mcxiaoke.volley:library:1.0.19'
}
Go through Android Volley Library
Make sure you have jcenter() in your dependencies. So your build.gradle should have:
repositories {
jcenter()
}
dependencies {
compile 'com.android.volley:volley:1.0.0'
}
Note:
The repositories block can either be in your root build.gradle or your app/build.gradle.