6

I am moving to androidX but I receive:

Could not find androidx.appcompat:appcompat:1.0.2.
Required by:
    project :app > com.facebook.react:react-native:0.60.4 

My project gradle.build:

buildscript {
    repositories {
        maven { url 'https://maven.google.com' }
        jcenter()
    }
    dependencies {
       ...
    }
}


allprojects {
    repositories {
        mavenLocal()
        jcenter()
        maven {
            url "https://jitpack.io"
        }
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url "$rootDir/../node_modules/react-native/android"
        }
    }
}

It seems like I am missing another source. Any suggestions?

dan0
  • 61
  • 1
  • 2

2 Answers2

4

AndroidX dependencies are available in Google's Maven Repository, which you haven't added under allprojects -> repositories in your project build.gradle.

Insert google() in allprojects -> repositories before everything else.
You can also replace maven { url 'https://maven.google.com' } with google() in buildscript -> repositories.

So it should look like this:

buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
       ...
    }
}

allprojects {
    repositories {
        google()
        mavenLocal()
        jcenter()
        maven {
            url "https://jitpack.io"
        }
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url "$rootDir/../node_modules/react-native/android"
        }
    }
}

Sync your project after making these changes and it should work.

ElegyD
  • 4,393
  • 3
  • 21
  • 37
1

From ReactNative version 0.60, it supports AndroidX. So you need to add AndroidX dependency also.

Add below dependency into your app/build.gradle file:

dependencies {
    implementation 'androidx.appcompat:appcompat:1.0.2'
}

Make sure that you have added this line in your gradle.properties file:

android.enableJetifier=true
android.useAndroidX=true
Birju Vachhani
  • 6,072
  • 4
  • 21
  • 43