无法访问“androidx.activity.result.ActivityResultCaller" [英] Cannot access 'androidx.activity.result.ActivityResultCaller'

查看:29
本文介绍了无法访问“androidx.activity.result.ActivityResultCaller"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 androidx 有一段时间了,我的 Android 项目编译得很好,但是最近我的 Android Studio 为所有 Activity 类抛出了大量红色

I'm using androidx for quite a while and my Android project compiles fine, however recently my Android Studio throws tons of red for all Activity classes

因为

无法访问androidx.activity.result.ActivityResultCaller",它是...的超类型

我用

AppCompatActivity 来自 androidx.appcompat:appcompat:1.1.0

我的build.gradle有:

    ext.kotlin_version = '1.3.71'
    ...
    dependencies {
        classpath 'com.android.tools.build:gradle:3.6.3'
        classpath 'com.google.gms:google-services:4.3.3'

gradle 版本distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip

我的gradle.properties:

android.useAndroidX=true
android.enableJetifier=true
org.gradle.jvmargs=-Xmx4608m
org.gradle.parallel=true

# Use kapt in parallel
kapt.use.worker.api=true

# Kapt compile avoidance
kapt.include.compile.classpath=false

推荐答案

出现这种情况是因为 Gradle 在解析依赖库版本时将 androidx.core:core 升级到 1.2.0 以上的版本,可能是1.3.0-beta01 或 1.3.0-rc01

This happened because of Gradle when resolving dependency libraries versions upgraded androidx.core:core to version more than 1.2.0, probably to 1.3.0-beta01 or 1.3.0-rc01

AppCompatActivity 扩展 FragmentActivity扩展 ComponentActivity扩展 androidx.core.app.ComponentActivity实现 ActivityResultCaller仅在 androidx.activity:activity:1.2.0-alpha03 中引入.

AppCompatActivity extends FragmentActivity that extends ComponentActivity that extends androidx.core.app.ComponentActivity that implements ActivityResultCaller introduced in androidx.activity:activity:1.2.0-alpha03 only.

要解决此问题,请将此依赖项添加到您的模块 build.gradle:

To resolve this issue add this dependency to your module build.gradle:

dependencies {
      implementation "androidx.activity:activity-ktx:1.2.0-alpha03"
}

这篇关于无法访问“androidx.activity.result.ActivityResultCaller"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