【发布时间】:2016-09-09 00:05:40
【问题描述】:
升级到 Android 设计工具 24 后,我的项目将不再运行。它构建良好,没有任何错误,但是当我运行它时出现错误:
错误:Gradle:任务 ':app:transformClassesWithDexForDebug' 执行失败。
com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1 .8.0_102\bin\java.exe'' 以非零退出值 1 结束
这是我的 build.gradle 文件:
apply plugin: 'com.android.application'
apply plugin: 'realm-android'
android {
compileSdkVersion 24
buildToolsVersion "24.0.2"
defaultConfig {
applicationId "com.example.don.mstp"
minSdkVersion 15
targetSdkVersion 24
versionCode 1
versionName "1.0"
// Enabling multidex support.
multiDexEnabled true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dexOptions {
incremental true
javaMaxHeapSize "4g"
preDexLibraries = false
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.2.0'
compile 'com.github.Lukle:ClickableAreasImages:v0.1'
compile 'com.android.support:design:24.2.0'
compile 'com.android.support:support-v4:24.2.0'
compile 'com.android.support:cardview-v7:24.2.0'
compile 'com.android.support:recyclerview-v7:24.2.0'
compile 'com.github.javiersantos:MaterialstyledDialogs:1.3'
compile 'com.github.PhilJay:MPAndroidChart:v2.1.6'
compile 'com.ramotion.foldingcell:folding-cell:1.0.1'
compile 'com.github.brnunes:swipeablerecyclerview:1.0.2'
compile 'com.github.gabrielemariotti.recyclerview:recyclerview-animators:0.3.0-SNAPSHOT@aar'
compile 'com.tiancaicc.springfloatingactionmenu:library:0.0.2'
compile 'com.daimajia.numberprogressbar:library:1.2@aar'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.android.support:multidex:1.0.1'
compile 'com.daprlabs.aaron:cardstack:0.3.0'
compile 'com.txusballesteros:FitChart:1.0'
compile 'com.github.SilenceDut:ExpandableLayout:v1.0.1'
}
【问题讨论】:
-
你真的需要 multidex "compile 'com.android.support:multidex:1.0.1'" 我非常怀疑它,但你应该看到你拉入你的应用程序的依赖项,很可能 gradle 失败因为您有大量依赖项,其中很可能包括其他依赖项,我相信您有重复项。在 Android Studio 中运行
./gradlew app:dependencies从终端检查 -
根据android文档:developer.android.com/studio/build/multidex.html,我需要添加“编译'com.android.support:multidex:1.0.0',更进一步并添加最新的。我是使用 Intellij,似乎没有“gradle 控制台”。我使用了很多依赖项,我的猜测是我可能已经超过 65K 方法。感谢您的及时回答。
-
仅在构建调试时或在构建发布时是否收到错误?另外,为什么你关闭了proguard
minifyEnabled false,应该为发布和调试启用。 -
我无法具体说明您的问题,但我想告诉您不要使用 Google 的支持库 x.x.0。它几乎总是会破坏构建、导致崩溃或给出不稳定的结果。我们总是从 x.x.1 版本开始申请。这就是我们从历史中学到的。
标签: java android intellij-idea android-gradle-plugin build.gradle