Android error when adding plugin com.google.gms.google-services - android

I am working with Firebase in my Android project. When I add
apply plugin: 'com.google.gms.google-services'
in gradle, it gives me an error. logcat says:
Error:Execution failed for task ':app:mergeDebugResources'.
> [string/google_api_key] E:\android\Workspace\FireGuard\app\src\main\res\values\strings.xml [string/google_api_key] E:\android\Workspace\FireGuard\app\build\generated\res\google-services\debug\values\values.xml: Error: Duplicate resources
I searched a lot, but no luck. How to remove this error? Please help.
below is my gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "25.0.0"
defaultConfig {
applicationId "com.example.pc.fireguard"
minSdkVersion 16
targetSdkVersion 24
versionCode 1
versionName "1.0"
testInstrumentationRunner"android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
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:24.2.1'
testCompile 'junit:junit:4.12'
compile 'com.android.volley:volley:1.0.0'
compile 'com.mikhaellopez:circularimageview:3.0.2'
compile 'com.android.support:support-v13:24.0.0'
compile 'com.android.support:recyclerview-v7:24.0.0'
compile 'com.google.android.gms:play-services:9.6.1'
compile project(':date4j')
compile project(':simple-crop-image-lib')
compile 'com.squareup.picasso:picasso:2.3.2'
compile project(':httpclient-4.3.4')
compile project(':httpmime-4.3.4')
compile project(':httpcore-4.3.2')
compile 'com.paypal.sdk:paypal-android-sdk:2.15.1'
}
apply plugin: 'com.google.gms.google-services'

Strings.xml in your app is having same name as of values.xml of google services library!
Since this answer has helped you in sorting out the issue, I am posting the same comment as an answer.

Related

Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'on facebook accesstoken.class

I have been having some issues with this for a while
Error:Execution failed for task
':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/facebook/AccessToken$1.class
I do not know what to do, please help.
this is my build gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23"
aaptOptions {
useNewCruncher false
}
defaultConfig {
applicationId "com.example.dell.treblemusic"
minSdkVersion 15
targetSdkVersion 24
versionCode 1
versionName "1.0.1"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
}
lintOptions {
abortOnError false
}
dexOptions {
incremental true
}
}
dependencies {
// compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile files('libs/clink210.jar')
compile files('libs/eventbus-2.4.0.jar')
compile files('libs/picasso-2.5.2.jar')
compile project(':PayPalAndroidSDK-2.12.4')
compile 'com.google.android.gms:play-services-wallet:8.4.0'
compile 'com.stripe:stripe-android:1.0.0'
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'com.android.support:recyclerview-v7:22.2.0'
compile 'com.stripe:stripe-java:1.37.1'
compile 'com.android.support:multidex:1.0.1'
compile project(':VisaCheckout-Android-SDK-2.9')
compile files('libs/card-io-5.1.1.jar')
compile files('libs/android-volley-1.0.10.jar')
compile 'com.pnikosis:materialish-progress:1.0'
compile files('libs/httpclient-4.2.4.jar')
compile files('libs/apache-httpcomponents-httpcore.jar')
compile files('libs/guava-13.0.1.jar')
compile project (':facebook-android-sdk-4.10.0')
compile 'com.android.support:cardview-v7:22.2.1'
}
You might be using different version of sample modules.
Please follow these steps
Add multidex in the gradle
In the module app gradle
android {
......
defaultConfig {
....
multiDexEnabled true
}
Added the dependency
compile 'com.android.support:multidex:1.0.1'
Add the facebook module and exclude dependent libraires
compile('com.facebook.android:facebook-android-sdk:$faceBookVersion') {
exclude group: 'com.android.support', module: 'multidex'
}
If You are using various Google play services like Location, Authentication etc, you should use same level of Libraries.
eg:
compile 'com.google.android.gms:play-services:10.0.1'
compile 'com.google.android.gms:play-services-appindexing:10.0.1'

Error:Execution failed for task ':app:transformClassesWithDexForDebug' in android [duplicate]

This question already has answers here:
DexIndexOverflowException Only When Running Tests
(4 answers)
Closed 5 years ago.
I am stuck with this error for 2 days.
Error:Execution failed for task
':app:transformClassesWithDexForDebucom.android.build.api.transform.Transfor
mException:com.android.ide.common.process.ProcessException:java.util.concurrent.ExecutionException:com.android.dex.DexIndexOverflowException:
method ID not in [0, 0xffff]: 65536
Here is the gradle file:
apply plugin: 'com.android.application'
android
{
compileSdkVersion 26
buildToolsVersion "26.0.2"
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "com.example.pos"
minSdkVersion 19
targetSdkVersion 26
versionCode 1
versionName "1.0"
// multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
exclude 'LICENSE.txt'
exclude 'asm-license.txt'
exclude 'META-INF/ASL2.0'
} }
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:26.0.0-alpha1'
compile 'com.android.support:support-v4:26.0.0-alpha1'
compile 'com.android.support:design:26.0.0-alpha1'
// compile files('libs/gson-2.2.2.jar')
compile files('libs/picasso-2.0.0.jar')
compile files('libs/upg_bridge.jar')
compile files('libs/log4j-1.2.16.jar')
compile files('libs/posindev.jar')
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.squareup.retrofit2:converter-gson:2.1.0'
compile 'com.squareup.okhttp3:logging-interceptor:3.4.1'
compile 'com.squareup.okhttp3:okhttp:3.4.1'
compile 'com.google.code.gson:gson:2.7'
// compile 'com.google.android.gms:play-services-base:10.2.0'
compile 'com.google.android.gms:play-services-base:10.2.1'
compile 'com.jakewharton.timber:timber:4.5.1'
compile project(':commerce-driver-uat-2.27.0.157')
compile project(':ingenico-uat-2.27.0.157')
// compile 'com.android.support:multidex:1.0.1'
compile 'com.squareup:otto:1.3.5'
compile 'com.squareup.okhttp:okhttp:2.7.4'
compile 'com.squareup.okhttp:okhttp-ws:2.7.4'
compile 'com.parse.bolts:bolts-android:1.2.1'
compile 'com.fasterxml.jackson.core:jackson-databind:2.4.4'
compile 'com.couchbase.lite:couchbase-lite-android:1.4.0'
compile 'com.couchbase.lite:couchbase-lite-android-forestdb:1.4.0'
compile 'com.google.android.gms:play-services-vision:10.2.1'
compile project(':mpos.android.accessories.miura-2.25.0')
compile project(':mpos.android.comlinks.tcp-2.25.0')
compile project(':mpos.android.comlinks.bluetooth-2.25.0')
compile project(':mpos.android.core-2.25.0')
compile 'com.android.support:cardview-v7:26.0.0-alpha1'
// compile 'com.google.android.gms:play-services:11.0.4'
}
If I do not add multidex then it won't generate apk. And if I add multidex it shows error in another class, like it won't be able to import some default classes. It says class not found. And those classes I am getting from a module imported in my project. I don't get what's the issue.
Thanks in advance.
Add this line in your gradle file and then clean the project and run application
android {
...
defaultConfig {
...
multiDexEnabled true
}
}

