gpt4 book ai didi

android - adb shell 我开始给出 ClassNotFoundException

转载 作者:行者123 更新时间:2023-11-30 00:23:45 25 4
gpt4 key购买 nike

我正在尝试通过 adb 命令启动 apk,安装 apk 后不久,但我收到 ClassNotFoundException 并且应用程序崩溃。

我的日志:

java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.sample.test.one/com.sample.test.one.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.sample.test.one.MainActivity" on path: DexPathList[[zip file "/data/app/com.sample.test.one-1/base.apk"],nativeLibraryDirectories=[/data/app/com.sample.test.one-1/lib/arm, /system/lib, /vendor/lib]]
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2849)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3045)
at android.app.ActivityThread.-wrap14(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1642)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6776)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1518)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1408)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.sample.test.one.MainActivity" on path: DexPathList[[zip file "/data/app/com.sample.test.one-1/base.apk"],nativeLibraryDirectories=[/data/app/com.sample.test.one-1/lib/arm, /system/lib, /vendor/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at android.app.Instrumentation.newActivity(Instrumentation.java:1086)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2839)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3045) 
at android.app.ActivityThread.-wrap14(ActivityThread.java) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1642) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:154) 
at android.app.ActivityThread.main(ActivityThread.java:6776) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1518) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1408) 

流程:

adb install test.apk

adb shell am start -n com.sample.test.one/com.sample.test.one.MainActivity

or

adb shell am start -a android.intent.action.Main -n com.sample.test.one/.MainActivity

我正在尝试上面的 adb shell 命令 但应用程序无法启动但我观察到的一种情况是,如果我将在 Android Studio 中运行代码并且应用程序安装在设备中,然后如果我会尝试“adb shell am start”命令然后它工作正常,但如果我尝试通过“adb install apk”然后这个命令不起作用。

最佳答案

我曾经遇到过这种情况,但是在将 MultiDex 添加到我的 gradle 之后,一切都很好。

第一步

defaultConfig {
minSdkVersion minVersion+
targetSdkVersion targetVersion+

multiDexEnabled true
}

dexOptions {
incremental true
javaMaxHeapSize "4g"
}

第 2 步

添加渐变

compile 'com.android.support:multidex:1.0.0'

第 3 步 更改 gradle 属性

org.gradle.jvmargs=-Xmx4096m

请试试这个技巧。

关于android - adb shell 我开始给出 ClassNotFoundException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45797928/

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