Execution failed for task ':app:transformClassesWithDexForDebug' in small app - android

I am trying to build an Android project (it is a small project), and I am getting this error in Travis:
* What went wrong:
Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536
I am aware I can fix this problem by enabling multiDex, however I don't think this error should happen in my case, as I don't believe the project and its dependencies surpass the method limit for multiDex.
Here are the dependencies in my build.gradle file:
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 project(':geth')
compile 'com.android.volley:volley:1.0.0'
compile 'com.google.android.gms:play-services-maps:10.0.1'
compile 'com.android.support:appcompat-v7:25.1.0'
compile 'com.android.support:support-v4:25.1.0'
compile 'com.android.support:design:25.1.0'
testCompile 'junit:junit:4.12'
}
Any ideas?
Thanks

You exceeded 65536 methods. Maybe this :geth project is too big?
You can turn multidexing on, more info here:
https://developer.android.com/studio/build/multidex.html
You can check what part of your project taking too much method indexes with:
https://github.com/KeepSafe/dexcount-gradle-plugin

Related

what the solution of Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'

I have tried to compile and I have no errors, but when I want to run the app I get this error:
Error:Execution failed for task
':app:transformClassesWithJarMergingForDebug'.
> com.android.build.api.transform.TransformException:
java.util.zip.ZipException: duplicate entry:
com/google/gson/annotations/Expose.class
my dependencies is :
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 files('src/include/gson-2.8.2-SNAPSHOT.jar')
compile 'com.android.support:appcompat-v7:23.2.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:design:23.2.0'
compile 'io.searchbox:jest-droid:2.0.1'
testCompile 'junit:junit:4.12'
I've noticed your question is a duplicate of this
As the accepted answer in that question states, you must multi-compiling GSON here
compile files('src/include/gson-2.8.2-SNAPSHOT.jar')
and in another library... I'm going to assume it's this one:
compile 'io.searchbox:jest-droid:2.0.1'
So I'd advise replicating the accepted answer for your project, like so:
compile('io.searchbox:jest-droid:2.0.1') {
exclude module: 'gson'
}

Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug' in android + volley libraries

I've read article this in backendless and this and this in StackOverflow. But there isn't any help for me. I searched everywhere but there isn't any solution.The error is bellow
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexException: Multiple dex files define Lcom/android/volley/VolleyError;
In build.gradle
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.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:25.3.1'
androidTestCompile 'com.mcxiaoke.volley:library:1.0.18'
compile project(":volley")
compile 'com.mcxiaoke.volley:library:1.0.18'
}
This error will disappear when removing compile 'com.mcxiaoke.volley:library:1.0.18' in build.gradle.
What I need to be done is pass the data within app and server(localhost). To pass the string I'm using JSON. In android app using Volley libraries.
What would be I missed? Thank you
I'm searching everywhere but there aren't any references
The documentation shows that Google's official Volley artifact is available via:
compile 'com.android.volley:volley:1.0.0'
Use that instead of com.mcxiaoke.volley:library:1.0.18, which was published two years ago.
Now, you also have compile project(":volley"). I do not know why. Use either com.android.volley:volley:1.0.0 or compile project(":volley"), not both. Unless you have some specific reason for using the library module (e.g., you are forking Volley), I would recommend using the com.android.volley:volley:1.0.0 artifact.

Multiple dex files define Landroid/support/v4/... error

I just included some Glide libraries and the Gradle builds fine.
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.1', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:23.1.1'
testCompile 'junit:junit:4.12'
compile files('libs/glide-3.7.0.jar')
compile files('libs/glide-3.7.0-javadoc.jar')
compile files('libs/android-support-v4.jar')
annotationProcessor 'com.github.bumptech.glide:compiler:4.0.0-RC1'
}
But I run into this:
Error:Error converting bytecode to dex:
Cause: com.android.dex.DexException: Multiple dex files define Landroid/support/v4/app/ActivityCompatHoneycomb;
As well as this:
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: java.lang.UnsupportedOperationException
Would appreciate any tips on getting this sorted out.
There are two dependencies causing a conflict. compile 'com.android.support:appcompat-v7:23.1.1' and compile files('libs/android-support-v4.jar')
I manually included the libs/android-support-v4.jar in the library directory since Glide requires it then removed the compile files('libs/android-support-v4.jar') dependency. The Gradle synced well after that, and the error was cleared.

How to use YouTube Analytics API in Android

