I'm trying to implement login with Facebook in my unity app but when I'm calling FB.LogInWithReadPermissions I'm getting the following error:
java.lang.NoClassDefFoundError: com.facebook.applinks.AppLinkData
StackTrace:
java.lang.NoClassDefFoundError: com.facebook.applinks.AppLinkData at libcore.reflect.InternalNames.getClass(InternalNames.java:55) at java.lang.Class.getDexCacheType(Class.java:2551) at java.lang.reflect.AbstractMethod.getParameterTypes(AbstractMethod.java:169) at java.lang.reflect.Method.getParameterTypes(Method.java:193) at java.lang.Class.getDeclaredMethods(Class.java:1812) at com.unity3d.player.ReflectionHelper.getMethodID(Unknown Source) at com.unity3d.player.UnityPlayer.nativeRender(Native Method) at com.unity3d.player.UnityPlayer.access$300(Unknown Source) at com.unity3d.player.UnityPlayer$e$1.handleMessage(Unknown Source) at android.os.Handler.dispatchMessage(Handler.java:98) at android.os.Looper.loop(Looper.java:154) at com.unity3d.player.UnityPlayer$e.run(Unknown Source) Caused by: java.lang.ClassNotFoundException: Didn't find class "com.facebook.applinks.AppLinkData" on path: DexPathList[[zip file
My code:
public void facebookLogin()
{
try
{
facebookButton.interactable = false;
var perms = new List<string>() { "public_profile", "email" };
FB.LogInWithReadPermissions(perms, (result) =>
{
if (result.Cancelled)
{
facebookButton.interactable = true;
}
else if (FB.IsLoggedIn)
{
var aToken = Facebook.Unity.AccessToken.CurrentAccessToken;
Dictionary<string, object> data = new Dictionary<string, object>()
{
{ "accessToken", aToken.TokenString }
};
//
managers.server.loginWithFacebook(data, (succ, error) =>
{
if (succ)
{
showHome();
}
else
{
facebookButton.interactable = true;
showError(error, () => { });
}
});
}
else
{
facebookButton.interactable = true;
}
});
}
catch (Exception ex)
{
Debug.Log(ex);
}
}
Unity Editor Version: 2020.3.15f1 Facebook SDK Version: 11.0.0
The solution for me was to update the unity-jar-resolver and then running resolve (Assets> External Dependency Manager> Android Resolver> Resolve)