Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Extending existing Facebook SDK for Unity - Adding App Invite

Discussion in 'Editor & General Support' started by devotionsolutions, Jul 31, 2015.

  1. devotionsolutions

    devotionsolutions

    Joined:
    Feb 9, 2013
    Posts:
    40
    Hi everyone, I need some advice here.
    The current Facebook SDK for Unity 6.2.2 (https://developers.facebook.com/docs/unity/downloads, 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:

    Code (CSharp):
    1. public static void inviteContacts(Activity root, String linkURL, String previewImageURL) {
    2.         Log.i(TAG, "MainActivity::inviteContacts()");
    3.    
    4.         Log.i(TAG, "MainActivity::FacebookId:" + FacebookSdk.getApplicationId()); //The code fails just here!
    5.  
    6.         if (AppInviteDialog.canShow()) {
    7.             Log.i(TAG, "AppInviteDialog.canShow()!");
    8.             AppInviteContent content = new AppInviteContent.Builder()
    9.                     .setApplinkUrl(linkURL)
    10.                     .setPreviewImageUrl(previewImageURL)
    11.                     .build();
    12.             //AppInviteDialog.show(this, content);
    13.             AppInviteDialog.show(root, content);
    14.         }
    15.     }
    But unfortunately I'm getting the following error:
    Code (CSharp):
    1. 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: http://www.thegamecontriver.com/2015/04/android-plugin-unity-android-studio.html

    Am I missing something?

    Thanks in advance.
     
    Last edited: Jul 31, 2015
  2. devotionsolutions

    devotionsolutions

    Joined:
    Feb 9, 2013
    Posts:
    40
    BTW, probably this post would be better fit for the Android Development forum. To the administrators: if possible, feel free to move it. Thanks.
     
  3. devotionsolutions

    devotionsolutions

    Joined:
    Feb 9, 2013
    Posts:
    40
    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:

    Code (CSharp):
    1. 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,
     
  4. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,562
    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.