Could not find androidx.appcompat:appcompat:28.0.0

Viewed 5302

I updated compileSDkversion from 27 to 28.

Added in gradle.properties file:

android.useAndroidX=true
android.enableJetifier=true

in build gradle added:

implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.core:core:1.0.2'

Refactored support libraries to androidX libraries in build.gradle.

I'm getting a build error:

Could not find androidx.appcompat:appcompat:28.0.0

What is the problem? What else should I change?

P.S: this is expoKit react-native project

2 Answers

In my case the issue was regarding some of the dependencies, which were using supportLibVersion property to resolve the android.support dependency.

Short:

Check your project's build.gradle and see if your supportLibVersion has as value 28.0.0 and set it to the value you need, which seems to be 1.0.2.

buildscript {
    ext {
        buildToolsVersion =
        minSdkVersion =
        compileSdkVersion =
        targetSdkVersion =
        supportLibVersion = "1.0.2" <---- here
    }

Long:

For example, one of my dependencies stated this dependency:

"com.android.support:appcompat-v7:${safeExtGet('supportLibVersion', '28.0.0')}"

My supportLibVersion property was still set to 28.0.0 for the old support version.

My guess is that Jetifier, which is used to translate the dependencies to AndroidX, replaces the 'com.android.support:appcompat-v7' part with well, but if the dependecy states the version of the library with the supportLibVersion property, the resolution of the translation will use that value, so it will end up trying to find androidx.appcompat:appcompat:28.0.0 which doesn't exist.

I found really helpful the AndroidX migration table to understand how Jetifier translates.

Hope it helps!

I just have found a solution.

I used in Android Studio: Refactor -> Migrate to AndroidX.

It solved my problem!

Related