在React Native 0.59上将目标SDK升级到29

时间:2020-08-09 05:36:34

标签: android firebase react-native sdk react-native-firebase

我当前在React Native上的android目标sdk是28,但是Play商店正在显示将其更新为29。 所以我在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"
    }
}

但是现在当我运行npx react-native run-android时,出现以下错误。

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

我正在使用react-native-firebase v5

1 个答案:

答案 0 :(得分:0)

请按照以下步骤操作:-

  • 在您的 React Native 项目中打开 android/build.gradle
  • 然后增加 compileSdkVersiontargetSdkVersion29
<块引用>

android/build.gradle

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

   allprojects {
    // ...
   }
  • 然后在 Android Studio 中,运行“将项目与 Gradle 文件同步”(File > Sync Project with Gradle Files)。

你应该准备好了。