0

I used Facebook SDK (and Twitter, Linkedin) to make a log in on my app. It works perfectly if I specify the minSdkVersion<10. I need to upgrade the app to use Fragment..

<uses-sdk android:minSdkVersion="10" />

For the 11 and greater, the app crashes after receiving the token! I need help! Take a look at the error:

UPDATE

07-12 16:58:44.136: D/AndroidRuntime(18310): Shutting down VM

    07-12 16:58:44.148: E/AndroidRuntime(18310): FATAL EXCEPTION: main
07-12 16:58:44.148: E/AndroidRuntime(18310): java.lang.NullPointerException: println needs a message
07-12 16:58:44.148: E/AndroidRuntime(18310):    at android.util.Log.println_native(Native Method)
07-12 16:58:44.148: E/AndroidRuntime(18310):    at android.util.Log.d(Log.java:138)
07-12 16:58:44.148: E/AndroidRuntime(18310):    at com.branchu1.Login$1$1.onComplete(Login.java:161)
07-12 16:58:44.148: E/AndroidRuntime(18310):    at com.facebook.android.Facebook$1.onComplete(Facebook.java:312)
07-12 16:58:44.148: E/AndroidRuntime(18310):    at com.facebook.android.FbDialog$FbWebViewClient.shouldOverrideUrlLoading(FbDialog.java:144)
07-12 16:58:44.148: E/AndroidRuntime(18310):    at android.webkit.CallbackProxy.uiOverrideUrlLoading(CallbackProxy.java:224)
07-12 16:58:44.148: E/AndroidRuntime(18310):    at android.webkit.CallbackProxy.handleMessage(CallbackProxy.java:324)
07-12 16:58:44.148: E/AndroidRuntime(18310):    at android.os.Handler.dispatchMessage(Handler.java:99)
07-12 16:58:44.148: E/AndroidRuntime(18310):    at android.os.Looper.loop(Looper.java:137)
07-12 16:58:44.148: E/AndroidRuntime(18310):    at android.app.ActivityThread.main(ActivityThread.java:4424)
07-12 16:58:44.148: E/AndroidRuntime(18310):    at java.lang.reflect.Method.invokeNative(Native Method)
07-12 16:58:44.148: E/AndroidRuntime(18310):    at java.lang.reflect.Method.invoke(Method.java:511)
07-12 16:58:44.148: E/AndroidRuntime(18310):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
07-12 16:58:44.148: E/AndroidRuntime(18310):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
07-12 16:58:44.148: E/AndroidRuntime(18310):    at dalvik.system.NativeStart.main(Native Method)

It's exactly the same thing with the Twitter and Linkedin SDK. And if I remove the field android:minSdkVersion from the manifest, it works. I really don't understand!

Thanks!

user420574
  • 1,437
  • 5
  • 21
  • 33
  • If you're just upgrading the app to use Fragments, why not use the Android Support Library classes? – Estel Jul 12 '12 at 15:12
  • What's on this line? Login.java:161. I'm using the Facebook SDK on SDK > 10 and haven't had problems. – Rawkode Jul 12 '12 at 15:12
  • @Estel I used Android.support.v13. So I need to set up the API level 11 as a minimal. I simply doesn't understand this error. If I remove totally the field ..it works. Where is the error coming from? – user420574 Jul 12 '12 at 15:16
  • @Rawkode Did you specify an android:minSdkVersion in your manifest? – user420574 Jul 12 '12 at 15:18
  • @Rawkode Line 161 is a lof of the facebook sdk. Log.d("Facebook", e.getMessage()); It seems, Facebook didn't send anything and I get an error from this line. – user420574 Jul 12 '12 at 15:24

2 Answers2

0

"@Rawkode Line 161 is a lof of the facebook sdk. Log.d("Facebook", e.getMessage()); It seems, Facebook didn't send anything and I get an error from this line."

Your issue is that e.getMessage() is a null String, and when you try to call Log.d(TAG, message) with a null String, it will crash with an NPE. I experienced similar issues and it took me a while to track it down:

Some errors do not have any data for the getMessage() method, as it's not required. My solution was to create my own method that always has some text in it, and you'll never get another NPE from that again:

private void logIt(String message){
    Log.d(TAG, "Logged: " + message);
}

Just call that instead of the normal Log.d() and you won't get that issue as there will ALWAYS be data to log (and in your case, it will say: "Logged: null"). You can also modify that method to accept individual tags, but isn't necessary.

Cruceo
  • 6,763
  • 2
  • 31
  • 52
  • The point here is not the crash of the app due to the null log but the fact is Facebook don't send me anything. After research, it's due to the API LEVEL 9 that doesn't support http function called in the sdk. I need to change these functions in the facebook sdk. I'll post an other question about it. Thanks for your reply anyway. – user420574 Jul 13 '12 at 09:15
0

I have the same error.. The app works perfectly on versión 9 or below, but with the android 3.0 or higher doesn't work.

Try with the new facebook's api, it works..

https://developers.facebook.com/android/

Sorry for my english!

user1542789
  • 11
  • 1
  • 2