整合Facebook sdk的Android错误

时间:2015-10-29 16:46:34

标签: android facebook android-gradle android-facebook

我在应用程序中添加sdk facebook时遇到问题: 但如果我添加一个新项目,如果它有效。

消息Gradle Build:

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.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   
'D:\MisProgramas\Java\jdk1.7.0_79\bin\java.exe'' finished with non-zero exit     
value 2
at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)

我的build.gradle(模块:app)

apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "21.1.2"

defaultConfig {
    applicationId "dev.glg.com.rby"
    minSdkVersion 15
    targetSdkVersion 22
    versionCode 10
    versionName "1.0.2-beta"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}

 }
    repositories {

     maven { url "https://jitpack.io" }
     mavenCentral()
}

dependencies {
 compile fileTree(dir: 'libs', include: ['*.jar'])
 compile 'com.google.android.gms:play-services:7.8.0'
 compile 'com.android.support:appcompat-v7:22.2.1'
 compile 'com.android.support:support-v4:22.2.1'
 //noinspection GradleDependency
 compile 'com.android.support:design:22.2.0'
 compile 'com.android.support:recyclerview-v7:22.2.1'
 compile 'com.android.support:cardview-v7:22.2.1'
 compile 'com.google.android.gms:play-services-analytics:7.8.0'
 compile 'org.ligi:floatlabel:0.2.0'
 compile 'com.github.castorflex.smoothprogressbar:library:1.1.0'
 compile 'com.github.PhilJay:MPAndroidChart:v2.1.3'
 compile 'com.android.support:percent:22.2.0'
 compile 'commons-net:commons-net:3.3'
 compile 'com.facebook.android:facebook-android-sdk:4.0.0'
}

我搜索了这个错误,似乎是库的副本。 在某处我读到了清楚的android.support.v4。但我需要 android.support.v4.content.WakefulBroadcastReceiver;

1 个答案:

答案 0 :(得分:0)

我解决了我的问题。

我改变了这个

compile 'com.google.android.gms:play-services:7.8.0'

对于此

compile 'com.google.android.gms:play-gcm:7.8.0'

在添加facebook sdk之前,一切运作良好......