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

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

问题描述

我使用 androidx 已有一段时间,并且我的Android项目可以正常编译,但是最近我的Android Studio对所有Activity类都抛出了很多红色

,因为

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

我用

来自 androidx.appcompat:appcompat:1.1.0

AppCompatActivity

我的 build.gradle 具有:

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

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

我的 gradle.properties :

  android.useAndroidX = trueandroid.enableJetifier = trueorg.gradle.jvmargs = -Xmx4608morg.gradle.parallel = true#并行使用kaptkapt.use.worker.api = true#Kapt避免编译kapt.include.compile.classpath = false 

解决方案

之所以发生此问题,是因为在解析依赖库版本时将Gradle升级到 androidx.core:core 到高于1.2.0的版本.1.3.0-beta01或1.3.0-rc01

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

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

 依赖项{实现"androidx.activity:activity-ktx:1.2.0-alpha03"} 

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

because of

cannot access 'androidx.activity.result.ActivityResultCaller' which is a supertype of ...

I use

AppCompatActivity from androidx.appcompat:appcompat:1.1.0

My build.gradle has:

    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'

And gradle version distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip

My 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

解决方案

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 extends FragmentActivity that extends ComponentActivity that extends androidx.core.app.ComponentActivity that implements ActivityResultCaller introduced in androidx.activity:activity:1.2.0-alpha03 only.

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天全站免登陆