当我尝试将Facebook添加为库或gradle时出现错误
//compile 'com.facebook.android:facebook-android-sdk:4.7.0'这是我的android studio项目结构,我的主应用程序文件夹gradle有以下库。
compile fileTree(include: ['*.jar'], dir: 'libs')
compile project(':twitter-core-release')
compile project(':tweet-ui-release')
compile project(':twitter-release')
compile project(':tweet-composer-release')
//compile 'com.facebook.android:facebook-android-sdk:4.7.0'
compile project(':facebook_sk')
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:design:23.0.1'
compile 'com.squareup.retrofit:retrofit:2.0.0-beta1'
compile 'com.squareup.retrofit:converter-jackson:2.0.0-beta1'
compile 'com.squareup.retrofit:adapter-rxjava:2.0.0-beta1'
compile 'com.twotoasters.jazzylistview:library:1.2.1'
compile 'com.twotoasters.jazzylistview:library-recyclerview:1.2.1'
compile 'com.pnikosis:materialish-progress:1.7'
compile 'com.google.android.gms:play-services-gcm:8.1.0'
compile 'com.android.support:recyclerview-v7:23.0.1'
compile 'io.realm:realm-android:0.82.2'
compile 'com.google.android.gms:play-services-analytics:8.1.0'
compile 'jp.wasabeef:recyclerview-animators:1.3.0'
compile 'com.google.code.gson:gson:2.3'
compile 'io.fabric.sdk.android:fabric:1.3.+@aar'
compile 'com.digits.sdk.android:digits:1.7.+@aar'在我的应用程序库中,它有universal-image-loader-1.9.4.jar
在facebook_sk中,它有以下内容
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
//compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:support-v4:23.0.1'
}在facebook库中,它有bolts-android-1.1.2.jar
如果我删除了facebook skd并构建了我的项目,那么它在studio中运行得很好,但当我无法使用facebook sdk时,它会给我以下错误:
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.build.transform.api.TransformException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home/bin/java'' finished with non-zero exit value 2我需要使用multidex吗?
发布于 2015-10-13 16:02:06
现在,我通过添加multidex解决了这个问题
defaultConfig {
applicationId "com.xxxxx"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
// Enabling multidex support.
multiDexEnabled true
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile project(':twitter-core-release')
compile project(':tweet-ui-release')
compile project(':twitter-release')
compile project(':tweet-composer-release')
//compile 'com.facebook.android:facebook-android-sdk:4.7.0'
compile project(':facebook_sk')
compile 'com.squareup.retrofit:retrofit:2.0.0-beta1'
compile 'com.squareup.retrofit:converter-jackson:2.0.0-beta1'
compile 'com.squareup.retrofit:adapter-rxjava:2.0.0-beta1'
compile 'com.twotoasters.jazzylistview:library:1.2.1'
compile 'com.twotoasters.jazzylistview:library-recyclerview:1.2.1'
compile 'com.pnikosis:materialish-progress:1.7'
compile 'com.google.android.gms:play-services-gcm:8.1.0'
compile 'com.google.android.gms:play-services-analytics:8.1.0'
compile 'io.realm:realm-android:0.82.2'
compile 'jp.wasabeef:recyclerview-animators:1.3.0'
compile 'com.google.code.gson:gson:2.3'
compile 'io.fabric.sdk.android:fabric:1.3.+@aar'
compile 'com.digits.sdk.android:digits:1.7.+@aar'
compile 'com.android.support:multidex:1.0.1'
}对于Facebook sdk:
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
//compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:support-v4:23.0.1'
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:design:23.0.1'
compile 'com.android.support:recyclerview-v7:23.0.1'
}发布于 2015-10-13 14:32:55
当我有不同版本的重复依赖项时,我得到相同的错误。
尝试此命令并检查是否存在以下内容两次:
gradle dependencies发布于 2016-06-07 01:12:37
我必须启用multiDex并将javaMaxHeapSize指定为"4g“,否则会出现内存不足错误。
需要在应用程序中构建gradle文件,在安卓内部,defaultConfig已经在那里,只需添加multiDexEnabled true在那里,dexOptions是新的。
defaultConfig {
multiDexEnabled true
}
dexOptions {
javaMaxHeapSize "4g"
}https://stackoverflow.com/questions/33095536
复制相似问题