Skip to content Skip to sidebar Skip to footer

Cannot Access 'androidx.activity.result.activityresultcaller'

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 acces

Solution 1:

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 modulebuild.gradle:

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

Solution 2:

In my case, turns out I had conflicting androidx.activity:activity-ktx gradle dependencies between my core/base and app module.

In addition to ActivityResultCaller, mine was throwing an issue with ActivityResultRegistryOwner.

For me, removing the dependency from the app module, pushing the core module dependency to androidx.activity:activity-ktx:1.2.0-alpha04 and bumping implementation "androidx.core:core-ktx:1.3.0 > 1.3.1 solved both issues.

I also have an androidx.appcompat:appcompat:1.3.0-alpha01 dependency in core, which I kept, but it seems removing it has no effect.

Solution 3:

In my case, I needed to remove implementation 'androidx.appcompat:appcompat:1.3.0-alpha01' while keeping implementation "androidx.core:core-ktx:1.3.1"

Post a Comment for "Cannot Access 'androidx.activity.result.activityresultcaller'"