Android Studio 1.1.0 Facebook SDK登录

我尝试用facebook SDK测试登录.

所以我添加编译’com.facebook.android:facebook-android-sdk:4.0.0′.

然后添加FacebookSdk.sdkInitialize(getApplicationContext());
到MainActivity.java

但是当我补充

<com.facebook.login.widget.LoginButton
    android:id="@+id/login_button"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center_horizontal"
    android:layout_marginTop="30dp"
    android:layout_marginBottom="30dp" />`

我有以下错误:

Rendering Problems The following classes could not be instantiated:
com.facebook.login.widget.LoginButton (Open Class,Show Exception)
Tip: Use View.isInEditMode() in your custom views to skip code or show sample data when shown in the IDE  
Exception Details java.lang.NoClassDefFoundError: Could not initialize class com.facebook.login.widget.LoginButton
at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:806)
at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:64)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:782)
at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
at android.view.LayoutInflater.inflate(LayoutInflater.java:385) Copy stack to clipboard

解决方法

将Facebook SDK作为模块导入并将其添加到依赖关系应该有助于您,如果遇到此问题:
Error:(13,0) Could not find property 'ANDROID_BUILD_MIN_SDK_VERSION' on project

请检查这个讨论:

Import module problem

祝你好运 !

相关文章

Android 如何解决dialog弹出时无法捕捉Activity的back事件 在...
Android实现自定义带文字和图片的Button 在Android开发中经常...
Android 关于长按back键退出应用程序的实现最近在做一个Andr...
android自带的时间选择器只能精确到分,但是对于某些应用要求...