:app:dexDebug on adding libGoogleAnalyticsServices - android

On trying to run my project, I get the following error:
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_67\bin\java.exe'' finished with non-zero exit value 2
I am adding the google analytics jar file from here. The issue goes away if I remove this line compile files('libs/libGoogleAnalyticsServices.jar') from the dependencies in the build.gradle
Is 1libGoogleAnalyticsServices.jar` interfering with something else I have in my dependencies?
dependencies {
//compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.facebook.android:facebook-android-sdk:4.1.1'
compile files('libs/nineoldandroids-2.4.0.jar')
compile files('libs/newrelic.android.jar')
compile files('libs/libGoogleAnalyticsServices.jar')
compile files('libs/YouTubeAndroidPlayerApi.jar')
compile 'com.google.android.gms:play-services:7.5.0'
compile('de.keyboardsurfer.android.widget:crouton:1.8.5#aar') {
}
compile ("com.doomonafireball.betterpickers:library:1.6.0")
compile ("com.doomonafireball.betterpickers:library:1.6.0") {
transitive = true
exclude group: 'com.android.support', module: 'support-v4'
}
compile project(':circularImageView')
}

This error could also indicate that you've hit the 65k method limit in Android.
If this is the case, then you have 3 options
Selectively use the parts of the play-services library that are required. This library itself will bring you close to the limit.
Let Progaurd minimize your application.
Use Multi-dex to split your dex index.
These guides will help you to achieve the options above;
http://googleadsdeveloper.blogspot.ie/2015/01/reducing-google-play-services-impact-on.html
https://developer.android.com/tools/building/multidex.html

Per the page you linked:
Important: This document describes a legacy version of the SDK. New users should use the latest SDK.
As the latest SDK is included in your 'com.google.android.gms:play-services:7.5.0' dependency, the two are overlapping and causing issues when building your application. You should instead follow the getting started guide for Google Analytics v4

Related

duplicated class caused by mulitedex dependecy in Android Studio

thank you for your support.
My issue is : When I added the multidex dependecy and try to export the signed apk, I get this error :
Error:Execution failed for task
':androidKeyboardThemes:transformClassesWithJarMergingForRelease'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/location/ActivityRecognition$1.class
My gradle dependecies are theses:
dependencies {
compile project(':cropper')
compile 'com.google.android.gms:play-services:+'
compile files('libs/StartAppInApp-2.4.7.jar')
compile files('libs/google-play-services.jar')
compile 'com.android.support:multidex:1.0.1'
}
I tried to delete one lib or jar at any time and build again but I couldn't get the job done.
Also I read all the unswer about duplicated class in stackoverflow but I failed again to solve my issue.
Any ideas?, thank you for your help.
dependencies {
compile project(':cropper')
compile 'com.google.android.gms:play-services:+' <-- choose either one
compile files('libs/StartAppInApp-2.4.7.jar')
compile files('libs/google-play-services.jar') <-- choose either one
compile 'com.android.support:multidex:1.0.1'
}
Whatever it is, please dont use play-services. inside compile 'com.google.android.gms:play-services:+' contains alot of dependencies.. see below.. using play-services may cause dex problem and heavy app. refer here

Android, one library with old google play service conflicts with google maps

I'm using asne google plus library for my project. It uses older version of google play service.
When I add Google maps with newer version, gradle build fails with this message:
Error:Execution failed for task ':app:processDebugResources'.
Error: more than one library with package name 'com.google.android.gms'
My dependencies in my app.gradle:
compile 'com.github.asne:asne-googleplus:0.3.3'
compile 'com.google.android.gms:play-services-maps:8.3.0'
compile 'com.google.android.gms:play-services-location:8.3.0'
When I make asne like this:
compile ('com.github.asne:asne-googleplus:0.3.3') {
transitive = true
}
This lib becomes invisible and I can't call its methods.
How to resolve this conflict?
I suggests that you use the entire dependency
compile 'com.google.android.gms:play-services:8.3.0'
and not split it into parts like play-services-location:8.3.0 and play-services-maps:8.3.0. This link provides a detailed explanation why.
You could try to just exclude the google dependencies of the library:
compile ('com.github.asne:asne-googleplus:0.3.3') {
exclude group: 'com.google.android.gms'
}

Android Studio multiple jar finished with non-zero exit value 2 error

I have an app using many modules such as facebookSDK, linkedInSDK etc. I needed to add one more module that is using volley library which is also used in linkedInSDK.
It builds successfully but causes:
Error:Execution failed for task ':splashActivity:dexDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_31\bin\java.exe'' finished with non-zero exit value 2
this error.
app build.gradle:
compile(name: 'app-debug', ext: 'aar')
compile 'com.android.support:support-v4:22.2.0'
compile 'com.mcxiaoke.volley:library:1.0.17#aar'
compile 'com.android.support:appcompat-v7:22.2.0'
linkedInSDK build.gradle:
compile 'com.android.support:support-v4:18.0.0'
compile files('libs/volley.jar')
As you can see, they both use volley library. When I remove one of them it throws cannot be resolved error in that module.
I tried
defaultConfig {
multiDexEnabled true
}
it didn't work.
Both app and linkedInSDK modules needs volley library. How can I build and run it successfully
I think some solution is present on the 'gradle' foram. can you please try this.
dependencies {
compile('packageName:name:version') {
//excluding a particular transitive dependency:
exclude module: 'name of excluing package' //by artifact name
}
}
"Happy Coding...!!!"
I solved it by moving my brand new module to the linkedInSDK and enabling multiDex. So I saw I had two problems, the first one is my project is over 65k Methods which needs multiDex, and library conflict between linkedInSDK and the new SDK.
So here is my linkedInSDK\build.gradle:
dependencies {
compile files('libs/volley.jar')
compile 'com.android.support:support-v4:22.2.0'
compile 'com.android.support:appcompat-v7:22.2.0'
//compile 'com.mcxiaoke.volley:library:1.0.17'
compile(name: 'app-debug', ext: 'aar')
}
repositories {
flatDir {
dirs 'libs'
}
}
So the volley library is used in the same module without conflict. Yay!

Gradle Build failed - Java.exe is finished with non-zero exit value 2

I have added recyclerview gradle build and then tried to run the app, and now I get this error:
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_79\bin\java.exe'' finished with non-zero exit value 2
Here is my gradle build file:
dependencies {
compile 'com.android.support:appcompat-v7:22.1.1'
compile 'com.android.support:recyclerview-v7:22.1.1'
compile fileTree(dir: 'libs', include: 'Parse-*.jar')
compile 'com.parse.bolts:bolts-android:1.2.0'
compile 'com.android.support:design:22.2.0'
compile 'com.google.android.gms:play-services:7.5.0'
compile 'com.facebook.fresco:fresco:0.5.2+'
compile 'com.facebook.android:facebook-android-sdk:4.1.0'
compile fileTree(dir: 'libs', include: 'commons-io-*.jar')
compile fileTree(dir: 'libs', include: 'ParseFacebookUtilsV4-*.jar')
}
How to fix this?
It looks like you have reached the dex limit and you have over 65k methods in your application.
If you want to keep all of your gradle dependencies as is, you should look into configuring multidex that way it will build your application using multiple dex files.
Another solution would be to try and remove any unnecessary dependencies from the google play services library. Chances are you don't need to include everything and you can choose to add only the imports you need.
For example:
com.google.android.gms:play-services-maps:7.5.0
com.google.android.gms:play-services-gcm:7.5.0
Rather than simply using:
compile 'com.google.android.gms:play-services:7.5.0'
You can reference the Google Play Services guide to determine which pieces of library you should add.
Android Studio suggests,
Avoid using + in version numbers can lead to unpredictable and unrepeatable builds.
+ in dependencies lets you pick up automatically the latest available version rather than a specific one, however this is not recommended.
You may have tested with a slightly different version than what build server used.
After Removing Plus Sign and Adding a Specific Version problem was solved.

Duplicate files while including butterknife with gradle

I have a basic Android app that I created with Android Studio, and I'm having problems adding butterknife to my build. I get this error:
Error:: duplicate files during packaging of APK C:\apps\orion\app\build\apk\app-debug-unaligned.apk
Error:Execution failed for task ':app:packageDebug'.
> Duplicate files copied in APK META-INF/services/javax.annotation.processing.Processor
File 1: C:\Users\andres\.gradle\caches\modules-2\files-2.1\com.jakewharton\butterknife\4.0.1\f43b36925363701633d01adb8e54df7150397a78\butterknife-4.0.1.jar
File 2: C:\Users\andres\.gradle\caches\modules-2\files-2.1\com.jakewharton\butterknife\4.0.1\f43b36925363701633d01adb8e54df7150397a78\butterknife-4.0.1.jar
My dependencies look like this:
dependencies {
compile 'com.android.support:support-v4:+'
compile 'com.squareup.dagger:dagger-compiler:1.2.1'
compile 'com.squareup.dagger:dagger:1.2.1'
compile 'com.jakewharton:butterknife:4.0.1'
compile 'com.google.android.gms:play-services:4.0.30'
compile 'com.android.support:appcompat-v7:+'
compile project(':lib')
compile fileTree(dir: 'libs', include: ['*.jar'])
}
Later versions of the plugin will tell you how to fix this. I think we introduced the fix in 0.8 so you should probably upgrade. Then the fix is to put this in your build.gradle
android {
packagingOptions {
exclude 'META-INF/services/javax.annotation.processing.Processor'
}
}
This will exclude this file from the packaging which is fine since it's not actually needed in the APK.
That's because you wrote compile for dagger-compiler, replace it with provided and the issue will be fixed.
compile 'com.squareup.dagger:dagger:1.2.1'
provided 'com.squareup.dagger:dagger-compiler:1.2.1'
The best option in version >= 0.9.1 of Gradle build tools is probably:
android {
packagingOptions {
pickFirst 'META-INF/services/javax.annotation.processing.Processor'
}
}
For more, see the Android Tools Project page: New Build System.
Edit:
One last note here if you start having problems with generated code, make sure to structure your dependencies properly. I ended up removing any exclusion of the Processor line and structuring my annotation processed dependencies like:
compile "org.parceler:parceler-api:0.2.15"
apt "org.parceler:parceler:0.2.15"
and
provided 'com.squareup.dagger:dagger-compiler:1.2.2'
apt 'com.squareup.dagger:dagger-compiler:1.2.2'
If after applying above given solutions you still face the same issue as I was, then if you are using glide library then change the version of the glide to it's max.
eg.
implementation 'com.github.bumptech.glide:glide:4.10.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.10.0'

Categories

Resources