您好我正在构建一个使用Android库作为插件之一的Unity应用程序。此Android库使用AppCompat。
从Unity博客中读到,我发现由于几个原因(主要是APK大小),Unity在构建期间不包含appcompat库,但它仍然允许手动添加库。 (博客:http://blogs.unity3d.com/2015/07/16/android-themes-in-unity/)
因此我在Assets / Plugins / Android /中添加了库,然后我的Unity应用程序能够成功构建并生成APK文件。
问题来自于我试图打开应用程序,该应用程序可能启动了在android库中定义的活动。此特定活动使用appcompat库。我从logcat
收到以下错误消息I/art (19482): Rejecting re-init on previously-failed class java.lang.Class<android.support.v7.app.AppCompatActivity>
I/art (19482): Rejecting re-init on previously-failed class java.lang.Class<android.support.v7.app.AppCompatActivity>
W/ActivityManager( 890): Force finishing activity amillardo.test.blasterescopic/com.test.player.MainActivity
I/art (19482): Rejecting re-init on previously-failed class java.lang.Class<android.support.v7.app.ActionBarActivity>
I/art (19482): Rejecting re-init on previously-failed class java.lang.Class<android.support.v7.app.ActionBarActivity>
I/art (19482): Rejecting re-init on previously-failed class java.lang.Class<com.test.player.MainActivity>
E/AndroidRuntime(19482): FATAL EXCEPTION: main
E/AndroidRuntime(19482): Process: amillardo.test.blasterescopic, PID: 19482
E/AndroidRuntime(19482): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{amillardo.test.blasterescopic/com.test.player.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.test.player.MainActivity" on path: DexPathList[[zip file "/data/app/amillardo.test.blasterescopic-1/base.apk"],nativeLibraryDirectories=[/data/app/amillardo.test.blasterescopic-1/lib/arm, /system/lib, /vendor/lib, system/vendor/lib, system/vendor/lib/egl, system/lib/hw]]
E/AndroidRuntime(19482): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2322)
E/AndroidRuntime(19482): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2474)
E/AndroidRuntime(19482): at android.app.ActivityThread.access$800(ActivityThread.java:144)
E/AndroidRuntime(19482): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1359)
E/AndroidRuntime(19482): at android.os.Handler.dispatchMessage(Handler.java:102)
E/AndroidRuntime(19482): at android.os.Looper.loop(Looper.java:155)
E/AndroidRuntime(19482): at android.app.ActivityThread.main(ActivityThread.java:5696)
E/AndroidRuntime(19482): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(19482): at java.lang.reflect.Method.invoke(Method.java:372)
E/AndroidRuntime(19482): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1028)
E/AndroidRuntime(19482): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:823)
E/AndroidRuntime(19482): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.test.player.MainActivity" on path: DexPathList[[zip file "/data/app/amillardo.test.blasterescopic-1/base.apk"],nativeLibraryDirectories=[/data/app/amillardo.test.blasterescopic-1/lib/arm, /system/lib, /vendor/lib, system/vendor/lib, system/vendor/lib/egl, system/lib/hw]]
E/AndroidRuntime(19482): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
E/AndroidRuntime(19482): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
E/AndroidRuntime(19482): at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
E/AndroidRuntime(19482): at android.app.Instrumentation.newActivity(Instrumentation.java:1083)
E/AndroidRuntime(19482): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2312)
E/AndroidRuntime(19482): ... 10 more
E/AndroidRuntime(19482): Suppressed: java.lang.NoClassDefFoundError: com.test.player.MainActivity
E/AndroidRuntime(19482): at dalvik.system.DexFile.defineClassNative(Native Method)
E/AndroidRuntime(19482): at dalvik.system.DexFile.defineClass(DexFile.java:226)
E/AndroidRuntime(19482): at dalvik.system.DexFile.loadClassBinaryName(DexFile.java:219)
E/AndroidRuntime(19482): at dalvik.system.DexPathList.findClass(DexPathList.java:321)
E/AndroidRuntime(19482): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:54)
E/AndroidRuntime(19482): ... 14 more
E/AndroidRuntime(19482): Suppressed: java.lang.ClassNotFoundException: com.test.player.MainActivity
E/AndroidRuntime(19482): at java.lang.Class.classForName(Native Method)
E/AndroidRuntime(19482): at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
E/AndroidRuntime(19482): at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
E/AndroidRuntime(19482): at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
E/AndroidRuntime(19482): ... 13 more
E/AndroidRuntime(19482): Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
I/TrimMemoryManager( 1561): [trimMemory] 20
E/ActivityManager( 890): App crashed! Process: amillardo.test.blasterescopic
所以,我被困在这里。有人有什么建议吗?谢谢!
答案 0 :(得分:1)
在尝试了我能想到的所有方法后,我终于开始工作了!
我怀疑这是因为appcompat库实际上需要或依赖于support-v4库。
最初我只将android sdk中的appcompat库导入到我的Unity项目中。但是当我导入support-v4库时,错误不再存在!
所以希望这可以帮助任何需要它的人。