Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
913 views
in Technique[技术] by (71.8m points)

login - The following classes could not be instantiated: - com.facebook.widget.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)
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

OPTION #1:

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

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

OPTION #2:

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

An example could be:

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...