I am using two libraries in my project. One is this and the other is this.
Whenever I run the App with Edit Test library it shows UNEXPECTED TOP-LEVEL EXCEPTION:
Error:Execution failed for task ':mobile:dexDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
E:\Android\me\me\sdk\build-tools\21.1.2\dx.bat --dex --no-optimize --output C:\Project\RemoteiT\RemoteiT\mobile\build\intermediates\dex\debug --input-list=C:\Project\RemoteiT\RemoteiT\mobile\build\intermediates\tmp\dex\debug\inputList.txt
Error Code:
2
Output:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Lcom/nineoldandroids/animation/Animator$AnimatorListener;
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)
I Assume that the above error shows that com.nineoldandroids is added twice or conflicting.
So I tried to remove it in the build.gradle file. But it is still showing the error!
Is my Assumption is right? Or elsewhere did I go wrong?
Build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "me.aruhan.remt"
minSdkVersion 14
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
configurations {
// to avoid double inclusion of support libraries
all*.exclude group: 'com.nineoldandroids', module: 'materialDesign'
}
dependencies {
compile 'com.android.support:appcompat-v7:21.0.0'
compile project(':materialDesign')
compile 'com.rengwuxian.materialedittext:library:1.7.1'
}
Instead of adding it in the Configurations. I added the exclude for only the library like this:
compile ('com.rengwuxian.materialedittext:library:1.7.1') {
exclude group: 'com.nineoldandroids', module: 'library'
}
Go to File > project structure > Inside module select your > click on Dependencies on right hand side and see there are duplicate libraries are present or not?
Also try invalidate/Restart cache
If the error occurring due to duplication of libraries you can use packagingOptions in build.gradle file.
android {
....
packagingOptions {
exclude '.....'
pickFirst '.....'
}
}
Related
Hi i previously using renderscriptSupportModeEnabled true whiteout any problem but today when i want to run my app i giving this error message
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Landroid/support/annotation/AnimRes;
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: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
i even create new empty sample project with no dependency but same error message here is my .gradle file
android {
compileSdkVersion 22
buildToolsVersion "23.0.0 rc3"
defaultConfig {
applicationId "com.mk.sample"
minSdkVersion 10
targetSdkVersion 22
versionCode 1
versionName "1.0"
renderscriptTargetApi 19
renderscriptSupportModeEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.1'
}
I can't say I understand this solution - or that it's necessarily a good fix, but it got my app compiling again:
configurations.all {
exclude group: 'com.android.support', module: 'support-annotations'
}
Also, see: Getting Multiple dex error when using render script support lib
and Using buildToolsVersion 23 fails because Multiple dex files define 'AnimRes'
Credit to Luboš Staráček for this solution
I am new on Android Studio. I am facing below mentioned error while building the project.
:app:shrinkDebugMultiDexComponents FAILED
Error:Execution failed for task ':app:shrinkDebugMultiDexComponents'.
> java.io.IOException: Can't read [D:\StudioWorkspace\SampleSDKDemoProject\app\build\intermediates\multi-dex\debug\allclasses.jar] (Can't process class [org/fmod/FMODAudioDevice.class] (256))
Here is my build.gradle file inside app folder.
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion '21.1.2'
defaultConfig {
applicationId "com.test.offerwall"
minSdkVersion 9
targetSdkVersion 21
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile 'com.bee7.gamewall.aar:bee7#aar'
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.android.gms:play-services-base:6.5.87'
compile 'com.test.android.ads.aar:myapp#aar'
compile 'com.google.android.gms:play-services:7.5.0'
}
repositories {
flatDir {
dirs 'libs'
}
}
I have updated the android sdk also but no luck. Could you guys help me out that why I am facing this issue.
Kindly help me out with the solution.
Thanks in advance.
As commented: I have tried using removing the multiDexEnabled true
Then I got this error.
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536
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: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)
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_45\bin\java.exe'' finished with non-zero exit value 2
For the first error remove multiDexEnabled true.
UNEXPECTED TOP-LEVEL EXCEPTION:
for this one remove one of your com.google.android.gms:play-services libraries it is included more than once.
or add this in your build.gradle at the root level:
configurations {
all*.exclude group: 'com.google.android.gms', module: 'play-services'
}
hope this will help.
i need to do more graph in my app and i thought to import that library ( http://www.android-graphview.org/ ).
I just follow the rules and i add to the gradle the compile row.
That is :
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.1"
defaultConfig {
applicationId "com.btc.btcmobile"
minSdkVersion 17
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.jjoe64:graphview:4.0.0'
}
after that, i copy-paste the example on the site, but when i compile now i can see that error:
Error:Execution failed for task ':app:dexDebug'.
com.android.ide.common.internal.LoggedErrorException: Failed to run command:
C:\Users\valerio\AppData\Local\Android\sdk2\build-tools\21.1.1\dx.bat --dex --no-optimize --output C:\Users\valerio\Desktop\BtcMobile\btcmobile\app\build\intermediates\dex\debug --input-list=C:\Users\valerio\Desktop\BtcMobile\btcmobile\app\build\intermediates\tmp\dex\debug\inputList.txt
Error Code:
2
Output:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Lcom/jjoe64/graphview/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:302)
at com.android.dx.command.dexer.Main.run(Main.java:245)
at com.android.dx.command.dexer.Main.main(Main.java:214)
at com.android.dx.command.Main.main(Main.java:106)
UNEXPECTED TOP-LEVEL EXCEPTION:
How i can resolve?
Thanks.
In my case I had the GraphView4.1.jar inside the libs folder. I also had compile 'com.jjoe64:graphview:4.0.1' in the build.gradle. As soon as I removed the jar file from libs folder, the com.android.dex.DexException error was resolved.
In the project, there are 3 modules, A,B,C.
A is having dependency of B and B is having dependency of C.
Error Output:
Error:Execution failed for task ':app:dexDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
C:\Users\user\AppData\Local\Android\sdk\build-tools\21.1.2\dx.bat --dex --no-optimize --output C:\Testing\MyApplication\app\build\intermediates\dex\debug --input-list=C:\Testing\MyApplication\a\build\intermediates\tmp\dex\debug\inputList.txt
Error Code:
2
Output:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Lcom/test/test2/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)
MainProject[settings.gradle]:
include ':A', ':B', ':C'
MainProject[build.gradle] :
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
A.gradle :
apply plugin: 'com.android.application'
dependencies {
compile 'com.google.android.gms:play-services:6.5.87'
compile 'com.android.support:support-v4:21.0.3'
compile 'com.android.support:appcompat-v7:21.0.3'
compile project(':B')
}
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
/*defaultConfig {
minSdkVersion 9
targetSdkVersion 21
}*/
lintOptions {
abortOnError false
}
}
B.gradle :
apply plugin: 'com.android.library'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
minSdkVersion 15
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile('de.keyboardsurfer.android.widget:crouton:1.8.5') {
exclude group: 'com.android.support', module: 'support-v4'
}
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'de.greenrobot:eventbus:2.2.1'
compile 'com.mobsandgeeks:android-saripaar:1.0.3'
compile 'com.loopj.android:android-async-http:1.4.6'
compile project(':C')
compile 'com.android.support:appcompat-v7:21.0.3'
}
C.gradle :
apply plugin: 'com.android.library'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
minSdkVersion 15
targetSdkVersion 21
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile files('libs/classes.jar')
}
If I am removing the duplication of appcpmpat-v7 in A and module B then I am getting the errors.
Module C contains the compiled .class files.
I am unable to understand the duplication of build.config files. What can be the solution of this problem?
The support library is included several times (maybe because declared as dependency by several of the libraries you're using), look for that in your build script.
resolution remove appcompat library from Gradle A.
Dependency resolution
When a project references two Library projects that both require the same jar file, the build system has to detect and resolve the duplication.
A full dependency system would associate each jar file with a fully qualified name and a version number to figure out which version to use.
Unfortunately the Android build system does not have a full dependency resolution system (yet). In the meantime we have implemented a very basic system that follows these rules:
Jar file are identified strictly by their file names.
This means mylib.jar is different than mylib-v2.jar and both will be packaged, possibly resulting in “already added” dx error if they are actually the same library in a different revision.
For jars with the same file name, “same version” means same exact file.
Currently our detection is very basic, checking only that the files are identical in size and sha1.
If two libraries each include in their libs folder a file called mylib.jar but these two files are different, then the build system will fail indicating a dependency error.
check Android Dex: UNEXPECTED TOP-LEVEL EXCEPTION for more info.
I have two libraries on my proyect.
https://github.com/rengwuxian/MaterialEditText
https://github.com/navasmdc/MaterialDesignLibrary
It compiles, but when I run the program it reports an error.
UNEXPECTED TOP-LEVEL EXCEPTION:
Error:Execution failed for task ':app:dexDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
C:\Users\Alvaro\AppData\Local\Android\sdk\build-tools\21.1.2\dx.bat --dex --no-optimize --output D:\ALVARO\AndroidStudioProjects\Proyecto\app\build\intermediates\dex\debug --input-list=D:\Alva\AndroidStudioProjects\Proyecto\app\build\intermediates\tmp\dex\debug\inputList.txt
Error Code:
2
Output:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Lcom/nineoldandroids/animation/Animator$AnimatorListener;
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)
I KNOW THE PROBLEM, BUT I CAN'T SOLVE
Problem
Multiple dependencies are trying to import nineoldandroids exactly "nineoldandroids"
app build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.example.alva.proyecto"
minSdkVersion 14
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt')
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:21.0.3'
//seconds library
compile project(':materialDesign')
//first library
compile project(':EditText')
}
first library build.gradle
apply plugin: 'com.android.library'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
minSdkVersion 14
targetSdkVersion 21
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile 'com.android.support:support-annotations:21.0.3'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.android.support:appcompat-v7:21.0.3'
}
seconds library build.gradle
apply plugin: 'com.android.library'
android {
compileSdkVersion 8
buildToolsVersion "19.1.0"
defaultConfig {
minSdkVersion 8
targetSdkVersion 8
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:18.+'
compile files('libs/nineoldandroids-2.4.0.jar')
}
I have tried:
1. Put on "app" build.gradle:
compile project(':EditText') {
exclude group: 'com.nineoldandroids', module: 'library:2.4.0'
}
NOT WORKS, IT'S REPORTS AN ERROR
Error:(31, 0) Gradle DSL method not found: 'exclude()'
Possible causes:<ul><li>The project 'Proyecto' may be using a version of Gradle that does not contain the method.
Gradle settings</li><li>The build file may be missing a Gradle plugin.
Apply Gradle plugin</li>
2. Remove "nineoldandroids" from seconds library, NOT WORKS
Any suggestions?
I don't know how to import using their respective artifacts
It is in the documentation for each library.
The MaterialEditText "Download" section cites:
compile 'com.rengwuxian.materialedittext:library:1.8.2'
The "How to Use" section of MaterialDesignLibrary cites:
repositories {
jcenter()
}
dependencies {
compile 'com.github.navasmdc:MaterialDesign:1.+#aar'
}
Then, Gradle will (hopefully) be able to detect that both of these dependencies themselves depend upon nineoldandroids and resolve the conflict. I say "hopefully" because whichever library the "seconds library build.gradle" comes from uses a local copy of nineoldandroids, which is not a good idea. Neither GitHub repo seems to have that particular build.gradle file, though, so you may be OK.