1
- 发布:2022-09-27 14:17
- 更新:2022-09-27 14:28
- 阅读:820
产品分类: 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
操作步骤:
预期结果:
屏幕显示提示:哈哈哈 成功了 ,日志打印:哈哈哈 成功了
屏幕显示提示:哈哈哈 成功了 ,日志打印:哈哈哈 成功了
实际结果:
两者都没出现,且提示类找不到
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)
两者都没出现,且提示类找不到
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);
}
}
1 个回复
来盘芋头丸 (作者) - Android原生JS PHP 都会点
日志