我正在android studio中创建一个Unity插件。但是我坚持这个特殊的例外。
当我将项目编译并作为应用程序运行时,问题不会发生,只有当它作为库导出到统一时才会发生。
以下是错误的完整Log cat
com.livefurnish.livefurnish E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.livefurnish.livefurnish, PID: 28640
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.livefurnish.livefurnish/com.livefurnish.livefurnish.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.livefurnish.livefurnish.MainActivity" on path: DexPathList[[zip file "/data/app/com.livefurnish.livefurnish-2/base.apk"],nativeLibraryDirectories=[/data/app/com.livefurnish.livefurnish-2/lib/arm, /system/fake-libs, /data/app/com.livefurnish.livefurnish-2/base.apk!/lib/armeabi-v7a, /system/lib, /vendor/lib]]
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2567)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6126)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.livefurnish.livefurnish.MainActivity" on path: DexPathList[[zip file "/data/app/com.livefurnish.livefurnish-2/base.apk"],nativeLibraryDirectories=[/data/app/com.livefurnish.livefurnish-2/lib/arm, /system/fake-libs, /data/app/com.livefurnish.livefurnish-2/base.apk!/lib/armeabi-v7a, /system/lib, /vendor/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at android.app.Instrumentation.newActivity(Instrumentation.java:1079)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2557)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6126)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Suppressed: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/common/api/GoogleApiClient$OnConnectionFailedListener;
at java.lang.VMClassLoader.findLoadedClass(Native Method)
at java.lang.ClassLoader.findLoadedClass(ClassLoader.java:742)
at java.lang.ClassLoader.loadClass(ClassLoader.java:362)
... 12 more
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.common.api.GoogleApiClient$OnConnectionFailedListener" on path: DexPathList[[zip file "/data/app/com.livefurnish.livefurnish-2/base.apk"],nativeLibraryDirectories=[/data/app/com.livefurnish.livefurnish-2/lib/arm, /system/fake-libs, /data/app/com.livefurnish.livefurnish-2/base.apk!/lib/armeabi-v7a, /system/lib, /vendor/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
... 15 more
这是我用于统一插件的自定义清单:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.livefurnish.livefurnish" android:versionName="1.0" android:versionCode="1">
<uses-sdk android:minSdkVersion="19" />
<application android:label="@string/app_name">
<activity android:name=".MainActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
我在互联网上找到并尝试了很多解决方案,但是当应用程序被编译为统一插件时,它们都没有解决这个问题。
答案 0 :(得分:2)
Unity无法导入gradle文件中的所有导入库。因此,您需要在Unity项目的Plugin文件夹中复制.jar文件