Duplicate dependency error for gms /analytics android studio 2.2rc2 - android

My app Level Gradle
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 23
buildToolsVersion "24.0.2"
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "com.mss.triplestar"
minSdkVersion 15
targetSdkVersion 23
multiDexEnabled true
}
//====================Add below two line=============
dexOptions {
javaMaxHeapSize "4g" //specify the heap size for the dex process
preDexLibraries = false //delete the already predexed libraries
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:23.4.0'
compile files('libs/dagger-1.2.2.jar')
compile files('libs/javax.inject-1.jar')
compile files('libs/libGoogleAnalyticsServices.jar')
// compile files('libs/libGoogleAnalyticsV2.jar')
compile 'com.google.android.gms:play-services-analytics:9.0.0'
compile files('libs/nineoldandroids-2.4.0.jar')
compile files('libs/vungle-publisher-adaptive-id-3.3.1.jar')
compile 'com.google.android.gms:play-services-ads:9.0.0'
compile project(':wheelLib')
compile 'com.google.android.gms:play-services:9.0.0'
// compile 'com.google.android.gms:play-services-gcm:9.0.0'
compile 'org.apache.httpcomponents:httpclient:4.5'
compile 'com.scottyab:aescrypt:0.0.1'
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support:appcompat-v7:24.2.0'
}
My log output
Information:Gradle tasks [:app:assembleDebug]
Warning:WARNING: Dependency org.apache.httpcomponents:httpclient:4.5 is ignored for debug as it may be conflicting with the internal version provided by Android.
Warning:WARNING: Dependency org.apache.httpcomponents:httpclient:4.5 is ignored for release as it may be conflicting with the internal version provided by Android.
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/analytics/internal/Command$1.class
Information:BUILD FAILED
Information:Total time: 2.579 secs
Information:1 error
Information:2 warnings
Information:See complete output in console
This is my log output i am trying to build and update my project but
it gives me this error if i removed analytic jar than i get easy
tracker error .please help i am stuck at this point getting no clue
.tried all the solutions .Thanks in advance

Since you are adding a legacy version of the Google Analytics SDK for Android you should remove it.
Remove:
compile files('libs/libGoogleAnalyticsServices.jar')
Also add the plugin to the bottom of your app-level build.gradle:
apply plugin: 'com.google.gms.google-services'
Also no reason to use both:
compile 'com.google.android.gms:play-services-ads:9.0.0'
compile 'com.google.android.gms:play-services:9.0.0'
and you shouldn't ever be using compile 'com.google.android.gms:play-services:9.0.0' as that includes every Google Play services library - only use the APIs you need.

change
buildToolsVersion "24.0.2" to 23.0.4

Related

Error:com.android.builder.dexing.DexArchiveBuilderException: Failed to process guava-21.0.jar Android 3.1 Dev Channel

