所以我有一个项目使用了一个领域。无论我使用哪个版本的插件,我都会遇到问题。问题是找不到unable to instantiate appComponantFactory
、MultiDexApplication
类等。
当我删除领域Gradle插件并运行该应用程序时,该应用程序完美运行,没有任何问题,比如类没有发现异常。
我在网上搜索了一下,没有人发布这件事。顺便说一句,该项目使用Kotlin(我不确定它是否会对领域插件产生问题(
除了使用realm Gradle插件之外,还有其他选项可以在我的应用程序中添加realm吗?
尝试在app/build.gradle
文件中添加multiDexEnabled true
。
像这样:
android {
compileSdkVersion 29
defaultConfig {
applicationId "ur.app.package"
multiDexEnabled true // <<-- add this
//....all other stuff
}
//all other stuff
}
(1(请在您的app/build.gradle文件中添加implementation 'androidx.multidex:multidex:2.0.1'
(2( 添加应用程序类并将其添加到清单文件中
class ApplicationClass : MultiDexApplication() {
override fun onCreate() {
super.onCreate()
MultiDex.install(this)
mInstance = this
val builder = VmPolicy.Builder()
StrictMode.setVmPolicy(builder.build())
val policy = StrictMode.ThreadPolicy.Builder().permitAll().build()
StrictMode.setThreadPolicy(policy)
}
companion object {
private var mInstance: ApplicationClass? = null
}}
(3( 将应用程序类添加到清单文件的标记中
<application
android:name=".utils.ApplicationClass" </application>