Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Android] Error calling method on NPObject #303

Closed
BarryDam opened this issue Jun 20, 2013 · 7 comments
Closed

[Android] Error calling method on NPObject #303

BarryDam opened this issue Jun 20, 2013 · 7 comments

Comments

@BarryDam
Copy link

Hello!

I'm running the plugin on Android 4.2.2 with Cordova 2.7

After following each step of your (and Facebooks) readme I started the Simple example.

When I pressed Login the following error occurd:

Uncaught Error: Error calling method on NPObject. at file://android_asset/www/cordova-2.7.0.js:857

SOLUTION :

Right click on the FacebookSDK project - go on the java build path and check android-support-v4.jar (somehow this was unchecked on mine after an android sdk update... )

then just go on Project > clean and rerun the application :)

@bradyemerson
Copy link

I am receiving the same error when calling FB.login() on Android 4.2.2 with Cordova 2.8.

Uncaught Error: Error calling method on NPObject. at file:///android_asset/www/js/cordova-2.8.0.js:863

I've tried the solution you suggested and other FB.xxxx functions work, just not login().

@radu-ciobanu
Copy link

I'm getting the same error too. Any solutions?

@bradyemerson
Copy link

Actually yes, just figured it out. VyseExhale's solution is correct I just misinterpreted it.

FacebookSDK Project -> Properties -> Java Build Path -> Order and Export (tab) -> Make sure android-support-v4.jar is checked. Then do a clean.

@radu-ciobanu
Copy link

Yeap, worked for me also. Thanks!
Now I have another issue. I'm not able the get the session working. FB.init response is null all the time. Any guesses?

@BarryDam
Copy link
Author

Have you configured your key hashes correctely @ your FB app?

AND .. on some (older) android versions, I had to whitelist all facebook domains in the config.xml:
<access origin="http://facebook.com" subdomains="true" /> <access origin="https://facebook.com" subdomains="true" /> <access origin="https://*.facebook.com" /> <access origin="http://*.facebook.com" /> <access origin="http://mymondrian.com" subdomains="true" /> <access origin="https://m.facebook.com" subdomains="true" /> <access origin="https://graph.facebook.com" subdomains="true" /> <access origin="https://api.facebook.com" subdomains="true" /> <access origin="https://*.fbcdn.net" subdomains="true" /> <access origin="https://*.akamaihd.net" subdomains="true" />

only <access origin=".*"/> wasn't enough

@bradyemerson
Copy link

Yes, it sounds like you have not configured the hash for your app in Facebook. You can generate it using keytool or add this snippet to the main activity:

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Add code to print out the key hash
try {
    PackageInfo info = getPackageManager().getPackageInfo(
            "com.facebook.samples.hellofacebook", 
            PackageManager.GET_SIGNATURES);
    for (Signature signature : info.signatures) {
        MessageDigest md = MessageDigest.getInstance("SHA");
        md.update(signature.toByteArray());
        Log.d("KeyHash:", Base64.encodeToString(md.digest(), Base64.DEFAULT));
        }
} catch (NameNotFoundException e) {

} catch (NoSuchAlgorithmException e) {

}

For more info, see Step 4: https://developers.facebook.com/docs/getting-started/facebook-sdk-for-android/3.0/

@aogilvie
Copy link
Collaborator

Closing. Out-of-date.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants