简体   繁体   English

将Parse和Facebook集成到Android应用中时出错

[英]Error in integrating Parse and Facebook into Android app

I am trying to integrate Parse and Facebook into my app. 我正在尝试将Parse和Facebook集成到我的应用程序中。 When I want to make the Facebook login I get this error: 当我想进行Facebook登录时,出现以下错误:

java.lang.NoClassDefFoundError: com.facebook.android.Facebook

The code I use to initialize my Parse and ParseFacebookUtils: 我用来初始化Parse和ParseFacebookUtils的代码:

public class App extends Application {
    public static Bitmap profilePicture;

    private static String PARSE_APPLICATION_ID;
    private static String PARSE_CLIENT_KEY;

    @Override
    public void onCreate() {
        super.onCreate();

        PARSE_APPLICATION_ID = getResources().getString(R.string.PARSE_APPLICATION_ID);
        PARSE_CLIENT_KEY = getResources().getString(R.string.PARSE_CLIENT_KEY);

        Parse.enableLocalDatastore(this);
        Parse.initialize(this, PARSE_APPLICATION_ID, PARSE_CLIENT_KEY);

        ParseFacebookUtils.initialize();

    }
}

I included Parse-1.9.0.jar and ParseFacebookUtilsV3-1.9.0.jar in my app. 我在我的应用程序中包含了Parse-1.9.0.jar和ParseFacebookUtilsV3-1.9.0.jar。 If someone could help me that would be great! 如果有人可以帮助我,那就太好了!

The problem was that the Facebook SDK wasn't loaded. 问题是没有加载Facebook SDK。 I fixed it by using 我通过使用修复了它

compile 'com.facebook.android:facebook-android-sdk:3.23.1'

instead of 代替

compile 'com.facebook.android:facebook-android-sdk:4.0.0'

I think (since Parse is using FacebookUtils V3 ) Parse requires Facebook SDK V3 instead of V4. 我认为(由于Parse使用FacebookUtils V3 ),Parse需要Facebook SDK V3而不是V4。

Bart, You can use Facebook v4 also. 巴特,您也可以使用Facebook v4。 For that use ParseFacebookUtils4 instead ParseFacebookUtils3. 为此,请使用ParseFacebookUtils4代替ParseFacebookUtils3。

Please see my answer here for clear example. 在这里查看我的答案以获取清晰的示例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM