代码之家  ›  专栏  ›  技术社区  ›  mojado

导入unity时未找到android库的maven依赖项

  •  0
  • mojado  · 技术社区  · 5 年前

    因为Unity脚本不能在android构建的后台运行,所以我需要创建一个android库来运行android服务中的代码。

    通过unity和running fine正确调用android服务。

    但是,我还需要在服务中使用paho MqttAndroidClient,这是在librarys gradle中作为maven依赖项添加的。当通过android studio构建android应用程序时,这很好,但是当作为库构建并导入unity时,我得到以下异常:

    Process: com.ar.mqttServer, PID: 19777
    java.lang.RuntimeException: An error occurred while executing doInBackground()
        at android.os.AsyncTask$3.done(AsyncTask.java:354)
        at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383)
        at java.util.concurrent.FutureTask.setException(FutureTask.java:252)
        at java.util.concurrent.FutureTask.run(FutureTask.java:271)
        at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:764)
     Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Lorg/eclipse/paho/android/service/MqttAndroidClient;
        at com.ar.ntripclient.NtripClient$NTRIPClientThread.doInBackground(NtripClient.java:92)
        at android.os.AsyncTask$2.call(AsyncTask.java:333)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245) 
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) 
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) 
        at java.lang.Thread.run(Thread.java:764) 
     Caused by: java.lang.ClassNotFoundException: Didn't find class "org.eclipse.paho.android.service.MqttAndroidClient" on path: DexPathList[[zip file "/data/app/com.ar.mqttServer-vUyFnwrhL3g2gvDl5VRW_w==/base.apk"],nativeLibraryDirectories=[/data/app/com.ar.mqttServer-vUyFnwrhL3g2gvDl5VRW_w==/lib/arm, /data/app/com.ar.mqttServer-vUyFnwrhL3g2gvDl5VRW_w==/base.apk!/lib/armeabi-v7a, /system/lib]]
        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:171)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
        at com.ar.ntripclient.NtripClient$NTRIPClientThread.doInBackground(NtripClient.java:92) 
        at android.os.AsyncTask$2.call(AsyncTask.java:333) 
        at java.util.concurrent.FutureTask.run(FutureTask.java:266) 
        at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245) 
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) 
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) 
        at java.lang.Thread.run(Thread.java:764) 
    
    0 回复  |  直到 5 年前