Upgrading Android Project to v3.8
Starting from version 3.8, the Android project generated by the build supports the new version of Android Studio (Flamingo | 2022.2.1) by default. Due to the requirement of the Android Gradle plugin , developers need to upgrade their JDK to version 17 and also upgrade Android Studio to the Flamingo version.
If the Android project generated by the build is not configured, you can directly delete the
native/engine/android
directory andbuild/android
directory, and then rebuild it. This avoids the need for step-by-step modifications and upgrades to the project. However, please note that this step is risky, and developers need to understand the consequences.
For existing native Android projects, developers can follow the steps below to upgrade their projects:
Step 1: Backup the Current Project
Before proceeding with the upgrade, it is important to backup the current native directory in case of any issues. For example, you can use Git to save the current modifications.
Step 2: Upgrade Gradle Plugin Version
The Gradle plugin version acts as the interface between Gradle and the Android build system. Therefore, before upgrading Gradle, we need to upgrade the Gradle plugin version. In the project's
native/engine/android/build.gradle
file, change the Gradle plugin version in the classpath to 8.0.2.
Step 3: Update Package Field
Remove the package attribute from the
native/engine/android/app/AndroidManifest.xml
file.
Based on the diff file below, edit
native/engine/android/app/build.gradle
and change
applicationId
to
namespace
.
Step 4: Upgrade Gradle Version
Next, we need to upgrade the Gradle wrapper version. In the project's
build/android/proj/gradle/wrapper/gradle-wrapper.properties
file, change the distributionUrl to 8.0.2 as shown below:
Step 5: Update Proguard Rules
Add the following code to file
native/engine/android/app/proguard-rules.pro