Android应用程序中的MultiDex支持错误

Android应用程序中的MultiDex支持错误

本文介绍了Android应用程序中的MultiDex支持错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用Android L compat库.在将相关代码添加到gradle之后,我得到了错误:

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)

这些是我的Android gradle设置:

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'
    }
}

}

这些是我的依赖项:

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?

推荐答案

适用于Android的Gradle插件v0.14.0添加了全面的multidex支持.
删除所有对multidex所做的build.gradle更改,只需添加以下内容:

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
   }
}

这篇关于Android应用程序中的MultiDex支持错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-23 04:57