i am newbie to Android Studio, every time when try to Run my app, face the exception
Error:Execution failed for task ':abc:dexDebug'.
com.android.ide.common.internal.LoggedErrorException: Failed to run command:
/home/nik/Installs/adt-bundle-linux-x86_64-20140702/sdk/build-tools/21.1.2/dx --dex --no-optimize --output /home/nik/workspace/androidstudio/abc/build/intermediates/dex/debug --input-list=/home/nik/workspace/androidstudio/abc/build/intermediates/tmp/dex/debug/inputList.txt
Error Code:
2
Output:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Lcom/abc/xyz/BuildConfig;
at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)
at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)
at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:303)
at com.android.dx.command.dexer.Main.run(Main.java:246)
at com.android.dx.command.dexer.Main.main(Main.java:215)
at com.android.dx.command.Main.main(Main.java:106)
try lot of solution like delete BuildConfig file etc but without luck. After lot of googling i just understand, problem related to multiple dependencies file but unable to solve.
Also try command
gradle -q dependencies
but fail with this error
FAILURE: Build aborted because of an internal error.
What went wrong:
Build aborted because of an unexpected internal error. Please file an issue at: http://forums.gradle.org.
Also i like to mention i am try to migrate my project from eclipse and its build successfully when run Build->Rebuild Project in Android Studio
boxAndroidLibraryV2
dependencies {
compile project(':boxJavaLibraryV2')
compile 'com.android.support:support-v4:19.1.0'
//compile 'com.android.support:support-v4:18.0.0'
compile files('libs/commons-codec.jar')
compile files('libs/commons-io-2.3.jar')
compile files('libs/commons-lang-2.6.jar')
compile files('libs/commons-logging-1.1.1.jar')
compile files('libs/httpclient-cache-4.2.5.jar')
compile files('libs/httpmime-4.2.5.jar')
compile files('libs/jackson-annotations-2.0.0.jar')
compile files('libs/jackson-core-2-1.0.0.jar')
compile files('libs/jackson-databind-2-1.0.0.jar')
}
boxJavaLibraryV2
dependencies {
compile files('libs/cglib-nodep-2.2.2.jar')
compile files('libs/commons-codec-1.6.jar')
compile files('libs/commons-io-2.3.jar')
compile files('libs/commons-lang-2.6.jar')
compile files('libs/commons-logging-1.1.1.jar')
compile files('libs/easymock-3.1.jar')
compile files('libs/httpclient-4.2.5.jar')
compile files('libs/httpclient-cache-4.2.5.jar')
compile files('libs/httpcore-4.2.4.jar')
compile files('libs/httpmime-4.2.5.jar')
compile files('libs/jackson-annotations-2.0.0.jar')
compile files('libs/jackson-core-2-1.0.0.jar')
compile files('libs/jackson-databind-2-1.0.0.jar')
compile files('libs/junit-4.8.2.jar')
compile files('libs/powermock-easymock-1.4.12-full.jar')
compile files('libs/robolectric-1.2-20121030.213744-165-jar-with-dependencies.jar')
}
mylib
dependencies {
compile 'com.android.support:support-v4:19.1.0'
compile 'com.google.guava:guava:17.0'
compile files('libs/commons-codec.jar')
compile files('libs/sqlcipher.jar')
}
myApp
dependencies {
compile project(':boxAndroidLibraryV2')
compile project(':liveSdk')
compile project(':mylib')
compile 'com.android.support:support-v4:19.1.0'
compile 'com.google.http-client:google-http-client-gson:1.19.0'
compile 'com.google.code.gson:gson:2.1'
compile 'com.google.android.gms:play-services:+'
compile files('libs/HockeySDK-3.0.2.jar')
compile files('libs/dropbox-android-sdk-1.5.4.jar')
compile files('libs/google-api-client-1.14.1-beta.jar')
compile files('libs/google-api-client-android-1.14.1-beta.jar')
compile files('libs/google-api-services-drive-v2-rev70-1.14.1-beta.jar')
compile files('libs/google-http-client-1.14.1-beta.jar')
compile files('libs/google-http-client-android-1.14.1-beta.jar')
compile files('libs/google-oauth-client-1.14.1-beta.jar')
compile files('libs/icu4j-4.8.1.jar')
compile files('libs/in-app-purchasing-2.0.59.jar')
compile files('libs/json_simple-1.1.jar')
}
i know some dependencies are multiple in box library like
compile files('libs/commons-io-2.3.jar')
compile files('libs/commons-lang-2.6.jar')
but if i am try to remove these than face exception
Error:(6, 29) error: package org.apache.commons.io does not exist
Error:(80, 13) error: cannot find symbol variable IOUtils
Error:(6, 32) error: cannot find symbol class CharEncoding
Error:(57, 75) error: cannot find symbol variable CharEncoding
Error:(58, 79) error: cannot find symbol variable CharEncoding etc...
Thanks for any suggestion
after lot of trials
dexOptions {
preDexLibraries = false
javaMaxHeapSize "4g"
}
this worked for me..
Related
I am successfully able to generate the debug apk of my Android app. But while generating a signed version I get the message:
Warning:there were 1 unresolved references to library class members.
You probably need to update the library versions.
(http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedlibraryclassmember)
Warning:Exception while processing task java.io.IOException: Please correct the above warnings first.
:app:transformClassesAndResourcesWithProguardForRelease FAILED
Error:Execution failed for task
':app:transformClassesAndResourcesWithProguardForRelease'.
java.io.IOException: Please correct the above warnings first.
Following is the list of my project dependencies:
dependencies {
compile 'ch.acra:acra:4.5.0'
compile project(':androidHorizontalListView')
compile 'cz.msebera.android:httpclient:4.4.1.1'
compile 'com.android.support:multidex:1.0.0'
compile 'com.facebook.android:facebook-android-sdk:4.7.0'
compile 'com.android.support:appcompat-v7:24.0.0'
compile 'com.github.bumptech.glide:glide:3.5.2'
compile 'com.google.android.gms:play-services:8.3.0'
compile 'com.mikhaellopez:circularimageview:3.0.2'
compile 'com.android.support:design:24.0.0'
compile 'com.github.danylovolokh:hashtag-helper:1.1.0'
compile 'com.android.support:support-v4:24.0.0'
compile 'pl.droidsonroids.gif:android-gif-drawable:1.1.+'
compile 'com.android.support:cardview-v7:24.0.0'
compile 'com.android.support:recyclerview-v7:24.0.0'
}
methodscount.com shows, that Acra (v 4.5.0) depends on:
org.json:json:20080701
You have two choices:
Update Acra to version 4.7.0
or
Add this dependency
I am trying to incorporate Facebook SDK , but Android Studio is giving me errors at compile time.
Here is my 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.8.0_51\bin\java.exe'' finished with non-zero exit value 2
Gradle
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile files('libs/gcm.jar')
compile files('libs/httpmime-4.1.1.jar')
compile files('libs/junit-4.10.jar')
compile files('libs/ksoap2-android-assembly-2.4-jar-with-dependencies.jar')
compile files('libs/signpost-commonshttp4-1.2.1.1.jar')
compile files('libs/signpost-core-1.2.1.1.jar')
compile files('libs/signpost-jetty6-1.2.1.1.jar')
compile files('libs/twitter4j-core-3.0.5.jar')
compile project(':stripe')
compile project(':FacebookSDK')
compile 'com.google.android.gms:play-services:8.4.0'
compile 'com.google.android.gms:play-services-maps:8.4.0'
compile 'com.google.android.gms:play-services-gcm:8.4.0'
compile 'com.intuit.sdp:sdp-android:1.0.3'
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:design:23.0.1'
compile 'com.specyci:residemenu:1.6+'
compile 'com.android.support:multidex:1.0.0'
}
But this doesn't work, and honestly isn't a good solution. When I remove facebook sdk, my app compiles no problem, but with it nothing works. What am I missing here?
You are over 64K methods in your build because of using so many libraries, enable multiDex, clear unused libraries, remove unused methods with ProGuard or whatever you want, but you have reached the method count limit for a single APK.
I have been trying to integrate admob into my project when suddenly this error appears
Error:Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'.
> com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK jsr305_annotations/Jsr305_annotations.gwt.xml
File1: C:\Users\SkyPunch\AndroidStudioProjects\GyanBox\app\build\intermediates\exploded-aar\com.longtailvideo.jwplayer\jwplayer-android-sdk\2.4.1+158\jars\classes.jar
File2: C:\Users\SkyPunch\AndroidStudioProjects\GyanBox\app\build\intermediates\exploded-aar\com.google.android.gms\play-services-basement\9.4.0\jars\classes.jar
I think its an issue with same classes in two liberaries
I have used these
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.android.support:support-v4:23.3.0'
compile 'com.github.amlcurran.showcaseview:library:5.4.0'
compile 'com.github.castorflex.verticalviewpager:library:19.0.1'
compile 'com.github.curioustechizen.android-ago:library:1.3.0'
compile 'com.nononsenseapps:filepicker:2.4.2'
compile 'com.rockerhieu.emojicon:library:1.3.3'
compile 'de.hdodenhof:circleimageview:2.0.0'
compile 'org.apmem.tools:layouts:1.10#aar'
compile 'com.android.support:cardview-v7:23.3.0'
compile 'com.android.support:recyclerview-v7:23.3.0'
compile 'com.squareup.picasso:picasso:2.4.0'
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
compile 'com.google.code.gson:gson:2.3.1'
compile 'com.neovisionaries:nv-websocket-client:1.23'
compile 'com.theartofdev.edmodo:android-image-cropper:1.2.6'
compile 'com.longtailvideo.jwplayer:jwplayer-android-sdk:+'
compile 'com.android.support:percent:23.3.0'
compile 'com.google.firebase:firebase-core:9.4.0'
compile 'com.google.firebase:firebase-ads:9.4.0'
How can i resolve this without removing any of the libraries
Edit: i found that by following it can be resolved
packagingOptions {
exclude 'jsr305_annotations/Jsr305_annotations.gwt.xml'
}
Will this have any impact on app. Am i excluding an important file?
I am getting below error log:
Error:Execution failed for task
'app:transformClassesWithJarMergingForDebug'.>
com.android.build.api.transform.TransformException:
java.util.zip.ZipException: duplicate entry:
android/support/annotation/Keep.class
Here is the list of build.gradle dependencies:
dependencies {
compile project(':chartboostSDK')
compile project(':flurry_lib')
compile project(':googleCloudMessaging_lib')
compile project(':mainLibProj')
compile project(':localytics_lib')
compile project(':mobihelp_sdk_android_v1534')
compile project(':unityandroidresources')
compile project(':iAB_lib')
compile project(':etcetera_lib')
compile 'com.google.code.gson:gson:2.3.1'
compile 'com.google.android.gms:play-services:+'
compile files('libs/FlurryPlugin.jar')
compile files('libs/FreshdeskPlugin.jar')
compile files('libs/Prime31UnityActivity.jar')
compile files('libs/adcolony-adapter-1.1.6.jar')
compile files('libs/android-bridge.jar')
compile files('libs/apsalar.jar')
compile files('libs/apsalarUnity3d.jar')
compile files('libs/bolts-android-1.2.1.jar')
compile files('libs/chartboost-adapter-1.0.6.jar')
compile files('libs/crittercism_v5_4_3_sdkonly.jar')
compile files('libs/dagger.jar')
compile files('libs/emojiplugin.jar')
compile files('libs/in-app-purchasing-2.0.61.jar')
compile files('libs/javax.inject.jar')
compile files('libs/mediationsdk-6.3.5.jar')
compile files('libs/nativex-adapter-1.0.3.jar')
compile files('libs/nineoldandroids.jar')
compile files('libs/support-annotations-23.1.1.jar')
compile files('libs/tapjoyconnectlibrary.jar')
compile files('libs/tapjoyunitywrapper.jar')
compile files('libs/unity-classes.jar')
compile files('libs/vungle-adapter-1.1.6.jar')
compile files('libs/unity-classes.jar')
}
Try to import the library as a gradle dependency like this:
compile 'com.android.support:support-annotations:23.1.1'
If you want to use jar then it seems like that it hasn't been properly built. So try to do something like this:
Unzip the jar file. (Simply change .jar extension to .zip
This will remove the duplicate files.
Recreate the jar using jar cf xmlbeans.jar -C (path to unzipped folder) . (Mind it, there is a dot in the end of command)
Use this regenerated jar
im a begginer in android studio and im trying to perform a database sync with mysql and a android database. after following a guide (it makes no mention to gradle stuff however so im having to improvise) im left with the bellow error
After searching i was told its probably my dependencies but i haven't had much look so far
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile files('libs/gson-2.2.2.jar')
compile files('libs/android-support-v4.jar')
compile files('libs/android-async-http-1.4.4.jar')
}
my library in the .idea folder look like this
libraries
android_async_http_1_4_4.xml
android_support_v4.xml
appcompat_v7_21_0_3.xml
gson_2_2_2.xml
support_annotations_21_0_3.xml
support_v4_21_0_3.xml
this is the error i got
Error:Execution failed for task ':app:dexDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
/Applications/Android Developer Tools/sdk/build-tools/21.1.2/dx --dex --no-optimize --output /Volumes/Untitled/You copy/app/build/intermediates/dex/debug --input-list=/Volumes/Untitled/You copy/app/build/intermediates/tmp/dex/debug/inputList.txt
Error Code:
2
Output:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompatIcs;
at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)
at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)
at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:303)
at com.android.dx.command.dexer.Main.run(Main.java:246)
at com.android.dx.command.dexer.Main.main(Main.java:215)
at com.android.dx.command.Main.main(Main.java:106)
thank you for any help you can offer me
Gradle knows how to resolve dependency conflicts. You can read about that here : https://gradle.org/docs/current/userguide/dependency_management.html .
So the error is not because appcompat clashes with support-v4.
It looks like you're referencing twice, libraries from your libs folder.
Either use:
dependencies {
compile 'com.android.support:appcompat-v7:21.0.3'
compile files('libs/gson-2.2.2.jar')
compile files('libs/android-support-v4.jar')
compile files('libs/android-async-http-1.4.4.jar') }
or:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
}
However, my recommendation is to also reference support-v4, gson and android-async as you reference appcompat-v7.
Problem:
With Gradle dependencies, AppCompatv7 also brings in Supportv4. So, simply remove Supportv4 .jar because you are accidentally adding it twice.
Your dependencies:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile files('libs/gson-2.2.2.jar')
compile files('libs/android-support-v4.jar') // <-- remove jar
compile files('libs/android-async-http-1.4.4.jar')
}
Should be:
I also upgraded your .jars into Gradle dependencies.
dependencies {
compile 'com.android.support:appcompat-v7:22.0.0' // <-- upgraded
compile 'com.google.code.gson:gson:2.3.1' // <-- upgraded to gradle dependency
compile 'com.loopj.android:android-async-http:1.4.4' // <-- upgraded to gradle dependency
}