我的项目工作正常,直到我添加了Facebook依赖项.
我开始收到此错误.
我读了很多问题,问题似乎与MultiDex有关.
但是没有一个解决方案适合我
Error:Execution Failed for task ':app:transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException:
com.android.ide.common.process.ProcessException:
org.gradle.process.internal.ExecException: Process 'command
'/usr/lib/jvm/java-7-openjdk-amd64/bin/java'' finished with non-zero exit value 1
即使在我删除了我添加的内容之后,它仍然会显示并且gradle似乎在构建时比平常花费了大量时间
这是我的build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsversion "23.0.3"
defaultConfig {
applicationId "net.ciblo.spectrodraft"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile filetree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
repositories {
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
}
compile 'com.facebook.android:facebook-android-sdk:[4,5)'
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support:appcompat-v7:23.2.1'
compile 'com.android.support:cardview-v7:23.2.1'
compile 'com.android.support:design:23.2.1'
compile 'com.daimajia.easing:library:1.0.1@aar'
compile 'com.daimajia.androidanimations:library:1.1.3@aar'
compile 'com.google.android.gms:play-services:8.4.0'
compile 'com.mcxiaoke.volley:library-aar:1.0.0'
compile 'com.pnikosis:materialish-progress:1.5'
compile 'com.nineoldandroids:library:2.4.+'
compile 'com.michaelpardo:activeandroid:3.1.0-SNAPSHOT'
compile 'com.android.support:support-v4:23.2.1'
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
}
解决方法:
将以下代码添加到build.gradle应用程序模块解决了我的问题
android{
defaultConfig {
// Enabling multidex support.
multiDexEnabled true
}
dexOptions {
javaMaxHeapSize "4g"
}
}
dependencies {
//...
compile 'com.android.support:multidex:1.0.0'
}