我在build.gradle文件中导入了ParseFacebookUtils
compile 'com.parse:parsefacebookutils-v4-android:1.10.3@aar'
官方文档说它包含了parse-android:1.12.0,但我无法弄清楚如何使用普通的Parse函数,比如在没有facebook的情况下登录,甚至创建Parse Objects。
我尝试导入两个
compile 'com.parse:parsefacebookutils-v4-android:1.10.3@aar'
compile 'com.parse:parse-android:1.12.0'
它编译成功,但是当我启动应用程序时,它返回classNotFoundException
01-05 15:41:33.560 11530-11530/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.peter.georeminder, PID: 11530
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/facebook/FacebookSdk;
at com.parse.FacebookController$FacebookSdkDelegateImpl.initialize(FacebookController.java:187)
at com.parse.FacebookController.initialize(FacebookController.java:70)
at com.parse.ParseFacebookUtils.initialize(ParseFacebookUtils.java:108)
at com.parse.ParseFacebookUtils.initialize(ParseFacebookUtils.java:92)
at com.peter.georeminder.utils.GeoReminderApplication.onCreate(GeoReminderApplication.java:34)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1013)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4707)
at android.app.ActivityThread.-wrap1(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1405)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.facebook.FacebookSdk" on path: DexPathList[[zip file "/data/app/com.peter.georeminder-2/base.apk"],nativeLibraryDirectories=[/data/app/com.peter.georeminder-2/lib/x86, /data/app/com.peter.georeminder-2/base.apk!/lib/x86, /vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at com.parse.FacebookController$FacebookSdkDelegateImpl.initialize(FacebookController.java:187)
at com.parse.FacebookController.initialize(FacebookController.java:70)
at com.parse.ParseFacebookUtils.initialize(ParseFacebookUtils.java:108)
at com.parse.ParseFacebookUtils.initialize(ParseFacebookUtils.java:92)
at com.peter.georeminder.utils.GeoReminderApplication.onCreate(GeoReminderApplication.java:34)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1013)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4707)
at android.app.ActivityThread.-wrap1(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1405)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Suppressed: java.lang.ClassNotFoundException: com.facebook.FacebookSdk
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 16 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available
更新 build.gradle文件如下:
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
maven { url "https://jitpack.io" }
}
android {
compileSdkVersion 23
buildToolsVersion '23.0.2'
defaultConfig {
applicationId "com.peter.georeminder"
minSdkVersion 19
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
pseudoLocalesEnabled true
}
debug {
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
productFlavors {
}
dexOptions {
javaMaxHeapSize "4g"
}
aaptOptions {
cruncherEnabled false
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile files('libs/AMap_Android_3DMapSDK_V3.1.1.jar')
compile project(':searchbox')
compile 'com.android.support:multidex:1.0.1'
compile ('com.android.support:appcompat-v7:23.1.1')
compile 'com.android.support:recyclerview-v7:23.1.1'
compile 'com.android.support:cardview-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.android.support:support-v4:23.1.1'
compile 'com.android.support:support-annotations:23.1.1'
compile 'com.google.android.gms:play-services-maps:8.4.0'
compile 'com.google.android.gms:play-services-identity:8.4.0'
compile 'com.google.android.gms:play-services-analytics:8.4.0'
// I'm having problems with these three
compile 'com.parse:parse-android:1.12.0'
compile 'com.parse:parsefacebookutils-v4-android:1.10.3@aar'
compile 'com.facebook.android:facebook-android-sdk:4.8.2'
compile 'com.github.clans:fab:1.6.2'
compile 'com.github.dmytrodanylyk.android-process-button:library:1.0.4'
compile 'com.github.recruit-lifestyle:WaveSwipeRefreshLayout:1.4'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.daimajia.easing:library:1.0.1@aar'
compile 'com.daimajia.androidanimations:library:1.1.3@aar'
compile 'de.hdodenhof:circleimageview:2.0.0'
compile 'me.relex:circleindicator:1.1.6@aar'
compile 'com.ToxicBakery.viewpager.transforms:view-pager-transforms:1.2.32@aar'
compile('com.twitter.sdk.android:twitter:1.11.0@aar') {
transitive = true;
}
compile('com.crashlytics.sdk.android:crashlytics:2.5.5@aar') {
transitive = true;
}
compile('com.mikepenz:materialdrawer:4.6.3@aar') {
transitive = true
}
}
当我运行应用程序时,我收到的错误消息是:
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: bolts/AggregateException.class
答案 0 :(得分:2)
正如ParseFacebookUtil.java课程中所述,您还需要导入Facebook SDK V4.x.x.
将此添加到build.gradle并再试一次:
compile 'com.facebook.android:facebook-android-sdk:4.7.0'
您还需要按照docs中的说明初始化Facebook SDK。
<强>更新强> 显然,2个项目具有相同的类,并且它会发生冲突,请尝试:
compile('com.parse:parse-android:1.12.0') {
exclude group: 'com.parse.bolts',
module: 'bolts-android'
}
如果这不起作用,请尝试:
compile('com.parse:parse-android:1.12.0') {
exclude group: 'com.parse.bolts',
module: 'bolts-tasks'
}