gpt4 book ai didi

从输出文件夹共享调试 APK 时 Android 应用程序崩溃

转载 作者:搜寻专家 更新时间:2023-11-01 07:46:28 26 4
gpt4 key购买 nike

我正在开发一个只有一个屏幕条形码扫描的应用程序,我使用 zxing 库实现了这一点。但我的问题是,如果我使用 android studio 安装应用程序,它工作正常,但如果我从输出文件夹与蓝牙、电子邮件、Xender 等共享此 apk。应用程序已安装,但当我打开应用程序时,它会崩溃并且出现异常NoClassFoundException。

这是 Logcat:

FATAL EXCEPTION: main

    Process: com.jenex.cartracking, PID: 31223                                                                       

java.lang.RuntimeException: Unable to instantiate activity
ComponentInfo{com.jenex.cartracking/com.jenex.cartracking.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.jenex.cartracking.MainActivity" on path: DexPathList[[zip file "/data/app/com.jenex.cartracking-1/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3029)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3300)
at android.app.ActivityThread.access$1000(ActivityThread.java:211)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1705)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:6946)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.jenex.cartracking.MainActivity" on path: DexPathList[[zip file "/data/app/com.jenex.cartracking-1/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at android.app.Instrumentation.newActivity(Instrumentation.java:1094)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3019)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3300) 
at android.app.ActivityThread.access$1000(ActivityThread.java:211) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1705) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:145) 
at android.app.ActivityThread.main(ActivityThread.java:6946) 
at java.lang.reflect.Method.invoke(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:372) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199) 
Suppressed: java.lang.ClassNotFoundException: com.jenex.cartracking.MainActivity
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 13 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available

最佳答案

您必须先清理构建,然后才能共享应用并进行调试构建。

按照这个简单的步骤,

  1. Goto Build -> Clean Project
  2. Goto Build -> Build Apk

这将生成构建 Apk。分享此 Apk。

希望这对您有所帮助。

关于从输出文件夹共享调试 APK 时 Android 应用程序崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43254615/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com