Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Resources$NotFoundException is thrown by Integrating Facebook-android-sdk-3.0

I'm trying to integrate Facebook inside my app. But as soon as i clicked on fbphoto it throws error android.content.res.Resources$NotFoundException. I do know that it throws error as proper resource is not founding at runtime.

Found out that error is thrown at facebook.authorize(this, new String[] { "email", "publish_stream"}, new DialogListener() {}. But the root cause is still missing.

fbphoto.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            loginToFacebook();
        }
    });

public void loginToFacebook()
{
if(!facebook.isSessionValid())
    {
        facebook.authorize(this, new String[] { "email", "publish_stream"}, new DialogListener() {

        });
    }

02-08 02:57:58.236: E/AndroidRuntime(1582): FATAL EXCEPTION: main
02-08 02:57:58.236: E/AndroidRuntime(1582): android.content.res.Resources$NotFoundException: String resource ID #0x7f050011
02-08 02:57:58.236: E/AndroidRuntime(1582):     at android.content.res.Resources.getText(Resources.java:201)
02-08 02:57:58.236: E/AndroidRuntime(1582):     at android.content.res.Resources.getString(Resources.java:254)
02-08 02:57:58.236: E/AndroidRuntime(1582):     at android.content.Context.getString(Context.java:183)
02-08 02:57:58.236: E/AndroidRuntime(1582):     at com.facebook.widget.WebDialog.onCreate(WebDialog.java:188)
02-08 02:57:58.236: E/AndroidRuntime(1582):     at android.app.Dialog.dispatchOnCreate(Dialog.java:307)
02-08 02:57:58.236: E/AndroidRuntime(1582):     at android.app.Dialog.show(Dialog.java:225)
02-08 02:57:58.236: E/AndroidRuntime(1582):     at com.facebook.AuthorizationClient$WebViewAuthHandler.tryAuthorize(AuthorizationClient.java:462)
02-08 02:57:58.236: E/AndroidRuntime(1582):     at com.facebook.AuthorizationClient.tryCurrentHandler(AuthorizationClient.java:210)
02-08 02:57:58.236: E/AndroidRuntime(1582):     at com.facebook.AuthorizationClient.tryNextHandler(AuthorizationClient.java:189)
02-08 02:57:58.236: E/AndroidRuntime(1582):     at com.facebook.AuthorizationClient.authorize(AuthorizationClient.java:117)
02-08 02:57:58.236: E/AndroidRuntime(1582):     at com.facebook.AuthorizationClient.startOrContinueAuth(AuthorizationClient.java:98)
02-08 02:57:58.236: E/AndroidRuntime(1582):     at com.facebook.Session.tryLegacyAuth(Session.java:1096)
02-08 02:57:58.236: E/AndroidRuntime(1582):     at com.facebook.Session.authorize(Session.java:893)
02-08 02:57:58.236: E/AndroidRuntime(1582):     at com.facebook.Session.open(Session.java:957)
02-08 02:57:58.236: E/AndroidRuntime(1582):     at com.facebook.Session.openForPublish(Session.java:415)
02-08 02:57:58.236: E/AndroidRuntime(1582):     at com.facebook.android.Facebook.openSession(Facebook.java:319)
02-08 02:57:58.236: E/AndroidRuntime(1582):     at com.facebook.android.Facebook.authorize(Facebook.java:313)
02-08 02:57:58.236: E/AndroidRuntime(1582):     at com.facebook.android.Facebook.authorize(Facebook.java:149)
02-08 02:57:58.236: E/AndroidRuntime(1582):     at com.example.splashscreen.SecondScreen.loginToFacebook(SecondScreen.java:110)
02-08 02:57:58.236: E/AndroidRuntime(1582):     at com.example.splashscreen.SecondScreen$1.onClick(SecondScreen.java:73)
02-08 02:57:58.236: E/AndroidRuntime(1582):     at android.view.View.performClick(View.java:2485)
02-08 02:57:58.236: E/AndroidRuntime(1582):     at android.view.View$PerformClick.run(View.java:9080)
02-08 02:57:58.236: E/AndroidRuntime(1582):     at android.os.Handler.handleCallback(Handler.java:587)
02-08 02:57:58.236: E/AndroidRuntime(1582):     at android.os.Handler.dispatchMessage(Handler.java:92)
02-08 02:57:58.236: E/AndroidRuntime(1582):     at android.os.Looper.loop(Looper.java:123)
02-08 02:57:58.236: E/AndroidRuntime(1582):     at android.app.ActivityThread.main(ActivityThread.java:3683)
02-08 02:57:58.236: E/AndroidRuntime(1582):     at java.lang.reflect.Method.invokeNative(Native Method)
02-08 02:57:58.236: E/AndroidRuntime(1582):     at java.lang.reflect.Method.invoke(Method.java:507)
02-08 02:57:58.236: E/AndroidRuntime(1582):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
02-08 02:57:58.236: E/AndroidRuntime(1582):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
02-08 02:57:58.236: E/AndroidRuntime(1582):     at dalvik.system.NativeStart.main(Native Method)
like image 887
Vikalp Patel Avatar asked Feb 07 '13 21:02

Vikalp Patel


People also ask

How did you integrate the Facebook SDK in Android app?

To use the Facebook SDK in an Android Studio project, add the SDK as a build dependency and import the SDK. Go to Android Studio | New Project | Minimum SDK. Select API 15: Android 4.0. 3 (IceCreamSandwich) or higher and create your new project.

Is Facebook SDK open source?

Overview of the Facebook SDK for AndroidThe SDK is open source, and it is hosted at GitHub's facebook / facebook-android-sdk repository.

What is the latest version of Facebook SDK?

The current version of the Facebook SDK for Android is version 15.0. 0 and requires the Android API 15. Code and samples for the Facebook SDK for Android are available on GitHub.


1 Answers

Please note that this error will also happen if you are running IntelliJ and have included the Facebook source as a library module in your project.

It's unclear what actually causes this to occur, but when the Facebook project (entire tree) is included as a library module in your IntelliJ project, the facebook strings.xml file will sometimes get overwritten with a very simple strings.xml file, and break your app with the Resources Not Found exception on the Facebook login screen. Not only that, but the Facebook AndroidManifest will sometimes also get overwritten and cause compile time issues.

Replacing the bogus strings.xml and AndroidManifest.xml files will resolve the issue.

like image 96
Greg Pasquariello Avatar answered Oct 06 '22 00:10

Greg Pasquariello