Having a really hard time with a AndroidJavaException: java.lang.ClassNotFoundException

Hi there,

I’ve got a very strange runtime error that I can’t resolve. I’ve submitted a bug report for it, and I’ve been working with the guys at Prime31 to try and get to the bottom of it it but no luck. I’m getting this error:

E/Unity (25282): AndroidJavaException: java.lang.ClassNotFoundException: com.prime31.FacebookPlugin
E/Unity (25282): java.lang.ClassNotFoundException: com.prime31.FacebookPlugin
E/Unity (25282): at java.lang.Class.classForName(Native Method)
E/Unity (25282): at java.lang.Class.forName(Class.java:308)
E/Unity (25282): at java.lang.Class.forName(Class.java:272)
E/Unity (25282): at com.unity3d.player.UnityPlayer.nativeRender(Native Method)
E/Unity (25282): at com.unity3d.player.UnityPlayer.c(Unknown Source)
E/Unity (25282): at com.unity3d.player.UnityPlayer$c$1.handleMessage(Unknown Source)
E/Unity (25282): at android.os.Handler.dispatchMessage(Handler.java:98)
E/Unity (25282): at android.os.Looper.loop(Looper.java:145)
E/Unity (25282): at com.unity3d.player.UnityPlayer$c.run(Unknown Source)
E/Unity (25282): Caused by: java.lang.ClassNotFoundException: Didn’t find class “com.prime31.FacebookPlugin” on path: DexPathList[[zip file “/data/app/co.yakand.prime31test-1/base.apk”],nativeLibraryDirectories=[/data/app/co.yakand.prime31test-1/lib/arm, /vendor/lib, /system/lib]]
E/Unity (25282): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
E/Unity (25282): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
E/Unity (25282): at
E/Unity (25282): MissingMethodException: Method not found: ‘UnityEngine.Texture2D.EncodeToPNG’.
E/Unity (25282): at UnityEngine.SetupCoroutine.InvokeMoveNext (IEnumerator enumerator, IntPtr returnValueAddress) [0x00000] in :0
E/Unity (25282): UnityEngine.MonoBehaviour:StartCoroutine_Auto_Internal(IEnumerator)
E/Unity (25282): UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator)
E/Unity (25282): Prime31.FacebookUIManager:Start()

To try and narrow down the problems I’m working in a completely new empty project to remove any clashes with other plugins etc. I imported a couple of Prime31 plugins that have been recently built and are the most current versions, however I don’t believe the issue is with the plugins themselves. I get no compile errors, it’s only when running the app on a device and try to use java some classes that it throws the error. It’s something about my setup and I’m thinking perhaps it’s the Android SDK.

I’ve sent this test project I’d created to the good people at Prime31 who have done some testing for me to help rule out possibilities and it does not seem to be the Unity version. If I use these version I get the runtime error:
2017.2.0f3
2017.2.0p2
2017.2.0p3

Yet if Prime31 use these they don’t have an issue. They even made sure to replicate the same JDK version as me, I’ve tried and this hasn’t changed the outcome:
jdk1.8.0_131.jdk
jdk1.8.0_152.jdk

If it matters I’m running macOs Sierra 10.12.6. I have the latest Android SDK installed from API level 19 to 26 and was using built tools 26.0.3. I’m just now in the process of adding the newer API 27 SDK files to see if it makes any difference but figured these would be in alpha/beta stage anyway.

Does anyone have any ideas why this project works for Prime31 but not for me?? I’m really out of ideas on what to check. All I know is that I was able to produce a working android build before I updated everything. I went from Unity 2017.1.2p1, I had an older Android SDK installation that needed many files updated, and I had updated the prime31 plugins.

I’m really hoping someone can figure out the silly thing I’ve done or forgotten to check.

bug report: https://fogbugz.unity3d.com/default.asp?973799_9cspbmkg8pmbjh2g

(removed this comment)

by the way… neither IL2CPP or Mono made any difference to the outcome either.