React Native Could not find com.android.support:appcompat-v7:${supportVersion}

Viewed 985

I have a React Native app I'm trying to deploy to an Android Studio's Android emulator, on Windows 10.

I run the app from an elevated Power Shell, using

react-native run-android

The Metro Bundler console opens, but the build fails with the following message:

Could not resolve all files for configuration ':react-native-audio:debugCompileClasspath'.

Could not find com.android.support:appcompat-v7:${supportVersion}. Required by: project :react-native-audio

I have:

  • React Native v0.59.10
  • Node v10.16.3
  • Android Studio v3.5
  • Gradle:

    buildToolsVersion = "28.0.3"

    minSdkVersion = 16

    compileSdkVersion = 28

    targetSdkVersion = 28

    supportLibVersion = "28.0.0"

    classpath 'com.android.tools.build:gradle:3.3.1'

I have tried changing to classpath 'com.android.tools.build:gradle:3.2.1' as per the advice from github, but that only resulted in a different error:

A problem occurred configuring project ':app'.

Could not get unknown property 'mergeResourcesProvider' for object of type com.android.build.gradle.internal.api.ApplicationVariantImpl.

2 Answers

try changing it to

 classpath 'com.android.tools.build:gradle:3.4.1'

and make sure in gradle/wrapper/gradle-wrapper.properties the version is as below

distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip

Follow this pr, converting the quotes to double quotes:

https://github.com/jsierles/react-native-audio/pull/333/files

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:appcompat-v7:${supportVersion}'
    compile 'com.facebook.react:react-native:+'
}

// change to

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile "com.android.support:appcompat-v7:${supportVersion}"
    compile 'com.facebook.react:react-native:+'
}


Related