Android samples error

2019-06-06 06:51发布

问题:

I cloned the Git Hub repo and imported the folder into eclipse. I attempted to run all of the samples on my Samsung Galaxy Skyrocket with CM10 and all the apps failed. I then ran it on a stock Galaxy S3 with stock ICS and a Samsung R720 with stock gingerbread and they all failed the same way. I finally ran it on the emulator for the same results.

Below are the details of the failures

Example:

SplashActivity: Unfortunately Facebook SDK has stopped working immediately

Tests: App runs but errors when signing in Public API errors failed;

Clicking login returns a facebook themed pagge that says AN error occured. Please try again later.

Test Ui allows me to login correctly and will return error if I input wrong pass but after auth same error comes up

Test Logout Logout tests failed

Stream: I get the welcome screen and the facebook button but clicking the facebook stream button causes the error Unfortunately Facebook SDK has stopped working immediately

In console I keep seeing [2012-10-10 19:13:56 - facebook] Could not find facebook.apk!

Logcat is producing this error

10-10 19:14:38.370: E/AndroidRuntime(9061): FATAL EXCEPTION: main 10-10 19:14:38.370: E/AndroidRuntime(9061): java.lang.NoClassDefFoundError: com.facebook.android.Facebook 10-10 19:14:38.370: E/AndroidRuntime(9061): at com.facebook.stream.LoginHandler$JsHandler$1.run(LoginHandler.java:71) 10-10 19:14:38.370: E/AndroidRuntime(9061): at android.os.Handler.handleCallback(Handler.java:615) 10-10 19:14:38.370: E/AndroidRuntime(9061): at android.os.Handler.dispatchMessage(Handler.java:92) 10-10 19:14:38.370: E/AndroidRuntime(9061): at android.os.Looper.loop(Looper.java:137) 10-10 19:14:38.370: E/AndroidRuntime(9061): at android.app.ActivityThread.main(ActivityThread.java:4930) 10-10 19:14:38.370: E/AndroidRuntime(9061): at java.lang.reflect.Method.invokeNative(Native Method) 10-10 19:14:38.370: E/AndroidRuntime(9061): at java.lang.reflect.Method.invoke(Method.java:511) 10-10 19:14:38.370: E/AndroidRuntime(9061): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791) 10-10 19:14:38.370: E/AndroidRuntime(9061): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:558) 10-10 19:14:38.370: E/AndroidRuntime(9061): at dalvik.system.NativeStart.main(Native Method)

I am not sure where the problem is. It seems to connect to the Lib project fine. Maybe there is a name collison because example and Lib both have com.facebook.android? I really want to start integrating this in my own application but I am weary because of the non-working samples. Granted, it may be my fault I just want to see it working first, Nah mean?

回答1:

I figured it out. I removed all the projects from my workspace.

1) I selected Import? ANdroid from exis...> Copy Projects into workspace> Finish

At this point I got some weird errors see

2) Project> CLean all;

3) Project> Build All;

Now I got a ton of errors. ![]tonoferrors2

So I browsed to one of the errors and I tried to resolve by selecting Fix Project SEtup

**

    • IMPORTANT!!!!

** I got two options. Add project facebook and add archive facebook.jar. The first time I selected the first one errors went away and projects were in the state descrived in my first post. You must hit the second one first (add facebook.jar). Then do it again and the only option will be add archive facebook, do it. The errors will still be there.

I did a final clean and build and hackbooked worked perfect. Every project Every feature. No signing No BS.



回答2:

I got this problem too and none of the posts solved the issue. After reading several answer it started testing everything. So, I compiled the full solution here: that worked for me.

When you use new adt 17 you need Android.support.v4 the samples from facebook brings it added already.

1 - Delete it from your project libs folder. (if it is there) 2 - go to build path and remove it from libraries 3 - go to add Jars... and select the jar Android.support.v4 from the facebook sdk project. 4 - check it there under Order / Export tab. 5 - check android dependencies and android private libraries 6 - Clean your project.

NO MORE ERRORS :)

Thank you everybody. This is the result of a lot of reading. rsrs.



回答3:

You have to sign you application. I think below tutorials will help you to use FB in your application.

https://developers.facebook.com/docs/mobile/android/build/ https://developers.facebook.com/docs/mobile/android/hackbook/