爆款云服务器低至4折,1核1G¥366/

环境说明

  • 手机型号:realme x、oppo 手机
  • Android Studio 版本 3.2 和 3.4 都有此问题,其它版本未测试。
  • Cocos creator 2.x
  • Windwos 10

问题出现

在 cocos creator 构建、编译后,在 cocos creator 上点击 `运行 可以在手机上运行。在 Android Studio 上 Build 生成 apk 后,再安装到手机上也没有问题。但是使用 Android Studio 点击 Run 调试时安装后打开直接闪退(模拟器、手机),错误信息主要是说类 java.lang.ClassNotFoundException: Didn't find class "org.cocos2dx.javascript.AppActivity" 找不到。

E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.nideshop.admin, PID: 2364
    java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.nideshop.admin/org.cocos2dx.javascript.AppActivity}: java.lang.ClassNotFoundException: Didn't find class "org.cocos2dx.javascript.AppActivity" on path: DexPathList[[zip file "/data/app/com.nideshop.admin-eg5wX9EySQ9B1q18bTk7mQ==/base.apk"],nativeLibraryDirectories=[/data/app/com.nideshop.admin-eg5wX9EySQ9B1q18bTk7mQ==/lib/arm, /data/app/com.nideshop.admin-eg5wX9EySQ9B1q18bTk7mQ==/base.apk!/lib/armeabi-v7a, /system/lib]]
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3051)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3289)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2012)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:227)
        at android.app.ActivityThread.main(ActivityThread.java:7200)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:575)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:903)
     Caused by: java.lang.ClassNotFoundException: Didn't find class "org.cocos2dx.javascript.AppActivity" on path: DexPathList
...

解决方法

取消 Android Studio 的 Instant Run 选项
关闭InstantRun.png

参考链接: https://blog.csdn.net/iblade/article/details/83150728

标签: Android