问题
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 ?
回答1:
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
回答2:
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.
- First in Unity Build Settings, make sure you choose Gradle for Build System, Export Project, Development Build and Script Debugging.
- Also, make sure you change the Gradle dependency version in Android Studio.
Here is a similar question from Quora.
来源:https://stackoverflow.com/questions/49106942/importing-vufoira-scene-into-native-android-app