2***@qq.com
2***@qq.com
  • 发布:2019-07-11 15:08
  • 更新:2019-07-26 19:04
  • 阅读:5146

uniapp调用原生插件包含第三方SDK时抛NoClassDefFoundError异常

分类:uni-app

开发uniapp原生插件时,在依赖的library里的activity有依赖第三方SDK时,在打包自定义基座时logcat中抛出异常:

java.lang.NoClassDefFoundError: Failed resolution of: Lorg/ar/arcall/ARCallEvent;  
        at java.lang.Class.newInstance(Native Method)  
        at android.app.Instrumentation.newActivity(Instrumentation.java:1174)  
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2669)  
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)  
        at android.app.ActivityThread.-wrap11(Unknown Source:0)  
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)  
        at android.os.Handler.dispatchMessage(Handler.java:106)  
        at android.os.Looper.loop(Looper.java:164)  
        at android.app.ActivityThread.main(ActivityThread.java:6494)  
        at java.lang.reflect.Method.invoke(Native Method)  
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)  
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)  
     Caused by: java.lang.ClassNotFoundException: Didn't find class "org.ar.arcall.ARCallEvent" on path: DexPathList[[zip file "/data/app/io.dcloud.UNICFFB4F8-0FXeMyqJGtXpDrWrH6akfw==/base.apk"],nativeLibraryDirectories=[/data/app/io.dcloud.UNICFFB4F8-0FXeMyqJGtXpDrWrH6akfw==/lib/x86, /data/app/io.dcloud.UNICFFB4F8-0FXeMyqJGtXpDrWrH6akfw==/base.apk!/lib/x86, /system/lib, /vendor/lib]]  

我已经在android library的dependencies里写了依赖关系,在编译时如果在package.json里同样写dependencies打包就会报错,这里该怎么做,社区好像没有相关的文章。

2019-07-11 15:08 负责人:无 分享
已邀请:
2***@qq.com

2***@qq.com (作者)

解决了,api改成implementation

l***@gmail.com

l***@gmail.com

楼主你好,我也是有你这种情况,但是我用的就是implementation,还是获取不到,代码如下忘指点下:

   compileOnly fileTree(dir: 'libs', include: ['*.jar'])  
    compileOnly fileTree(dir: '../app/libs', include: ['uniapp-release.aar'])  
    compileOnly fileTree(dir: '../app/libs', include: ['lib.5plus.base-release.aar'])  
    compileOnly 'com.ald.library:eca-sdk:1.0.5'  
    compileOnly 'cn.pedant.sweetalert:library:1.3'  
    compileOnly 'com.hjq:toast:8.0'

然后在hookproxy中初始化这个

public class MyHookPro implements AppHookProxy {  
    public String TAG = "MyHook";  

    @Override  
    public void onCreate(Application application) {  
        // 在 Application 中初始化  
        Log.i(TAG, "=======弹框初始化========");  
        ToastUtils.init(application);  
        Log.i(TAG, "=======弹框初始化结束========");  

    }  
}  

最后还是报错了

2019-07-26 18:59:53.579 14317-14317/? I/MyHook: =======弹框初始化========  
2019-07-26 18:59:53.582 14317-14317/? W/System.err: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/hjq/toast/ToastUtils;  
2019-07-26 18:59:53.583 14317-14317/? W/System.err:     at com.sky.uniplugin_auto_phone_call.MyHookPro.onCreate(MyHookPro.java:28)  
2019-07-26 18:59:53.583 14317-14317/? W/System.err:     at io.dcloud.weex.MoudlesLoader.createAppMoudle(MoudlesLoader.java:86)  
2019-07-26 18:59:53.584 14317-14317/? W/System.err:     at io.dcloud.weex.MoudlesLoader.initMoudle(MoudlesLoader.java:66)  
2019-07-26 18:59:53.584 14317-14317/? W/System.err:     at io.dcloud.weex.MoudlesLoader.onCreate(MoudlesLoader.java:54)  
2019-07-26 18:59:53.585 14317-14317/? W/System.err:     at com.taobao.weex.WXSDKEngine.initialize(WXSDKEngine.java:182)  
2019-07-26 18:59:53.585 14317-14317/? W/System.err:     at io.dcloud.feature.weex.WeexInstanceMgr.initWeexEnv(WeexInstanceMgr.java:116)  
2019-07-26 18:59:53.586 14317-14317/? W/System.err:     at java.lang.reflect.Method.invoke(Native Method)  
2019-07-26 18:59:53.587 14317-14317/? W/System.err:     at io.dcloud.common.adapter.util.PlatformUtil.invokeMethod(PlatformUtil.java:863)  
2019-07-26 18:59:53.587 14317-14317/? W/System.err:     at io.dcloud.common.util.BaseInfo.initWeex(BaseInfo.java:1476)

请帮忙看看,谢谢了

该问题目前已经被锁定, 无法添加新回复