3
votes

I am working on AR app made with unity + vufoira and I wanted to embed it in a native android app. I used this procedures to embed my app Embedding Unity In Android App . But I keep having the following error.

03-04 07:22:24.160 12649-13939/yenettaapp.beblocky E/Unity: AndroidJavaException: java.lang.ClassNotFoundException: com.vuforia.VuforiaUnityPlayer.VuforiaInitializer java.lang.ClassNotFoundException: com.vuforia.VuforiaUnityPlayer.VuforiaInitializer at java.lang.Class.classForName(Native Method) at java.lang.Class.forName(Class.java:400) at java.lang.Class.forName(Class.java:326) at com.unity3d.player.UnityPlayer.nativeRender(Native Method) at com.unity3d.player.UnityPlayer.c(Unknown Source) at com.unity3d.player.UnityPlayer$c$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$c.run(Unknown Source) Caused by: java.lang.ClassNotFoundException: Didn't find class "com.vuforia.VuforiaUnityPlayer.VuforiaInitializer" on path: DexPathList[[zip file "/data/app/yenettaapp.beblocky-1/base.apk", zip file "/data/app/yenettaapp.beblocky-1/split_lib_dependencies_apk.apk", zip file "/data/app/yenettaapp.beblocky-1/split_lib_slice_0_apk.apk", zip file "/data/app/ 03-04 07:22:24.205 12649-13939/yenettaapp.beblocky E/Unity: Exception in callback: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> UnityEngine.AndroidJavaException: java.lang.ClassNotFoundException: com.vuforia.VuforiaUnityPlayer.VuforiaInitializer java.lang.ClassNotFoundException: com.vuforia.VuforiaUnityPlayer.VuforiaInitializer at java.lang.Class.classForName(Native Method) at java.lang.Class.forName(Class.java:400) at java.lang.Class.forName(Class.java:326) at com.unity3d.player.UnityPlayer.nativeRender(Native Method) at com.unity3d.player.UnityPlayer.c(Unknown Source) at com.unity3d.player.UnityPlayer$c$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$c.run(Unknown Source) Caused by: java.lang.ClassNotFoundException: Didn't find class "com.vuforia.VuforiaUnityPlayer.VuforiaInitializer" on path: DexPathList[[zip file "/data/app/yenettaapp.beblocky-1/base.apk", zip file "/data/app/ye 03-04 07:22:24.229 12649-14048/yenettaapp.beblocky E/mono: Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object at UnityEngine.AndroidJavaObject.Dispose (Boolean disposing) [0x00000] in :0 at UnityEngine.AndroidJavaObject.Finalize () [0x00000] in :0 03-04 07:22:24.229 12649-14048/yenettaapp.beblocky E/mono: Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object at UnityEngine.AndroidJavaObject.Dispose (Boolean disposing) [0x00000] in :0 at UnityEngine.AndroidJavaObject.Finalize () [0x00000] in :0

How can I get around this error ?

2
Same issue as this I think developer.vuforia.com/forum/android/…sunil sunny
Its not solved yet tho . . .Nathan Damtew
At which step of the procedure did you get that error? While exporting from Unity or after importing into Android Studio?Saw Thinkar Nay Htoo
After importing in unity. The application will crash just when its about to run the activity where the Unity Scene + Vuforia are embedded in.@SawThinkarNayHtooNathan Damtew
I don't get it. After importing in Unity or Android Studio?Saw Thinkar Nay Htoo

2 Answers

4
votes

I had the same problem. This is how I fixed it:

  • In the project build.gradle I added this under allprojects repositories:
   flatDir {
            dirs 'libs'
        }
  • In my module build.gradle I added the dependencies:
  implementation fileTree(dir: 'libs', include: ['*.jar'])
  implementation(name: 'VuforiaWrapper', ext:'aar'

Hope this may help you

0
votes

I have also tried that Embedding Unity In Android App tutorial from Medium and it didn't work.

Try this Unity3d tutorial -Export Unity Project to Android Studio.

  1. First in Unity Build Settings, make sure you choose Gradle for Build System, Export Project, Development Build and Script Debugging.

Build Settings Unity3D

  1. Also, make sure you change the Gradle dependency version in Android Studio.

Gradle Android Studio

Here is a similar question from Quora.