Upgrading target sdk to 29 on React Native 0.59

Viewed 2033

My current android target sdk on React Native is 28, but Play Store is showing to update it to 29. So I made the following changes in android/build.gradle

buildscript {

    ext {
       googlePlayServicesVersion = "16.0.0"
        firebaseVersion = "17.3.4"
        buildToolsVersion = "28.0.3" //changed to 29.0.3
        minSdkVersion = 16
        compileSdkVersion = 28 //changed to 29
        targetSdkVersion = 28 // changed to 29
        supportLibVersion = "28.0.0"
    }
}

But now when I run npx react-native run-android I get the following error.

Could not resolve all files for configuration ':app:debugCompileClasspath'.
> Could not find com.android.support:support-v4:29.0.0.
  Required by:
      project :app
      project :app > project :react-native-firebase
> Could not find com.android.support:support-v4:29.0.0.
  Required by:
      project :app > com.google.android.gms:play-services-basement:16.2.0

I am using react-native-firebase v5

1 Answers

Follow the below steps :-

  • Open android/build.gradle in your React Native project.
  • Then increment the compileSdkVersion and targetSdkVersion values to 29.

In android/build.gradle

   buildscript {
       ext {
           buildToolsVersion = "28.0.3"
           minSdkVersion = 16
           compileSdkVersion = 29
           targetSdkVersion = 29
       }
       // ...
   }

   allprojects {
    // ...
   }
  • Then in Android Studio, Run "Sync Project with Gradle Files" (File > Sync Project with Gradle Files).

And you should be all set.

Related