我的错误信息是:
//Error Code:
2
Output:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Lcom/google/common/annotations/Beta;
at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:594)
at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:552)
at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:533)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:170)
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)//
请帮我解决这个问题 我的build.gradle
//dependencies {
compile project(':appRater')
compile project(':circularImageView')
compile project(':facebookSDK')
compile project(':paperSlidingTab')
compile project(':library')
compile project(':urlImageViewHelper')
compile project(':pullToRefreshLi')
compile project(':libraries:SlidingMenu:library')
compile files('libs/GoogleAdMobAdsSdk-6.4.1.jar')
compile files('libs/httpmime-4.2.5.jar')
compile files('libs/json-org.jar')
compile files('libs/universal-image-loader-1.9.1-with-sources.jar')
compile files('libs/WebSocket.jar')
compile files('libs/gcm.jar')
compile files('libs/applause-sdk-library-2.0.0.jar')
compile 'org.droidparts:droidparts:1.+'
compile 'joda-time:joda-time:2.3'
compile 'com.google.api-client:google-api-client:1.+'
compile 'com.google.api-client:google-api-client-android2:1.+'
compile 'com.google.http-client:google-http-client:1.+'
compile 'com.google.http-client:google-http-client-android2:1.+'
compile 'com.google.oauth-client:google-oauth-client:1.+'
compile 'com.google.code.gson:gson:2.+'
compile 'com.google.guava:guava:11.+'
compile 'com.google.http-client:google-http-client-jackson2:1.+'
compile 'com.google.protobuf:protobuf-java:2.+'
compile 'com.google.android.gms:play-services:3.+'
}
android {
compileSdkVersion 19
buildToolsVersion "19.1.0"
defaultConfig {
minSdkVersion 9
targetSdkVersion 17
}
signingConfigs {
release {
if (System.getenv("GRADLE_KEYSTORE")) {
storeFile = file(System.getenv("GRADLE_KEYSTORE"))
storePassword = System.getenv("GRADLE_KEYSTORE_PASSWORD")
keyAlias = System.getenv("GRADLE_KEY_ALIAS")
keyPassword = System.getenv("GRADLE_KEY_PASSWORD")
}
}
}
buildTypes.debug {
ext.enableCrashlytics = false
}
buildTypes.release {
debuggable false
zipAlignEnabled true
minifyEnabled false
signingConfig signingConfigs.release
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/notice.txt'
exclude 'META-INF/ASL2.0'
}
lintOptions {
checkReleaseBuilds false
// Or, if you prefer, you can continue to check for errors in release builds,
// but continue the build even when errors are found:
abortOnError false
}
}
答案 0 :(得分:1)
当我们在一个项目中使用具有2个或更多版本的相同库时,会出现这种情况。因此,请尝试在您的应用中找到库的版本,尤其是support-v4库
android {
compileSdkVersion 19
buildToolsVersion "19.1.0"
defaultConfig {
...
minSdkVersion 14
targetSdkVersion 19
...
// Enabling multidex support.
multiDexEnabled true
}
...
}
dependencies {
compile 'com.android.support:multidex:1.0.0'
}
你也可以使用下面的代码,这个在我的案例中工作
dexOptions {
incremental true
javaMaxHeapSize "4g"
}
答案 1 :(得分:0)
defaultConfig {
minSdkVersion 14 //lower than 14 doesn't support multidex
targetSdkVersion 22
// Enabling multidex support.
multiDexEnabled true
}
或者您可以通过制作应用程序类
来完成public class MyApplication extends MultiDexApplication { .. }
或
override
attachBaseContext method and call MultiDex.install().
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
否则(如果您的应用程序没有自定义应用程序实现),请在您的AndroidManifest.xml中将MultiDexApplication声明为应用程序实现。
<application
android:name="android.support.multidex.MultiDexApplication"
.. >
..
</application>