以下类无法实例化: - com.facebook.widget.LoginButton [英] The following classes could not be instantiated: - com.facebook.widget.LoginButton

查看:168
本文介绍了以下类无法实例化: - com.facebook.widget.LoginButton的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在努力让Facebook的练习应用程序正常工作,我无法为我的生活找出为什么我不能参考在Facebook SDK中找到的LoginButton。以下是当我查看定义LoginButton的布局时遇到的错误。

I have been working on getting the facebook practice apps working and I cannot for the life of me figure out why I cannot reference the LoginButton found in the Facebook SDK. Below is the error that I am encountering when I look at the layout that defines the LoginButton.

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







The following classes could not be instantiated:
- com.facebook.widget.LoginButton (Open Class, Show Error Log)
See the Error Log (Window > Show View) for more details.
Tip: Use View.isInEditMode() in your custom views to skip code when shown in Eclipse

android.content.res.Resources$NotFoundException: Could not resolve resource value:            0x7F070004.
at android.content.res.BridgeResources.throwException(BridgeResources.java:693)
at android.content.res.BridgeResources.getColor(BridgeResources.java:185)
at com.facebook.widget.LoginButton.<init>(LoginButton.java:211)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(    at      sun.reflect.NativeConstructorAccessorImpl.newInstance(    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(    at java.lang.reflect.Constructor.newInstance(    at com.android.ide.eclipse.adt.internal.editors.layout.ProjectCallback.instantiateClass(ProjectCallback.java:422)
at com.android.ide.eclipse.adt.internal.editors.layout.ProjectCallback.loadView(ProjectCallback.java:179)
at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:207)
at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:135)
at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:746)
at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:64)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:718)
at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
at android.view.LayoutInflater.inflate(LayoutInflater.java:372)


推荐答案

p> 选项#1

有时,添加新资源时,Eclipse不能正确编译新的代码(可能是缓存问题),导致此错误。

Sometimes, when a new resource is added, Eclipse doesn't compile correctly the new code (maybe a caching issue), causing this error.

通常,只需重新启动Eclipse即可解决问题。

Normally, simply restarting Eclipse is enough to fix the problem.

选项#2: / strong>

OPTION #2:

有时,呈现自定义视图会导致此异常。我知道唯一的解决方法是在每次尝试使用 getResources()时检查View.isInEditMode。

Sometimes, rendering custom views causes this exception. The only workaround I know is checking View.isInEditMode every time you try to use the getResources().

例如:

if (isInEditMode()) {
    //do something else, as getResources() is not valid.
} else {
    //you can use getResources()
    String mystring = getResources().getString(R.string.mystring);
}

这篇关于以下类无法实例化: - com.facebook.widget.LoginButton的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