Extending existing Facebook SDK for Unity - Adding App Invite

Hi everyone, I need some advice here.
The current Facebook SDK for Unity 6.2.2 (Downloads - Unity SDK - Documentation - Meta for Developers, neither the beta) doesn’t include support for App Invites: https://developers.facebook.com/docs/app-invites.

I’m trying to add the functionality on my own. I’ve started by creating an Android plugin using the Facebook Android SDK, and also just the App Invite functionality, a simple static method including the following:

public static void inviteContacts(Activity root, String linkURL, String previewImageURL) {
        Log.i(TAG, "MainActivity::inviteContacts()");
   
        Log.i(TAG, "MainActivity::FacebookId:" + FacebookSdk.getApplicationId()); //The code fails just here!

        if (AppInviteDialog.canShow()) {
            Log.i(TAG, "AppInviteDialog.canShow()!");
            AppInviteContent content = new AppInviteContent.Builder()
                    .setApplinkUrl(linkURL)
                    .setPreviewImageUrl(previewImageURL)
                    .build();
            //AppInviteDialog.show(this, content);
            AppInviteDialog.show(root, content);
        }
    }

But unfortunately I’m getting the following error:

java.lang.NoClassDefFoundError: Failed resolution of: Lcom/facebook/FacebookSdk [OR ANY OTHER FACEBOOK JAVA CLASS]

I’m following the instructions here, and the example worked as expected: Loading...

Am I missing something?

Thanks in advance.

BTW, probably this post would be better fit for the Android Development forum. To the administrators: if possible, feel free to move it. Thanks.

OK, this is not related to Facebook library exclusively, I’ve tried to add the Google Analytics library and I have the same error now:

I/Unity﹕ AndroidJavaException: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/analytics/GoogleAnalytics;

Seems like I’m missing something here. Could you guys help?

Thanks,

Can you post some of the code you’re using to call into this native Java code ?
Also, keep in mind this won’t work in the editor, only on an Android device.