After updating my dependency versions in AndroidStudio3.1, I started getting the following error:
Information:Gradle tasks [:app:assembleDebug]
Error:com.android.builder.dexing.DexArchiveBuilderException: Failed to process C:\Users\Blabla\.gradle\caches\modules-2\files-2.1\com.google.guava\guava\21.0\3a3d111be1be1b745edfa7d91678a12d7ed38709\guava-21.0.jar
Error:com.android.builder.dexing.DexArchiveBuilderException: Error while dexing.
Error:com.android.tools.r8.ApiLevelException: Default interface methods are only supported starting with Android N (--min-api 24): java.util.Collection com.google.common.collect.BiMap.values()
Error:Execution failed for task ':app:transformClassesWithDexBuilderForDebug'.
> com.android.build.api.transform.TransformException: com.android.builder.dexing.DexArchiveBuilderException: com.android.builder.dexing.DexArchiveBuilderException: Failed to process C:\Users\Blabla\.gradle\caches\modules-2\files-2.1\com.google.guava\guava\21.0\3a3d111be1be1b745edfa7d91678a12d7ed38709\guava-21.0.jar
Information:BUILD FAILED in 6s
Information:4 errors
Information:0 warnings
Information:See complete output in console
I have already cleaned and rebuilt project. Checked my "multiDexEnabled true" and 'compile 'com.android.support:multidex:1.0.2' is added.
What else can I do?
EDIT: Adding build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
buildToolsVersion '26.0.2'
defaultConfig {
applicationId "com.blabla"
minSdkVersion 19
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
configurations.all {
resolutionStrategy.force 'com.google.code.findbugs:jsr305:1.3.9'
}
}
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:27.0.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:multidex:1.0.2'
compile 'com.android.support:design:27.0.0'
compile 'com.android.support:cardview-v7:27.0.0'
compile 'com.jakewharton:butterknife:8.7.0'
compile 'com.google.code.gson:gson:2.8.0'
compile 'com.google.guava:guava:21.0'
compile 'com.microsoft.azure:azure-mobile-android:3.2.0#aar'
compile 'com.microsoft.azure:notification-hubs-android-sdk:0.4#aar'
compile 'com.microsoft.azure:azure-notifications-handler:1.0.1#aar'
compile 'com.squareup.okhttp:okhttp:2.5.0'
compile 'com.google.firebase:firebase-core:11.4.2'
compile 'com.google.firebase:firebase-crash:11.4.2'
compile 'com.google.firebase:firebase-auth:11.4.2'
compile 'com.google.firebase:firebase-database:11.4.2'
compile 'com.google.firebase:firebase-storage:11.4.2'
testCompile 'junit:junit:4.12'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.7.0'
compile 'com.google.android.gms:play-services-maps:11.4.2'
compile 'com.google.android.gms:play-services-location:11.4.2'
compile 'com.google.maps.android:android-maps-utils:0.5+'
}
apply plugin: 'com.google.gms.google-services'
I had the same issue in react-native project,
the below lines worked for me,
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
Update your Guava version
Guava 21 is Java 8 only.
Update your gradle to Guava version 27.0.1-android, which is compatible with Android:
Gradle 4.6+:
dependencies {
implementation 'com.google.guava:guava:27.0.1-android'
}
Previous Gradle versions:
dependencies {
compile 'com.google.guava:guava:27.0.1-android'
}
I had same problem and I solved it cleaning project and rebuilding it.
In Android Studio go to Build --> Clean Project and after, Build --> Rebuild Project
Hope it helps
I had the similar case when I switched to OkHttp 4.x. It turned out that I had to disable the method profiling in run configuration:
Edit Configurations -> app -> Profiling tab -> uncheck Enable advanced profiling. It solved my case but I cannot use profiling now on older devices.
In my case, I was getting the error because I was clicking the Debug 'app' button while my build variant was set to release. When I changed my build variant to debug, then clicked the Debug button again, the error went away. I hope this helps someone.
I had the same issue and my problem was dependency conflict.
I searched for the conflict via the gradle dependency tree:
gradlew app:dependencies
Then I excluded the module for the conflicting library (e.g org.json:json):
api ('<conflicting-library>',{
exclude group:'org.json', module:'json'
})

Android Studio dex.DexException:

Randomly got this error during my build (debug or production) in the morning.
com.android.dex.DexException: Multiple dex files define Lcom/crashlytics/android/answers/shim/R
Execution failed for task ':app:transformClassesWithDexForDebug'.
>...
It has been 10hours and I have tried:
1) Updated my Android SDKs
2) Updated my Google Repository
3) Updated everything else as well.
4) Cleaned and Rebuild the project with no errors.
5) Went through my external dependency tree, didn't find any duplicate libraries.
Here is my gradle content:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion '25.0.0'
defaultConfig {
applicationId "######.####"
minSdkVersion 19
targetSdkVersion 25
versionCode 53
versionName "1.2"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile 'com.android.support:appcompat-v7:25.0.0'
compile 'com.android.support:design:25.0.0'
compile 'com.androidmapsextensions:android-maps-extensions:2.3.0'
compile 'com.google.android.gms:play-services-gcm:10.2.1'
compile 'com.google.android.gms:play-services-location:10.2.1'
compile 'com.google.android.gms:play-services-maps:10.2.1'
compile 'com.google.android.gms:play-services-places:10.2.1'
compile 'com.google.maps.android:android-maps-utils:0.5'
compile 'de.hdodenhof:circleimageview:2.0.0'
compile 'org.jsoup:jsoup:1.9.2'
compile 'com.github.lzyzsd:circleprogress:1.1.0#aar'
compile 'com.google.code.gson:gson:2.7'
compile 'io.branch.sdk.android:library:2.+'
compile 'com.google.firebase:firebase-core:10.2.1'
compile 'com.google.firebase:firebase-crash:10.2.1'
compile 'com.facebook.android:facebook-android-sdk:4.+'
compile 'net.yslibrary.keyboardvisibilityevent:keyboardvisibilityevent:1.0.1'
compile 'com.android.support:support-v4:25.0.0'
compile 'com.edmodo:rangebar:1.0.0'
compile 'com.appyvet:materialrangebar:1.3'
compile 'com.facebook.fresco:fresco:0.14.1'
compile 'com.google.firebase:firebase-messaging:10.2.1'
compile 'com.android.support:recyclerview-v7:25.0.0'
}
apply plugin: 'com.google.gms.google-services'
Running out of ideas and google result pages for a solution. Does anybody experienced find something wrong with the libraries I use or the versions?
Thanks!
remove this line = compile 'com.android.support:design:25.0.0'
if it doesn't work please add
dexOptions {
preDexLibraries = false }
to your build.gradle file
Solution found.
Looking at the error I googled and found this.
Then went to the Branch documentation and found this here which stated:
Note that if you don’t plan to use the Fabric Answers integration, you
can use the following line:
compile ('io.branch.sdk.android:library:2.+') {
exclude module: 'answers-shim'
}
This answers-shim is also in the stacktrace.
I wonder where is that module then duplicated?

Duplicate entry error in my Android app

This error occurs when I sync the gradle file
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/zxing/client/android/camera/CameraConfigurationUtils.class
I tried cleaning the project, rebuilding the project and multidex, excluding the module.
My min sdk is 19. If greater than 20, multidex worked properly,
but in SDK 19 it didn't work.
This is my gradle build file:
apply plugin: 'com.android.application'
android
{
compileSdkVersion 24
buildToolsVersion '25.0.2'
defaultConfig
{
applicationId "com.example.prototype_01"
minSdkVersion 19
targetSdkVersion 22
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes
{
release
{
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies
{
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.1.1'
compile 'com.android.support:design:24.1.1'
compile 'com.google.android.gms:play-services-appindexing:9.6.1'
compile 'com.android.support:multidex:1.0.0'
compile 'com.journeyapps:zxing-android-embedded:3.2.0#aar'
compile 'com.google.zxing:core:3.2.0'
compile 'com.github.bumptech.glide:glide:3.5.1'
//compile files('libs/android-core-3.2.1.jar')
compile 'com.android.support:support-v4:24.2.1'
compile 'com.tsengvn:Typekit:1.0.0'
compile 'com.google.firebase:firebase-messaging:9.6.1'
}
apply plugin: 'com.google.gms.google-services'
What can be done to solve this issue?
It is not related to Multidex.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/zxing/client/android/camera/CameraConfigurationUtils.class
It means that you are adding the same class CameraConfigurationUtils.class twice.
Check your jar files.
If you have libs/android-core-3.2.1.jar you are adding twice the same class.
This class is inside the jar and inside the library compile 'com.journeyapps:zxing-android-embedded:3.2.0#aar'.
Remove the jar file from the libs folder.
duplicate entry: com/google/zxing/
You've added too many libraries. Try removing one at a time until your app can build.
Start with removing any conflicting Jar files from libs related to Zxing
Zxing core is not necessary, the embedded one already compiles it
compile 'com.journeyapps:zxing-android-embedded:3.2.0#aar'
// compile 'com.google.zxing:core:3.2.0'
Multidex / changing your SDK version isn't going to magically fix overlapping dependencies

Android - transform Classes With Dex For Debug

My project was working fine until I added the Facebook dependency.
I've started getting this error.
I've read many question, the problem seems to be related to MultiDex.
But none of the solutions worked for me
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException:
com.android.ide.common.process.ProcessException:
org.gradle.process.internal.ExecException: Process 'command
'/usr/lib/jvm/java-7-openjdk-amd64/bin/java'' finished with non-zero exit value 1
Even after I remove what I've added, it still show and also gradle seems to be taking a lot of time while building than usual
Here is my build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "net.ciblo.spectrodraft"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
repositories {
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
}
compile 'com.facebook.android:facebook-android-sdk:[4,5)'
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support:appcompat-v7:23.2.1'
compile 'com.android.support:cardview-v7:23.2.1'
compile 'com.android.support:design:23.2.1'
compile 'com.daimajia.easing:library:1.0.1#aar'
compile 'com.daimajia.androidanimations:library:1.1.3#aar'
compile 'com.google.android.gms:play-services:8.4.0'
compile 'com.mcxiaoke.volley:library-aar:1.0.0'
compile 'com.pnikosis:materialish-progress:1.5'
compile 'com.nineoldandroids:library:2.4.+'
compile 'com.michaelpardo:activeandroid:3.1.0-SNAPSHOT'
compile 'com.android.support:support-v4:23.2.1'
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
}
Adding the following code to build.gradle app module solved my problem
android{
defaultConfig {
// Enabling multidex support.
multiDexEnabled true
}
dexOptions {
javaMaxHeapSize "4g"
}
}
dependencies {
//...
compile 'com.android.support:multidex:1.0.0'
}
you can selectively compile Google Play service APIs into your app. For example, to include only the Google Fit and Android Wear APIs, replace the following line in your build.gradle file:
compile 'com.google.android.gms:play-services:8.4.0'
with these lines:
compile 'com.google.android.gms:play-services-fitness:8.4.0'
compile 'com.google.android.gms:play-services-wearable:8.4.0'
==> to keep the number of methods in your app (including framework APIs, library methods, and your own code) under the 65,536 limit.
Adding the following in build.gradle fixed the issue for me,
android {
//...
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
//...
}
This horrendous recurring issue hit me again recently. The gradle build stalls permanently at app:transformClassesWithDexForDebug, just running for hours and never completing. This time I fixed it by removing all references to 'fabric', a new layer of Crashlytics being pushed on us.
//apply plugin: 'io.fabric' //REMOVE
//classpath 'io.fabric.tools:gradle:1.26.1' //REMOVE

Android Studio `jdk1.7.0_51\bin\java.exe'' finished with non-zero exit value 2`

I am all of a sudden getting the following issue when I try to build my application:
at com.android.dx.merge.DexMerger$6.updateIndex(DexMerger.java:502)
at com.android.dx.merge.DexMerger$IdMerger.mergeSorted(DexMerger.java:277)
at com.android.dx.merge.DexMerger.mergeMethodIds(DexMerger.java:491)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:168)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:502)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:334)
at com.android.dx.command.dexer.Main.run(Main.java:277)
at com.android.dx.command.dexer.Main.main(Main.java:245)
at com.android.dx.command.Main.main(Main.java:106)
Error:Execution failed for task ':app:dexDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.7.0_51\bin\java.exe'' finished with non-zero exit value 2'
From reading other threads it has something to do with having more than 65k methods. however My app is no where near that many, it is still a small app. Im not sure if that includes additional libraries included in the gradle file.
here is my gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion '23.0.1'
defaultConfig {
applicationId "com.domain.app"
minSdkVersion 14
targetSdkVersion 23
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile files('libs/jasypt-1.9.2.jar')
apply plugin: 'com.google.gms.google-services'
compile 'com.android.support:support-v4:23.1.0'
compile 'com.google.code.gson:gson:2.3'
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'me.dm7.barcodescanner:zbar:1.6.3'
compile 'com.loopj.android:android-async-http:1.4.9'
compile 'com.google.android.gms:play-services:8.1.0'
compile 'com.astuetz:pagerslidingtabstrip:1.0.1'
compile 'com.android.support:recyclerview-v7:23.1.0'
compile 'com.android.support:cardview-v7:23.1.0'
compile 'com.mobsandgeeks:android-saripaar:2.0.3'
compile 'com.github.satyan:sugar:1.3.1'
compile 'uk.co.ribot:easyadapter:1.5.0#aar'
compile 'com.android.support:design:23.1.0'
}
How can I determine If I am reaching this limit, If so is there a way to see which included library is so large? Also what are the drawbacks to enabling multiDexEnabled true?
If I must be honest I would rather not enable multiDex and this application should not be this large. I would rather fix the source of the problem.
This eror happens because you have more than 65k methods which exceeds the capacity of dex.
You can use this lib to check if you have more than 65k methods or not https://github.com/KeepSafe/dexcount-gradle-plugin
You should had to your gradle if you have more than 65k and you need them
defaultConfig {
applicationId "com.domain.app"
minSdkVersion 14
targetSdkVersion 23
multiDexEnabled true // Add this
}
Please check the documentation here http://developer.android.com/tools/building/multidex.html
Although if you do not need all methods of play-services use what you really need, you should check this documentation to use what you only need.
https://developers.google.com/android/guides/setup
Additionally, as #IntelliJAmiya said remove this
apply plugin: 'com.google.gms.google-services'
because is duplicated, you are already using
'com.google.android.gms:play-services:8.1.0'
add this to your build grandle
android {
.....
multiDexEnabled true
}
and add multidex to your dependencies and try to build again
dependencies {
compile 'com.android.support:multidex:1.0.0'
}
EDIT : add in your manifest the mutltidex app :
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android.multidex.myapplication">
<application
...
android:name="android.support.multidex.MultiDexApplication">
...
</application>
</manifest>
EDIT 2 : OR, if you have a class who extends Application, add MultiDex.install(this) in the attachBaseContext() of your class (override it if not exist)
Remove this at first
apply plugin: 'com.google.gms.google-services'
Actually you already call compile 'com.google.android.gms:play-services:8.1.0' .So don't need to call again .
Then Clean and Rebuild
Finally
dependencies {
compile files('libs/jasypt-1.9.2.jar')
compile 'com.android.support:support-v4:23.1.0'
compile 'com.google.code.gson:gson:2.3'
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'me.dm7.barcodescanner:zbar:1.6.3'
compile 'com.loopj.android:android-async-http:1.4.9'
compile 'com.google.android.gms:play-services:8.1.0'
compile 'com.astuetz:pagerslidingtabstrip:1.0.1'
compile 'com.android.support:recyclerview-v7:23.1.0'
compile 'com.android.support:cardview-v7:23.1.0'
compile 'com.mobsandgeeks:android-saripaar:2.0.3'
compile 'com.github.satyan:sugar:1.3.1'
compile 'uk.co.ribot:easyadapter:1.5.0#aar'
compile 'com.android.support:design:23.1.0'
}
Edit 1
call multiDexEnabled true
Looks
defaultConfig {
applicationId "com.domain.app"
minSdkVersion 14
targetSdkVersion 23
multiDexEnabled true
}
And add this
compile 'com.android.support:multidex:1.0.1'

Categories

Resources