来盘芋头丸
来盘芋头丸
  • 发布:2022-09-27 14:17
  • 更新:2022-09-27 14:28
  • 阅读:596

【报Bug】安卓原生插件 在UniAppHookProxy 已经执行了初始化的MMkv,调用的时候提示找不到类

分类:uni-app

产品分类: uniapp/App

PC开发环境操作系统: Windows

PC开发环境操作系统版本号: 10 企业版 LTSC 21H2 19044.1288 Windows Feature Experience Pack 120.2212.3920.0

HBuilderX类型: 正式

HBuilderX版本号: 3.6.4

手机系统: Android

手机系统版本号: Android 10

手机厂商: 华为

手机机型: Nova7SE

页面类型: vue

vue版本: vue2

打包方式: 云端

项目创建方式: HBuilderX

操作步骤:

1

预期结果:

屏幕显示提示:哈哈哈 成功了 ,日志打印:哈哈哈 成功了

实际结果:

两者都没出现,且提示类找不到

2022-09-27 14:17:05.907 21559-21559/? E/AndroidRuntime: FATAL EXCEPTION: main  
    Process: com.qingting.fk, PID: 21559  
    java.lang.NoClassDefFoundError: Failed resolution of: Lcom/hjq/widget/MmkvUtil;  
        at com.example.gas.NativePageActivity.onCreate(NativePageActivity.java:37)  
        at android.app.Activity.performCreate(Activity.java:8214)  
        at android.app.Activity.performCreate(Activity.java:8202)  
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1320)  
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:4033)  
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4247)  
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:91)  
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:149)  
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:103)  
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2613)  
        at android.os.Handler.dispatchMessage(Handler.java:110)  
        at android.os.Looper.loop(Looper.java:219)  
        at android.app.ActivityThread.main(ActivityThread.java:8668)  
        at java.lang.reflect.Method.invoke(Native Method)  
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513)  
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1109)  
     Caused by: java.lang.ClassNotFoundException: com.hjq.widget.MmkvUtil  
        at com.example.gas.NativePageActivity.onCreate(NativePageActivity.java:37)   
        at android.app.Activity.performCreate(Activity.java:8214)   
        at android.app.Activity.performCreate(Activity.java:8202)   
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1320)   
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:4033)   
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4247)   
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:91)   
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:149)   
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:103)   
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2613)   
        at android.os.Handler.dispatchMessage(Handler.java:110)   
        at android.os.Looper.loop(Looper.java:219)   
        at android.app.ActivityThread.main(ActivityThread.java:8668)   
        at java.lang.reflect.Method.invoke(Native Method)   
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513)   
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1109)   

bug描述:

package.json

{  
    "name": "轮子哥框架封插件",  
    "id": "gas",  
    "version": "1.0.2",  
    "description": "轮子哥",  
    "_dp_type": "nativeplugin",  
    "_dp_nativeplugin": {  
        "android": {  
            "hooksClass": "com.example.gas.Gas_AppProxy",  
            "plugins": [{  
                "type": "module",  
                "name": "gas",  
                "class": "com.example.gas.TestModule"  
            }],  
            "integrateType": "aar",  
            "compileOptions": {  
                "sourceCompatibility": "1.8",  
                "targetCompatibility": "1.8"  
            },  
            "abis": [  
                "armeabi-v7a,arm64-v8a"  
            ],  
            "minSdkVersion": "21",  
            "useAndroidX": true,  
            "dependencies": [  
                "com.tencent:mmkv-static:1.2.10",  
                "com.github.kongzue.DialogX:DialogX:0.0.43"  
            ]  
        }  
    }  
}  

android 代码

public class Gas_AppProxy implements UniAppHookProxy {  

    private Application mApplication;  

    @Override  
    public void onSubProcessCreate(Application application) {  
        mApplication = application;  
        DebugLogUtil.getInstance().Debug("Gas_AppProxy-onSubProcessCreate");  
        init();  
    }  

