问题描述
我面临的一个问题,同时增加了线路谷歌日历的API build.gradle
。以下是错误:
I face a problem while adding a line for Google Calendar API to build.gradle
. Here is the 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
'/usr/java/jdk1.7.0_79/bin/java''
finished with non-zero exit value 2
Information:BUILD FAILED
Information:Total time: 14.802 secs
Information:1 error
Information:2 warnings
Information:See complete output in console
我已经尝试了许多的选择,但没有什么工作。当我添加multiDex真正的
到 defaultConfig
,appcompat库没有连接到我的项目,并与应用程序崩溃 java.lang.NoClassDefFoundError的:android.support.v7.appcompat.R $布局
I have tried many options but nothing is working. When I add "multiDex true"
to defaultConfig
, appcompat library doesn't connect to my project, and application crashes with java.lang.NoClassDefFoundError: android.support.v7.appcompat.R$layout.
下面是我的 build.gradle
:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "ua.appp.appp"
minSdkVersion 14
targetSdkVersion 21
versionCode 15
versionName "2.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:22.0.0'
compile 'com.google.android.gms:play-services:6.5.87'
compile 'com.google.apis:google-api-services-calendar:v3-rev119-1.19.1'
compile 'com.google.api-client:google-api-client:1.19.1'
compile 'com.google.api-client:google-api-client-android:1.19.1'
compile 'com.google.api-client:google-api-client-gson:1.19.1'
compile 'com.github.navasmdc:MaterialDesign:1.+@aar'
compile 'com.afollestad:material-dialogs:0.6.5.2'
compile 'com.nhaarman.listviewanimations:lib-core:3.1.0@aar'
compile 'com.nhaarman.listviewanimations:lib-manipulation:3.1.0@aar'
compile 'com.nhaarman.listviewanimations:lib-core-slh:3.1.0@aar'
}
PS:一些有趣的事实:当我加入所有这些库测试项目,code编译和工作正常,没有一个错误
PS: Some interesting fact: When I add all these libraries to a test project, code compiles and works fine without an error.
推荐答案
当您添加 multidex:真正的
不要忘了做一个应用
类项目,从扩展 MultiDexApplication
还是有很多坏的东西会发生
When you add the multidex:true
don't forget to make an Application
class in your project that extends from the MultiDexApplication
or a lot of bad stuff will happen
public class YourApplication extends MultiDexApplication {
..........
}
和别忘了这是(该版本可能会随时间而改变,当你读到这,请确保您使用最新版本)
And don't forget this either (the version may change over time, if you read this, make sure you use the latest version)
dependencies {
'com.android.support:multidex:1.0.1'
}
这篇关于MultiDex问题 - 执行失败的任务“:应用程序:dexDebug”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!