无法验证 dex 文件

无法验证 dex 文件

生成了一个签名的 apk 但每次都会强制关闭,但我可以从 android studio 运行该应用程序。请告诉我解决方案,这是代码。

time: 1568046689417
device fp:xiaomi/whyred/whyred:9/PKQ1.180904.001/9.8.1:user/release-keys
product board:sdm660
descendant vers:4.0.0
msg: java.lang.ClassNotFoundException: Didn't find class "ptl.sky_winner.MyApplication" on path: DexPathList[[zip file "/system/framework/org.apache.http.legacy.boot.jar", zip file "/data/app/ptl.sky_winner-OeCyI4HMA8AcXS6214JQhA==/base.apk"],nativeLibraryDirectories=[/data/app/ptl.sky_winner-OeCyI4HMA8AcXS6214JQhA==/lib/arm64, /data/app/ptl.sky_winner-OeCyI4HMA8AcXS6214JQhA==/base.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64]]
stacktrace: java.lang.RuntimeException: Unable to instantiate application ptl.sky_winner.MyApplication: java.lang.ClassNotFoundException: Didn't find class "ptl.sky_winner.MyApplication" on path: DexPathList[[zip file "/system/framework/org.apache.http.legacy.boot.jar", zip file "/data/app/ptl.sky_winner-OeCyI4HMA8AcXS6214JQhA==/base.apk"],nativeLibraryDirectories=[/data/app/ptl.sky_winner-OeCyI4HMA8AcXS6214JQhA==/lib/arm64, /data/app/ptl.sky_winner-OeCyI4HMA8AcXS6214JQhA==/base.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64]]
    at android.app.LoadedApk.makeApplication(LoadedApk.java:1069)
    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5903)
    at android.app.ActivityThread.access$1100(ActivityThread.java:201)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1657)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loop(Looper.java:193)
    at android.app.ActivityThread.main(ActivityThread.java:6739)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:495)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: java.lang.ClassNotFoundException: Didn't find class "ptl.sky_winner.MyApplication" on path: DexPathList[[zip file "/system/framework/org.apache.http.legacy.boot.jar", zip file "/data/app/ptl.sky_winner-OeCyI4HMA8AcXS6214JQhA==/base.apk"],nativeLibraryDirectories=[/data/app/ptl.sky_winner-OeCyI4HMA8AcXS6214JQhA==/lib/arm64, /data/app/ptl.sky_winner-OeCyI4HMA8AcXS6214JQhA==/base.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64]]
    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
    at android.app.AppComponentFactory.instantiateApplication(AppComponentFactory.java:50)
    at android.app.Instrumentation.newApplication(Instrumentation.java:1120)
    at android.app.LoadedApk.makeApplication(LoadedApk.java:1061)
    ... 9 more
    Suppressed: java.io.IOException: Failed to open dex files from /data/app/ptl.sky_winner-OeCyI4HMA8AcXS6214JQhA==/base.apk because: Failure to verify dex file '/data/app/ptl.sky_winner-OeCyI4HMA8AcXS6214JQhA==/base.apk': Method 31218(Lcom/google/android/gms/common/api/internal/zzcl;.a) is marked constructor, but doesn't match name
        at dalvik.system.DexFile.openDexFileNative(Native Method)
        at dalvik.system.DexFile.openDexFile(DexFile.java:354)
        at dalvik.system.DexFile.<init>(DexFile.java:101)
        at dalvik.system.DexFile.<init>(DexFile.java:75)
        at dalvik.system.DexPathList.loadDexFile(DexPathList.java:394)
        at dalvik.system.DexPathList.makeDexElements(DexPathList.java:354)
        at dalvik.system.DexPathList.<init>(DexPathList.java:164)
        at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:74)
        at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:65)
        at dalvik.system.PathClassLoader.<init>(PathClassLoader.java:64)
        at com.android.internal.os.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:73)
        at com.android.internal.os.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:88)
        at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:74)
        at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:40)
        at android.app.LoadedApk.createOrUpdateClassLoaderLocked(LoadedApk.java:727)
        at android.app.LoadedApk.getClassLoader(LoadedApk.java:810)
        at android.app.LoadedApk.getResources(LoadedApk.java:1032)
        at android.app.ContextImpl.createAppContext(ContextImpl.java:2345)
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5801)
        ... 8 more




答案1

我用com.android.tools.build:gradle:3.1.1

这个问题也碰到过,解决方法如下:

  • 升级com.android.tools.build:gradle:3.1.1最新版本3.4.0及以上

  • 为了gradle.properties关闭 D8,android.enableD8=false

相关内容