Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MultiDex support in Android application error

I want to use Android L compat libs. after adding the relevant code to gradle, I get the error:

  Error Code:
2
  Output:
objc[36290]: Class JavaLaunchHelper is implemented in both /Library/Java/JavaVirtualMachines/jdk1.7.0_67.jdk/Contents/Home/bin/java and /Library/Java/JavaVirtualMachines/jdk1.7.0_67.jdk/Contents/Home/jre/lib/libinstrument.dylib. One of the two will be used. Which one is undefined.
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.IllegalArgumentException: method ID not in [0, 0xffff]: 65536
  at com.android.dx.merge.DexMerger$6.updateIndex(DexMerger.java:501)
  at com.android.dx.merge.DexMerger$IdMerger.mergeSorted(DexMerger.java:276)
  at com.android.dx.merge.DexMerger.mergeMethodIds(DexMerger.java:490)
  at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:167)
  at com.android.dx.merge.DexMerger.merge(DexMerger.java:188)
  at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:439)
  at com.android.dx.command.dexer.Main.runMonoDex(Main.java:287)
  at com.android.dx.command.dexer.Main.run(Main.java:230)
  at com.android.dx.command.dexer.Main.main(Main.java:199)
  at com.android.dx.command.Main.main(Main.java:103)

I saw questions about it this here and here, and tried out the solution from this blog post, and I still get an error, where in the case of the blog post, I get:

  Error Code:
2  Output:
objc[36323]: Class JavaLaunchHelper is implemented in both /Library/Java/JavaVirtualMachines/jdk1.7.0_67.jdk/Contents/Home/bin/java and /Library/Java/JavaVirtualMachines/jdk1.7.0_67.jdk/Contents/Home/jre/lib/libinstrument.dylib. One of the two will be used. Which one is undefined.
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Library dex files are not supported in multi-dex mode
    at com.android.dx.command.dexer.Main.runMultiDex(Main.java:322)
    at com.android.dx.command.dexer.Main.run(Main.java:228)
    at com.android.dx.command.dexer.Main.main(Main.java:199)
    at com.android.dx.command.Main.main(Main.java:103)

These are my android gradle settings:

android {
compileSdkVersion 21
buildToolsVersion "20.0.0"

defaultConfig {
    applicationId "com.my.package"
    minSdkVersion 9
    targetSdkVersion 21
}

buildTypes {
    release {
        runProguard false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt'
    }
}

}

These are my dependencies:

dependencies {
compile project(':libraries:ecoGallery')
compile project(':libraries:facebookSDK')
compile 'com.android.support:support-v4:21.0.0'
compile 'com.android.support:appcompat-v7:21.0.0'
compile 'com.google.android.gms:play-services:6.1.71'
compile 'com.j256.ormlite:ormlite-android:4.48'
compile 'com.j256.ormlite:ormlite-core:4.48'
compile 'com.mixpanel.android:mixpanel-android:4.3.1@aar'
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.3'
compile 'com.nineoldandroids:library:2.4.0'
compile 'oauth.signpost:signpost-commonshttp4:1.2.1.2'
compile 'oauth.signpost:signpost-core:1.2.1.2'
compile 'com.uservoice:uservoice-android-sdk:+@aar'
compile 'com.newrelic.agent.android:android-agent:4.87.0'
compile 'com.google.guava:guava:18.0'
compile files('libs/android-support-multidex.jar')

}

Does anyone have any ideas for what I might be doing wrong?

like image 682
dors Avatar asked Oct 29 '14 14:10

dors


1 Answers

Gradle plugin v0.14.0 for Android adds full multidex support.
Remove all the build.gradle changes you made (for multidex), and simply add the following:

android {
   defaultConfig {
      ...
      multiDexEnabled = true
   }
}
like image 78
Alex Lipov Avatar answered Oct 07 '22 04:10

Alex Lipov