为什么我得到“无法访问viewModelProviderFactory .. AppCompatActivity检查模块类路径是否缺少或冲突的依赖关系”

时间:2020-06-04 15:33:16

标签: android android-viewmodel

我刚刚将以下依赖项添加到当前的Android应用程序中

implementation "androidx.activity:activity-ktx:1.1.0"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0"
implementation "androidx.lifecycle:lifecycle-extensions:2.2.0"
implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.2.0"

现在下面的代码显示了一个皮棉错误

    fun myMethod(activity: AppCompatActivity) {

...

          activity.startActivity(upIntent)
    }

如图所示

enter image description here

我已清除缓存并重新启动了AS,但是问题仍然存在

我正在使用此版本的AS

Android Studio 4.0
Build #AI-193.6911.18.40.6514223, built on May 20, 2020
Runtime version: 1.8.0_242-release-1644-b3-6222593 x86_64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
macOS 10.14.6
GC: ParNew, ConcurrentMarkSweep
Memory: 1981M
Cores: 8
Registry: ide.new.welcome.screen.force=true, debugger.watches.in.variables=false
Non-Bundled Plugins: org.jetbrains.kotlin, com.intellij.marketplace, google-sceneform-tools, wu.seal.tool.jsontokotlin

我的项目gradle类似于:-

buildscript {
    ext.kotlin_version = "1.3.72"
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:4.0.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

0 个答案:

没有答案