    @Override  
    public void onCreate(Application application) {  
        mApplication = application;  
        DebugLogUtil.getInstance().Debug("Gas_AppProxy-onCreate");  
        init();  
    }  

    private void other() {  
        PopTip.show("是行");  
        MmkvUtil.save("test", "哈哈哈  成功了 ");  
    }  

    private void init() {  
        MMKV.initialize(mApplication);  
        DialogX.init(mApplication);  
        DialogX.implIMPLMode = DialogX.IMPL_MODE.VIEW;  
        DialogX.useHaptic = true;  
        DialogX.globalStyle = new MaterialStyle();  
        DialogX.globalTheme = DialogX.THEME.AUTO;  
        DialogX.onlyOnePopTip = false;  

        DebugLogUtil.getInstance().Debug("初始化结束");  
        other();  
    }  
}
public class NativePageActivity extends Activity {  
    @Override  
    protected void onCreate(Bundle savedInstanceState) {  
        super.onCreate(savedInstanceState);  
        FrameLayout rootView = new FrameLayout(this);  
        TextView textView = new TextView(this);  
        textView.setTextColor(Color.BLACK);  
        textView.setTextSize(30);  
        textView.setText("我是GAS插件");  
        rootView.addView(textView, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 300));  
        textView.setOnClickListener(new View.OnClickListener() {  
            @Override  
            public void onClick(View v) {  
                Intent intent = new Intent();  
                intent.putExtra("respond", "我是原生页面");  
                setResult(1001, intent);  
                finish();  
            }  
        });  

        setContentView(rootView);  

        String ss = MmkvUtil.getString("test", "");  
        DebugLogUtil.getInstance().Debug(ss);  
        PopTip.show(ss);  
    }  
}  
2022-09-27 14:17 负责人:无 分享
已邀请:
来盘芋头丸

来盘芋头丸 (作者) - Android原生JS PHP 都会点

日志

2022-09-27 14:27:09.718 27483-27535/? I/console: [WARN][JS Framework] 当前运行的基座不包含原生插件[app2],请在manifest中配置该插件,重新制作包括该原生插件的自定义运行基座  
2022-09-27 14:27:13.294 27483-27535/? I/console: [LOG]App Hide at App.vue:10  
2022-09-27 14:27:13.342 27483-27483/? D/DebugLogUtil: 调用处 ,(召唤师,我在 at (com.example.gas.NativePageActivity.java:35)->onCreate()  
2022-09-27 14:27:22.324 28208-28208/? D/DebugLogUtil: PluginApp - onSubProcessCreate  ,(召唤师,我在 at (io.dcloud.uniplugin.My_AppProxy.java:17)->onCreate()  
2022-09-27 14:27:22.325 28208-28208/? D/DebugLogUtil: Gas_AppProxy-onCreate,(召唤师,我在 at (com.example.gas.Gas_AppProxy.java:27)->onCreate()  
2022-09-27 14:27:22.328 28208-28208/? D/DebugLogUtil: 初始化结束,(召唤师,我在 at (com.example.gas.Gas_AppProxy.java:45)->init()  
2022-09-27 14:27:23.158 28208-28265/? I/console: [LOG]App Launch at App.vue:4  
2022-09-27 14:27:23.164 28208-28265/? I/console: [LOG]App Show at App.vue:7  
2022-09-27 14:27:29.525 28208-28265/? I/console: [WARN][JS Framework] 当前运行的基座不包含原生插件[app2],请在manifest中配置该插件,重新制作包括该原生插件的自定义运行基座  
2022-09-27 14:27:31.784 28208-28265/? I/console: [LOG]App Hide at App.vue:10  
2022-09-27 14:27:31.811 28208-28208/? D/DebugLogUtil: 调用处 ,(召唤师,我在 at (com.example.gas.NativePageActivity.java:35)->onCreate()

要回复问题请先登录注册