gradle插件3.4.2和proguard是否存在问题?

时间:2019-07-10 22:24:22

标签: android gradle proguard android-multidex android-gradle-3.4.0

我将Gradle版本更新为5.1.1,并将Gradle插件更新为3.4.2。我们使用ProGuard构建应用程序,但现在找不到来自MultidexApplication的扩展类。但是,如果我们使用Gradle Plugin 3.4.0来构建应用程序,它将起作用。

  • 我们尝试清理项目。

  • 添加了multidex-config.pro并指定了我们要保留的类:

    发布{             multiDexKeepProguard文件('multidex-config.pro')             收缩资源true             minifyEnabled是             proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'),'proguard-rules.pro'         }

  • 我们正在使用Java版本8,并在gradle应用程序文件中实现了这一点:

    compileOptions {         sourceCompatibility JavaVersion.VERSION_1_8         targetCompatibility JavaVersion.VERSION_1_8 }

  • 我们在MultidexApplication类中安装multidex:

    覆盖乐趣attachBaseContext(base:Context?){         super.attachBaseContext(base)         MultiDex.install(this) }

这是我在multidex-config.pro中拥有的:

-keep class com.zubut.ZubutApp

即使在proguard-rules.pro中,我也拥有它:

-keep class com.zubut.ZubutApp

但是我提到过,它不适用于gradle插件3.4.2,但它适用于3.4.0。

这是我们得到的错误:

java.lang.RuntimeException: Unable to instantiate application com.zubut.ZubutApp: java.lang.ClassNotFoundException: Didn't find class "com.zubut.ZubutApp" on path: DexPathList[[zip file "/data/app/com.zubut.dev-RXmIrnT18sm7SZeIWglEAA==/base.apk"],nativeLibraryDirectories=[/data/app/com.zubut.dev-RXmIrnT18sm7SZeIWglEAA==/lib/arm64, /data/app/com.zubut.dev-RXmIrnT18sm7SZeIWglEAA==/base.apk!/lib/arm64-v8a, /system/lib64, /system/vendor/lib64]]
                         E      at android.app.LoadedApk.makeApplication(LoadedApk.java:979)
                         E      at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6036)
                         E      at android.app.ActivityThread.-wrap1(Unknown Source:0)
                         E      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1764)
                         E      at android.os.Handler.dispatchMessage(Handler.java:105)
                         E      at android.os.Looper.loop(Looper.java:164)
                         E      at android.app.ActivityThread.main(ActivityThread.java:6944)
                         E      at java.lang.reflect.Method.invoke(Native Method)
                         E      at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
                         E      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
                         E  Caused by: java.lang.ClassNotFoundException: Didn't find class "com.zubut.ZubutApp" on path: DexPathList[[zip file "/data/app/com.zubut.dev-RXmIrnT18sm7SZeIWglEAA==/base.apk"],nativeLibraryDirectories=[/data/app/com.zubut.dev-RXmIrnT18sm7SZeIWglEAA==/lib/arm64, /data/app/com.zubut.dev-RXmIrnT18sm7SZeIWglEAA==/base.apk!/lib/arm64-v8a, /system/lib64, /system/vendor/lib64]]
                         E      at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:93)
                         E      at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
                         E      at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
                         E      at android.app.Instrumentation.newApplication(Instrumentation.java:1093)
                         E      at android.app.LoadedApk.makeApplication(LoadedApk.java:973)
                         E      ... 9 more
                         E      Suppressed: java.io.IOException: Failed to open dex files from /data/app/com.zubut.dev-RXmIrnT18sm7SZeIWglEAA==/base.apk because: Failure to verify dex file '/data/app/com.zubut.dev-RXmIrnT18sm7SZeIWglEAA==/base.apk': Out-of-order field_ids
                         E          at dalvik.system.DexFile.openDexFileNative(Native Method)
                         E          at dalvik.system.DexFile.openDexFile(DexFile.java:353)
                         E          at dalvik.system.DexFile.<init>(DexFile.java:100)
                         E          at dalvik.system.DexFile.<init>(DexFile.java:74)
                         E          at dalvik.system.DexPathList.loadDexFile(DexPathList.java:374)
                         E          at dalvik.system.DexPathList.makeDexElements(DexPathList.java:337)
                         E          at dalvik.system.DexPathList.<init>(DexPathList.java:157)
                         E          at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:65)
                         E          at dalvik.system.PathClassLoader.<init>(PathClassLoader.java:64)
                         E          at com.android.internal.os.PathClassLoaderFactory.createClassLoader(PathClassLoaderFactory.java:43)
                         E          at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:69)
                         E          at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:36)
                         E          at android.app.LoadedApk.createOrUpdateClassLoaderLocked(LoadedApk.java:678)
                         E          at android.app.LoadedApk.getClassLoader(LoadedApk.java:711)
                         E          at android.app.LoadedApk.getResources(LoadedApk.java:944)
                         E          at android.app.ContextImpl.createAppContext(ContextImpl.java:2303)
                         E          at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5943)
                         E          ... 8 more

0 个答案:

没有答案