Facebook-sdk在android studio更新到0.8.1之后无法正常工作

时间:2014-07-14 12:08:46

标签: android facebook android-studio updates android-gradle

我正在开发一个Android应用程序,使用facebook sdk 3.6.0,在android studio 0.5.7中,更新到0.8.1之后... facebook sdk不起作用,  出现以下错误:

 07-14 11:39:59.808      544-544/com.example.testdrawer E/AndroidRuntime﹕ FATAL EXCEPTION: main
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.testdrawer/com.example.testdrawer.LoginActivity}: android.view.InflateException: Binary XML file line #36: Error inflating class com.facebook.widget.LoginButton
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1955)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1980)
            at android.app.ActivityThread.access$600(ActivityThread.java:122)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1146)
            at android.os.Handler.dispatchMessage(Handler.java:99)
            at android.os.Looper.loop(Looper.java:137)
            at android.app.ActivityThread.main(ActivityThread.java:4340)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:511)
            at comm.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
            at dalvik.system.NativeStart.main(Native Method)
     Caused by: android.view.InflateException: Binary XML file line #36: Error inflating class com.facebook.widget.LoginButton
            at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:691)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:739)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:742)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:742)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:742)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
            at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:251)
            at android.app.Activity.setContentView(Activity.java:1835)
            at com.example.testdrawer.LoginActivity.onCreate(LoginActivity.java:65)
            at android.app.Activity.performCreate(Activity.java:4465)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1919)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1980)
 

    at android.app.ActivityThread.access$600(ActivityThread.java:122)

                at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1146)
                at android.os.Handler.dispatchMessage(Handler.java:99)
                at android.os.Looper.loop(Looper.java:137)
                at android.app.ActivityThread.main(ActivityThread.java:4340)
                at java.lang.reflect.Method.invokeNative(Native Method)
                at java.lang.reflect.Method.invoke(Method.java:511)
                at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
                at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
                at dalvik.system.NativeStart.main(Native Method)
         Caused by: java.lang.ClassNotFoundException: com.facebook.widget.LoginButton
                at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
                at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
                at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
                at android.view.LayoutInflater.createView(LayoutInflater.java:552)
                at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680)
                at android.view.LayoutInflater.rInflate(LayoutInflater.java:739)
                at android.view.LayoutInflater.rInflate(LayoutInflater.java:742)
                at android.view.LayoutInflater.rInflate(LayoutInflater.java:742)
                at android.view.LayoutInflater.rInflate(LayoutInflater.java:742)
                at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
                at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
                at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
                at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:251)
                at android.app.Activity.setContentView(Activity.java:1835)
                at com.example.testdrawer.LoginActivity.onCreate(LoginActivity.java:65)
                at android.app.Activity.performCreate(Activity.java:4465)
                at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
                at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1919)
                at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1980)
                at android.app.ActivityThread.access$600(ActivityThread.java:122)
                at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1146)
                at android.os.Handler.dispatchMessage(Handler.java:99)
                at android.os.Looper.loop(Looper.java:137)
                at android.app.ActivityThread.main(ActivityThread.java:4340)
                at java.lang.reflect.Method.invokeNative(Native Method)
                at java.lang.reflect.Method.invoke(Method.java:511)
                at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
                at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
                at dalvik.system.NativeStart.main(Native Method)

我也将gradle从9改为12

 dependencies {
        classpath 'com.android.tools.build:gradle:0.12.+'
    }

如何解决这个问题?

谢谢你!

我不确切知道我做了什么,但它确实有效!

我清理了项目(构建清除项目),我在build.grandle中更改了一些内容

  apply plugin: 'android'
android {
    compileSdkVersion 19
    buildToolsVersion '19.1.0'

    defaultConfig {
        minSdkVersion 10
        targetSdkVersion 14
    }

    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}
dependencies {
    compile 'com.android.support:support-v4:+'
    compile project(':libraries:facebook')
    compile 'com.google.android.gms:play-services:4.2.42'
    compile 'com.android.support:appcompat-v7:+'
}

0 个答案:

没有答案