将Vufoira场景导入原生Android应用

时间:2018-03-05 09:18:24

标签: java c# android unity3d vuforia

我正在研究使用unity + vufoira制作的AR应用程序,我想将其嵌入到原生Android应用程序中。我使用此程序嵌入了我的应用Embedding Unity In Android App。但我一直有以下错误。

  

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)                                                                   在com.unity3d.player.UnityPlayer.nativeRender(原生方法)                                                                   在com.unity3d.player.UnityPlayer.c(未知来源)                                                                   在com.unity3d.player.UnityPlayer $ c $ 1.handleMessage(未知来源)                                                                   在android.os.Handler.dispatchMessage(Handler.java:98)                                                                   在android.os.Looper.loop(Looper.java:154)                                                                   在com.unity3d.player.UnityPlayer $ c.run(未知来源)                                                                引起:java.lang.ClassNotFoundException:路径上没有找到类“com.vuforia.VuforiaUnityPlayer.VuforiaInitializer”:DexPathList [[zip文件“/data/app/yenettaapp.beblocky-1/base.apk”,zip文件“/data/app/yenettaapp.beblocky-1/split_lib_dependencies_apk.apk”,zip文件“/data/app/yenettaapp.beblocky-1/split_lib_slice_0_apk.apk”,zip文件“/ data / app /   03-04 07:22:24.205 12649-13939 / yenettaapp.beblocky E / Unity:回调中的异常:System.Reflection.TargetInvocationException:调用目标抛出了异常。 ---> 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)                                                                   在com.unity3d.player.UnityPlayer.nativeRender(原生方法)                                                                   在com.unity3d.player.UnityPlayer.c(未知来源)                                                                   在com.unity3d.player.UnityPlayer $ c $ 1.handleMessage(未知来源)                                                                   在android.os.Handler.dispatchMessage(Handler.java:98)                                                                   在android.os.Looper.loop(Looper.java:154)                                                                   在com.unity3d.player.UnityPlayer $ c.run(未知来源)                                                                引起:java.lang.ClassNotFoundException:路径上没有找到类“com.vuforia.VuforiaUnityPlayer.VuforiaInitializer”:DexPathList [[zip文件“/data/app/yenettaapp.beblocky-1/base.apk”,zip文件“/数据/应用/也   03-04 07:22:24.229 12649-14048 / yenettaapp.beblocky E / mono:未处理的异常:System.NullReferenceException:对象引用未设置为对象的实例                                                                在UnityEngine.AndroidJavaObject.Dispose(布尔处理)[0x00000]中:0                                                                在UnityEngine.AndroidJavaObject.Finalize()[0x00000]中:0   03-04 07:22:24.229 12649-14048 / yenettaapp.beblocky E / mono:未处理的异常:System.NullReferenceException:对象引用未设置为对象的实例                                                                在UnityEngine.AndroidJavaObject.Dispose(布尔处理)[0x00000]中:0                                                                在UnityEngine.AndroidJavaObject.Finalize()[0x00000]中:0

如何解决此错误?

2 个答案:

答案 0 :(得分:4)

我遇到了同样的问题。这就是我修复它的方法:

  • 在项目build.gradle中,我在allprojects存储库中添加了这个:
   flatDir {
            dirs 'libs'
        }
  • 在我的模块build.gradle中,我添加了依赖项:
  implementation fileTree(dir: 'libs', include: ['*.jar'])
  implementation(name: 'VuforiaWrapper', ext:'aar'

希望这可以帮到你

答案 1 :(得分:0)

我也尝试过从Medium中嵌入Unity Android应用程序教程,但它没有用。

试试这个Unity3d tutorial -Export Unity Project to Android Studio

  1. 首先在Unity Build Settings中,确保选择Gradle for Build System,Export Project,Development Build和Script Debugging。
  2. Build Settings Unity3D

    1. 此外,请确保在Android Studio中更改Gradle依赖项版本。
    2. Gradle Android Studio

      以下是Quora的a similar question