Release version doesn't see Application class after installing the app

扶醉桌前 提交于 2020-01-24 21:58:05

问题


In a debug version app works fine. But when I generate sign apk and install this, after open app - it immediately crashes due to a logcat error:

 Caused by: java.lang.ClassNotFoundException: Didn't find class "com.mypackage.AppClass" on path: DexPathList[[zip file "/data/app/com.mypackage-1/base.apk"],nativeLibraryDirectories=[/vendor/lib64, /system/lib64]].

I use AppClass to extends MultiDexApplication and I've got there some functions also. I have declared this class correctly in a manifest.

The most complicated is that it works in a debug version but only in release version this problem occurs.

I would be really grateful if someone could help me to resolve this situation.

Regards


回答1:


Check this options:

Option 1: decrease your gradle version

Option 2: minifyEnabled false

Option 3: use stable support library and build tools.

Option 4: Invalidate caches/restart, file->invalidate caches/restart

Option 5: If you are using private platform libraries, make sure your non-NDK libraries with your APK.




回答2:


Finally, I found a solution which helped me to resolve this problem. I had to add this part of code in a gradle:

  dexOptions {
      preDexLibraries = false
   }

And the following to the general part of your apps build.gradle

afterEvaluate {
   tasks.matching {
      it.name.startsWith('dex')
   }.each { dx ->
      if (dx.additionalParameters == null) {
         dx.additionalParameters = ['--multi-dex']
      } else {
         dx.additionalParameters += '--multi-dex'
      }
   }
}

For the others who can have similar issue I'm referring to a post in which I obtained a solution: https://stackoverflow.com/a/26627133/5736917



来源:https://stackoverflow.com/questions/48330215/release-version-doesnt-see-application-class-after-installing-the-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!