unable to reference com.facebook.widget.LoginButton

烂漫一生 提交于 2019-12-01 12:40:21

问题


I am working on an android app which uses the Facebook SDK (using the latest version, 3.6). This is my first time working with the SDK and trying to get up the simple login page work based on the example code available in the samples (scrumptious). I am unable to resolve the LoginButton in my xml layout. It is unable to reference com.facebook.widget.LoginButton. I tried copying the class file LoginButton source into my own class named FBLoginButton and then edited the layout file to look like this:

        <!-- <com.facebook.widget.LoginButton -->
        <!--<com.facebook.scrumptious.LoginButton  -->

        <com.example.myproject.FBLoginButton 
            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" />

While my class FBLoginButton is free of errors in itself, I get the error:

The following classes could not be instantiated:
- com.example.insultdroid.FBLoginButton (Open Class, Show Error Log)

I have already spent endless hours trying to get the LoginButton to work but to no success. Rebuilding, cleaning, restarting eclipse; I have done it all! Can someone please help me!

Adding a snapshot that shows that LoginButton class is available in the facebooksdk.jar which I have added to the dependencies.


回答1:


The project you're working on... have you imported the Facebook SDK and added the library to your current project? (right click > Project > Android > Add... button in library section). Or check your Java build path -> Order and Export and make sure the facebook library is checked.

If you have, then it should work..., if you haven't, add the library and it should work.

Also, make sure under Android dependencies > facebooksdk.jar, that you see com.facebook.widget.LoginButton.

If it's still not working, try deleting the facebook library, re-adding it, close and restart Eclipse.




回答2:


I am not sure from where you got this component from... because the login button component starts with

<com.facebook.widget.LoginButton
        .... />

just change the component name to it, it should work. give me a feedback otherwise, happy programming




回答3:


see that you have added the facebook SDK from properties->Android->Add library project and not in the build path.

This should solve the problem.



来源:https://stackoverflow.com/questions/21070890/unable-to-reference-com-facebook-widget-loginbutton

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!