I’m working on a React Native project and need to update the compileSdkVersion and targetSdkVersion from 33 to 34. Below are the current configurations from my build.gradle files and gradle-wrapper.properties:
android/build.gradle
buildscript {
ext {
buildToolsVersion = "31.0.0"
minSdkVersion = 24
compileSdkVersion = 34
targetSdkVersion = 34
firebaseMessagingVersion = "21.1.0"
androidXCore = "1.6.0"
ndkVersion = "21.4.7075529"
}
repositories {
.....
}
dependencies {
classpath('com.android.tools.build:gradle:4.1.3')
classpath 'com.google.gms:google-services:4.3.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
gradle-wrapper.properties:
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https://services.gradle.org/distributions/gradle-6.7.1-bin.zip
Environment:
React Native version: 0.63.5
NDK Version: 21.4.7075529
What I’ve Tried:
- I attempted to directly change compileSdkVersion and targetSdkVersion to 34, but I ran into this build error related to the AAPT2 tool. Here’s the error :
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processDebugResources'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> AAPT2 aapt2-4.1.3-6503028-windows Daemon #0: Unexpected error during link, attempting to stop daemon.
This should not happen under normal circumstances, please file an issue if it does.
- I tried upgrading the Gradle wrapper to a newer version (e.g., distributionUrl=https://services.gradle.org/distributions/gradle-7.0-all.zip), but that resulted in compatibility issues with my current setup.
- I considered updating the Android Gradle Plugin (classpath ‘com.android.tools.build:gradle:4.1.3’), but I’m unsure of the correct version that would work with my existing dependencies and whether this would resolve the issue.
Question:
What is the best approach to update the compileSdkVersion and targetSdkVersion from 33 to 34 in my React Native project while ensuring compatibility with my current build setup? Specifically, I would like guidance on:
- Whether I need to upgrade the buildToolsVersion, Gradle version, or any other dependencies to support SDK 34.
- What changes, if any, are required for the firebaseMessagingVersion, androidXCore, or any other dependencies to avoid build errors.
3.Any other steps I should take to ensure a smooth upgrade process without introducing new build issues. - If the this SDK upgrade can be done without upgrading react native.
Thank you in advance for your assistance!