4

我正在 android studio 中创建一个统一插件。但是我被困在这个特殊的例外上。

当我将项目作为应用程序编译和运行时,问题不会发生,并且仅当它作为库导出到统一时才会发生。

这是错误的完整日志猫

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>

我在互联网上找到并尝试了许多解决方案,但是当应用程序编译为统一插件时,它们都没有解决这种情况。

4

1 回答 1

2

Unity 无法在你的 gradle 文件中导入所有导入的库。因此,您需要将 .jar 文件复制到 Unity 项目的 Plugin 文件夹中

于 2017-08-01T09:47:21.433 回答