android facebook sdk 4.1.2 eclipse 错误

Posted

技术标签:

【中文标题】android facebook sdk 4.1.2 eclipse 错误【英文标题】:android facebook sdk 4.1.2 eclipse error 【发布时间】:2015-05-19 04:40:55 【问题描述】:

这是我运行 App 后的错误。导入 Facebook 4.1.2 项目后,它说我需要 Java 1.7、android 支持 v4 和 Bolts-Android,所以我从上一个版本更新了我的 Android 工具库,它显示错误。

05-18 19:05:06.591: E/AndroidRuntime(23525): FATAL EXCEPTION: main
    05-18 19:05:06.591: E/AndroidRuntime(23525): java.lang.RuntimeException: Unable to start activity ComponentInfocom.example.fbtest/com.example.fbtest.MainActivity: android.view.InflateException: Binary XML file line #11: Error inflating class com.facebook.login.widget.LoginButton
    05-18 19:05:06.591: E/AndroidRuntime(23525):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2372)
    05-18 19:05:06.591: E/AndroidRuntime(23525):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2424)
    05-18 19:05:06.591: E/AndroidRuntime(23525):    at android.app.ActivityThread.access$600(ActivityThread.java:169)
    05-18 19:05:06.591: E/AndroidRuntime(23525):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1388)
    05-18 19:05:06.591: E/AndroidRuntime(23525):    at android.os.Handler.dispatchMessage(Handler.java:107)
    05-18 19:05:06.591: E/AndroidRuntime(23525):    at android.os.Looper.loop(Looper.java:194)
    05-18 19:05:06.591: E/AndroidRuntime(23525):    at android.app.ActivityThread.main(ActivityThread.java:5433)
    05-18 19:05:06.591: E/AndroidRuntime(23525):    at java.lang.reflect.Method.invokeNative(Native Method)
    05-18 19:05:06.591: E/AndroidRuntime(23525):    at java.lang.reflect.Method.invoke(Method.java:525)
    05-18 19:05:06.591: E/AndroidRuntime(23525):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:924)
    05-18 19:05:06.591: E/AndroidRuntime(23525):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:691)
    05-18 19:05:06.591: E/AndroidRuntime(23525):    at dalvik.system.NativeStart.main(Native Method)
    05-18 19:05:06.591: E/AndroidRuntime(23525): Caused by: android.view.InflateException: Binary XML file line #11: Error inflating class com.facebook.login.widget.LoginButton
    05-18 19:05:06.591: E/AndroidRuntime(23525):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:698)
    05-18 19:05:06.591: E/AndroidRuntime(23525):    at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
    05-18 19:05:06.591: E/AndroidRuntime(23525):    at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
    05-18 19:05:06.591: E/AndroidRuntime(23525):    at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
    05-18 19:05:06.591: E/AndroidRuntime(23525):    at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
    05-18 19:05:06.591: E/AndroidRuntime(23525):    at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:274)
    05-18 19:05:06.591: E/AndroidRuntime(23525):    at android.app.Activity.setContentView(Activity.java:1895)
    05-18 19:05:06.591: E/AndroidRuntime(23525):    at com.example.fbtest.MainActivity.onCreate(MainActivity.java:23)
    05-18 19:05:06.591: E/AndroidRuntime(23525):    at android.app.Activity.performCreate(Activity.java:5179)
    05-18 19:05:06.591: E/AndroidRuntime(23525):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1146)
    05-18 19:05:06.591: E/AndroidRuntime(23525):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2336)
    05-18 19:05:06.591: E/AndroidRuntime(23525):    ... 11 more
    05-18 19:05:06.591: E/AndroidRuntime(23525): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.facebook.login.widget.LoginButton" on path: DexPathList[[zip file "/data/app/com.example.fbtest-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.fbtest-2, /vendor/lib, /system/lib, /data/datalib]]
    05-18 19:05:06.591: E/AndroidRuntime(23525):    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:53)
    05-18 19:05:06.591: E/AndroidRuntime(23525):    at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
    05-18 19:05:06.591: E/AndroidRuntime(23525):    at java.lang.ClassLoader.loadClass(ClassLoader.java:461)

xml 和 manifest 的图像是:

XML,MANIFEST

【问题讨论】:

How to correct 在 Eclipse 中导入 Facebook SDK。 【参考方案1】:

要消除此错误,首先将您的 Facebook SDK 放入您的工作区,然后在 eclipse 中导入。

【讨论】:

以上是关于android facebook sdk 4.1.2 eclipse 错误的主要内容,如果未能解决你的问题,请参考以下文章

Facebook android sdk 需要 java 1.7 才能工作?

在 Facebook SDK Android 上找不到文件“com.facebook.android.facebook”

无法使用 Facebook Android SDK 和 Facebook Audience Network SDK 编译

通过 Xamarin.Facebook.Android sdk 登录 Facebook

Android - 使用 facebook sdk 在 facebook 墙上发帖的问题

Android:在eclipse中导入facebook sdk 4.10.1