Baffling java.lang.NoClassDefFoundError

I am using org.apache.http.entity.mime.MultipartEntityBuilder to upload images to the server, When I tested in version 7 devices, its works fine but in devices 4.x it throughs error like java.lang.NoClassDefFoundError at runtime. I am not sure where those classes went missing at runtime for 4.x devices.I am using Android Studio 2.3.3.I hope I have messed up Gradle hence the same works fine in 4.x devices when I use the same in a different application.
Build Gradle
android {
compileSdkVersion 25
buildToolsVersion "25.0.0"
defaultConfig {
applicationId "com.xx.xx.xx"
minSdkVersion 16
targetSdkVersion 23
versionCode 32
versionName "4.0.2"
multiDexEnabled true
}
lintOptions{
disable 'MissingTranslation'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
android {
useLibrary 'org.apache.http.legacy'
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
}
}
repositories {
maven { url 'https://jitpack.io' }
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.facebook.android:facebook-android-sdk:4.23.0'
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
compile 'com.google.firebase:firebase-messaging:9.2.1'
compile 'com.google.firebase:firebase-crash:9.2.1'
compile 'com.google.android.gms:play-services-location:9.2.1'
compile 'com.google.android.gms:play-services-appindexing:9.2.1'
compile 'com.loopj.android:android-async-http:1.4.9'
compile 'org.apache.commons:commons-lang3:3.4'
compile 'se.emilsjolander:stickylistheaders:2.7.0'
compile 'com.wdullaer:materialdatetimepicker:2.3.0'
compile 'com.google.android.exoplayer:exoplayer-core:r2.4.1'
compile group: 'org.apache.httpcomponents' , name: 'httpclient-android' , version: '4.3.5.1'
compile('org.apache.httpcomponents:httpmime:4.3') {
exclude module: "httpclient"
}
}
apply plugin: 'com.google.gms.google-services'
Gradle wrapper.properties
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip

Error:Execution failed for task ':java.util.zip.ZipException: duplicate entry: org/apache/commons/io/CopyUtils.class

Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: org/apache/commons/io/CopyUtils.class
It occurs this error.
The app builds success but when I get build apk, android studio show this message
This is my gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion '25'
defaultConfig {
applicationId "com.example.thewell_dev.fourscompany"
minSdkVersion 19
targetSdkVersion 24
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
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:23.2.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
compile 'com.mobsandgeeks:android-saripaar:2.0.3'
compile 'com.koushikdutta.ion:ion:2.1.9'
compile 'gun0912.ted:tedpermission:1.0.2'
compile 'com.android.support:design:22.+'
compile 'com.estimote:sdk:0.13.0'
compile 'jp.wasabeef:glide-transformations:2.0.0'
compile 'com.afollestad:easyvideoplayer:0.3.0'
compile 'com.github.jrvansuita:PickImage:v2.0.0'
compile 'com.amazonaws:aws-android-sdk-s3:2.+'
compile 'com.mindorks:placeholderview:0.6.0'
compile 'com.tsengvn:Typekit:1.0.0'
compile 'com.github.esafirm:RxDownloader:1.0.1'
compile 'com.mlsdev.rximagepicker:library:1.1.2'
compile 'io.reactivex:rxjava:1.0.14'
compile 'com.kbeanie:image-chooser-library:1.5.2#aar'
compile 'com.kbeanie:image-chooser-library:1.5.8'
compile 'io.github.jeancsanchez.photoviewslider:photoviewslider:1.2.0'
compile 'com.nononsenseapps:filepicker:3.1.0'
compile 'com.gjiazhe:scrollparallaximageview:1.0'
compile 'com.droidninja:filepicker:1.0.8'
compile 'com.android.support:multidex:1.0.0'
}
I think external libraries have
Commons-io-1.3.2.jar
Commons-io-2.4.jar
and both have CopyUtils.class
Anyway, It can't build apk and show that message.
Please anyone help me please
There is more than one dependency you have integrated which uses Apache Commons.
just exclude them using following code in gradle.
compile('YOUR_DEPENDENCY') {
exclude module: 'commons-io'
}
Found the solution for this issue . You need to exclude common-io from your app build.gradle .
android {
configurations{
all*.exclude module: 'commons-io'
}
}
Techierj answer is correct, but it will also exclude commons-io:2.4, and in my case I needed that. So you can exclude by specific group:
compile('YOUR_DEPENDENCY') {
exclude group: 'org.apache.commons', module: 'commons-io'
}
This will only exclude version 1.3.2 from org.apache.commons, and will mantain commons.io:commons.io:2.4

Faild to resolve Repository

I have updated my app.Gradle to building tools 25.0.2 also its compiled libraries as shown
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "....."
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'
}
}
packagingOptions { //to avoid the Error:Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'. > com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/LICENSE File1: C:\Users\dasse\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-databind\2.2.2\3c8f6018eaa72d43b261181e801e6f8676c16ef6\jackson-databind-2.2.2.jar File2: C:\Users\dasse\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-core\2.2.2\d20be6a5ddd6f8cfd36ebf6dea329873a1c41f1b\jackson-core-2.2.2.jar File3: C:\Users\dasse\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-annotations\2.2.2\285cb9c666f0f0f3dd8a1be04e1f457eb7b15113\jackson-annotations-2.2.2.jar
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
}
}
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.mikepenz:materialdrawer:5.8.1#aar') { transitive = true }
compile 'com.android.support:appcompat-v7:25.2.1'
compile 'com.android.support:design:25.2.1'
compile 'com.android.support:support-v4:25.1.1'
compile 'com.mikepenz:google-material-typeface:2.2.0.1#aar'
compile 'com.mikepenz:fontawesome-typeface:4.6.0.3#aar'
compile 'com.sothree.slidinguppanel:library:3.3.1'
compile "com.android.support:support-v4:25.1.1"
compile "com.android.support:support-v13:25.1.1"
compile "com.android.support:cardview-v7:25.1.1"
compile 'com.android.support:support-v4:25.1.1'
compile 'com.google.firebase:firebase-database:10.0.1'
compile 'com.google.firebase:firebase-crash:10.0.1'
compile 'com.google.firebase:firebase-auth:10.0.1'
compile 'com.firebase:firebase-client-android:2.3.1'
compile project(path: ':silo-upstream-release')
compile 'com.android.support.constraint:constraint-layout:1.0.0-beta4'
compile 'com.android.support:recyclerview-v7:25.1.1'
compile 'com.android.support:cardview-v7:25.1.1'
compile 'com.github.tiagohm:CodeView:0.1.3'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
and then syncing the project gives
I have clicked install many times and restarted android studio with no effect, the installation or the download of the repos. never started
NB : I have a program trace the speen of the network and the program which use it, It says that Android-St. takes a speed for nearly 5 seconds and then do nothing and the speed reterns to zero
You are using wrong dependencies.
Check the official page.
The support libraries 25.2.1 don't exist.
Use the latest version:
compile 'com.android.support:appcompat-v7:25.1.1'
compile 'com.android.support:design:25.1.1'

Categories

Resources