I need to get some statistics about a certain youtube channel searched by user, and YouTube Data API doesn't provide me enough data. So how can I use YouTube Analytics API to get more data abou an youtube channel?
I can't use their lib:
compile 'com.google.apis:google-api-services-youtubeAnalytics:v1-rev73-1.22.0'
because it gives me error, and I don't want to enable multidex:
Error:Execution failed for task
':app:transformClassesWithDexForDebug'.
com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException:
java.util.concurrent.ExecutionException:
com.android.dex.DexIndexOverflowException: method ID not in [0,
0xffff]: 65536
all my dependences are:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:25.0.1'
compile 'com.android.support:design:25.0.1'
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.squareup.retrofit2:converter-gson:2.1.0'
compile 'com.squareup.retrofit2:adapter-rxjava:2.1.0'
compile 'com.squareup.okhttp3:logging-interceptor:3.3.+'
compile 'io.reactivex:rxandroid:1.0.1'
compile 'com.google.android.gms:play-services-ads:10.0.1'
compile "com.google.android.gms:play-services-gcm:10.0.1"
compile ('com.google.apis:google-api-services-youtubeAnalytics:v1-rev73-1.22.0'){
exclude module: 'httpclient' //by artifact name
exclude group: 'org.apache.httpcomponents' //by group
exclude group: 'org.apache.httpcomponents', module: 'httpclient' //by both name and group
}}
Check this documentation for the different types of reports you can retrieve using the API. Most of the workarounds I have read is to add multiDexEnabled true to your app build.gradle file.
com.android.build.transform.api.TransformException
Android Studio TransformException : Error:Execution failed for task ':app:transformClassesWithDexForDebug'
Since you don't want to enable it, I can suggest to remove unused code with ProGuard. You should enable code shrinking to run ProGuard for your release builds. Enabling shrinking ensures you are not shipping unused code with your APKs.
You can refer with this another SO answer on how to get both statistics and snippet printed to the console with single api call.

generate signed APK error : java.util.zip.ZipException

I use my samsung A5 for testing app and the project is working correctly on my phone, but not working on other phones. so I want to Generate signed APK from my project. but there was an exception error:
Error:Execution failed for task '::transformClassesWithDexForRelease'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexException: Multiple dex files define Lcom/daimajia/androidanimations/library/BaseViewAnimator;
I googled the error and these code remove that error:
multiDexEnabled true
and
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/license.txt'
exclude 'META-INF/notice.txt'
}
but now there is another exception:
Error:Execution failed for task ':transformClassesWithJarMergingForRelease'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/daimajia/androidanimations/library/BaseViewAnimator.class
I think this might be because of libraries that I use, but have no idea how to handle it. below is all libraries in build.gradle :
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
//for compiling card view
compile 'com.android.support:cardview-v7:23.0.0'
compile 'com.android.support:recyclerview-v7:23.0.0'
//for sticky header
compile 'com.github.carlonzo.stikkyheader:core:0.0.3-SNAPSHOT'
compile 'com.github.ksoichiro:android-observablescrollview:1.5.0'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.melnykov:floatingactionbutton:1.0.7'
compile 'com.ogaclejapan.smarttablayout:library:1.6.1#aar'
compile 'com.ogaclejapan.smarttablayout:utils-v4:1.6.1#aar'
compile 'me.drakeet.materialdialog:library:1.3.1'
compile files('libs/volley.jar')
compile 'com.daimajia.easing:library:1.0.1#aar'
compile 'com.daimajia.androidanimations:library:1.1.3#aar'
//Sweet Alert Dialog
compile 'cn.pedant.sweetalert:library:1.3'
compile 'org.apmem.tools:layouts:1.10#aar'
}
A few things...
First of all, I'd remove most of the 3rd party libraries you are including. For example,
//for sticky header
compile 'com.github.carlonzo.stikkyheader:core:0.0.3-SNAPSHOT'
compile 'com.github.ksoichiro:android-observablescrollview:1.5.0'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.melnykov:floatingactionbutton:1.0.7'
all of those are covered by the Design Support Library from Google
From the names I think you can also remove
compile 'com.ogaclejapan.smarttablayout:library:1.6.1#aar'
compile 'com.ogaclejapan.smarttablayout:utils-v4:1.6.1#aar'
compile files('libs/volley.jar') should be replaced with compile 'com.android.volley:volley:1.0.0'
and I'd also remove
//Sweet Alert Dialog
compile 'cn.pedant.sweetalert:library:1.3'
compile 'org.apmem.tools:layouts:1.10#aar'
Many of those projects you are including haven't been worked on in over 2 years.
Try to still with the support libraries from Google. You'll get most of this from the Design support library.
Last point. You are getting the Dex errors because the app is including all of these libraries and passing the 64k method limit. I suggest enabling proguard to remove un-used code and reduce the method count of your project.

Categories

Resources