简体   繁体   English

仅在我的设备上安装APK后才发生ClassNotFoundException

[英]ClassNotFoundException only after installing APK on my device

I'm trying to get the .apk from my app. 我正在尝试从我的应用程序中获取.apk I already ran it and debugged it, and It worked just fine, but when I tried to genrate the apk file and run it on my device, the app crashes. 我已经运行并调试了它,并且工作正常,但是当我尝试生成apk文件并在我的设备上运行它时,该应用程序崩溃了。 This is the same device I've used to run and debug the app on Android Studio. 这是我用来在Android Studio上运行和调试应用程序的设备。

This is the error when I debug only the apk file: 当我仅调试apk文件时,这是错误:

I/zygote64: no shared libraies, dex_files: 1
D/AndroidRuntime: Shutting down VM
E/AndroidRuntime: FATAL EXCEPTION: main
    Process: app.com.clave, PID: 27029
    java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{app.com.appclave/app.com.appclave.SplashScreenActivity}: java.lang.ClassNotFoundException: Didn't find class "app.com.appclave.SplashScreenActivity" on path: DexPathList[[zip file "/data/app/app.com.appclave-yXmYCRL4P7N4tjj38LZxFg==/base.apk"],nativeLibraryDirectories=[/data/app/app.com.appclave-yXmYCRL4P7N4tjj38LZxFg==/lib/arm64, /system/lib64, /system/vendor/lib64]]
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2841)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3032)
        at android.app.ActivityThread.-wrap11(Unknown Source:0)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1696)
        at android.os.Handler.dispatchMessage(Handler.java:105)
        at android.os.Looper.loop(Looper.java:164)
        at android.app.ActivityThread.main(ActivityThread.java:6944)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
     Caused by: java.lang.ClassNotFoundException: Didn't find class "app.com.appclave.SplashScreenActivity" on path: DexPathList[[zip file "/data/app/app.com.appclave-yXmYCRL4P7N4tjj38LZxFg==/base.apk"],nativeLibraryDirectories=[/data/app/app.com.appclave-yXmYCRL4P7N4tjj38LZxFg==/lib/arm64, /system/lib64, /system/vendor/lib64]]
        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:93)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
        at android.app.Instrumentation.newActivity(Instrumentation.java:1180)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2831)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3032) 
        at android.app.ActivityThread.-wrap11(Unknown Source:0) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1696) 
        at android.os.Handler.dispatchMessage(Handler.java:105) 
        at android.os.Looper.loop(Looper.java:164) 
        at android.app.ActivityThread.main(ActivityThread.java:6944) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374) 
Application terminated.

Also I found sometimes the problem is in the manifest.xml file but I already checked and my activity is there: 我也发现有时问题出在manifest.xml文件中,但是我已经检查过了,我的活动在那里:

    <activity
            android:name=".SplashScreenActivity"
            android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name=".BienvenidaActivity" />
        <activity android:name=".infoAppActivity" />
        <activity android:name=".dudaActivity" />
        <activity android:name=".ActivationActivity" />
        <activity android:name=".TokenCodeActivity" />
        <activity android:name=".informationApp" />
        <activity android:name=".NextTokenCodeActivity" />
        <activity android:name=".Main"></activity>
    </application>
</manifest>

I had this problem once, specifically on API 26 (Android Oreo) because there are profiles in your device. 我曾经有这个问题,特别是在API 26(Android Oreo)上,因为您的设备中有配置文件。 The problem was that when you uninstall the first app, Android only uninstalled for the current user/profile. 问题在于,当您卸载第一个应用程序时,Android仅针对当前用户/配置文件进行了卸载。

The thing you should do is to remove the first application for all users. 您应该做的是为所有用户删除第一个应用程序。

Uninstall for all users 为所有用户卸载

and that's it. 就是这样。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM