安装应用程序后,发行版本看不到应用程序类 [英] Release version doesn't see Application class after installing the app
问题描述
在调试版本中,应用程序运行正常.但是,当我生成sign apk并安装它时,在打开应用程序后-由于logcat错误,它立即崩溃:
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]].
我使用AppClass扩展MultiDexApplication,并且那里也有一些功能.我已经在清单中正确声明了该类.
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.
致谢
推荐答案
最后,我找到了一个解决方案,可以帮助我解决此问题.我必须将这部分代码添加到gradle中:
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
}
以下是您应用的一般部分build.gradle
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'
}
}
}
对于其他可能遇到类似问题的人,我指的是获得解决方案的帖子: https://stackoverflow.com/a/26627133/5736917
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
这篇关于安装应用程序后,发行版本看不到应用程序类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!