From 664b0e98bb88938eda5571e05066dac087fe2b17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20M=C3=BCller?= Date: Wed, 8 May 2024 12:44:53 +0200 Subject: [PATCH] Upgrade Gradle and fix Android deprecation errors Upgrade to Gradle 8.5 and Gradle Plugin 8.3.0 for compatibility with Java 21. Explicity set Java version 21 in `build.gradle`. Increment compile and target SDK version to 34 accordingly. Remove the explicitly defined, obsolete `buildToolsVersion` property in `build.gradle`, as it is now automatically derived by Gradle. Replace the deprecated property `android:extractNativeLibs` in `AndroidMainfest.xml` with `useLegacyPackaging` in `build.gradle`. Replace the deprecated package definition `package="tw.DDNet"` in `AndroidMainfest.xml` with `namespace("tw.DDNet")` in `build.gradle`. Add the required property `android:exported="true"` to the main activity in `AndroidMainfest.xml`. --- scripts/android/files/AndroidManifest.xml | 10 ++++------ scripts/android/files/build.gradle | 20 ++++++++++++++----- .../android/files/gradle-wrapper.properties | 2 +- 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/scripts/android/files/AndroidManifest.xml b/scripts/android/files/AndroidManifest.xml index f63c07fa6..5c57de0f4 100644 --- a/scripts/android/files/AndroidManifest.xml +++ b/scripts/android/files/AndroidManifest.xml @@ -1,6 +1,5 @@ - + - - - diff --git a/scripts/android/files/build.gradle b/scripts/android/files/build.gradle index 417e1b23d..403dc50d1 100644 --- a/scripts/android/files/build.gradle +++ b/scripts/android/files/build.gradle @@ -10,19 +10,25 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:7.2.1' + classpath 'com.android.tools.build:gradle:8.3.0' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } +java { + toolchain { + languageVersion.set(JavaLanguageVersion.of(21)) + } +} + android { - compileSdkVersion 30 - buildToolsVersion "30.0.3" + compileSdkVersion 34 ndkVersion "TW_NDK_VERSION" defaultConfig { applicationId "tw.DDNet" + namespace("tw.DDNet") minSdkVersion 24 - targetSdkVersion 30 + targetSdkVersion 34 versionCode TW_VERSION_CODE versionName "TW_VERSION_NAME" } @@ -46,7 +52,11 @@ android { shrinkResources false } } - + packagingOptions { + jniLibs { + useLegacyPackaging = true + } + } sourceSets { main { assets.srcDirs = ['assets'] diff --git a/scripts/android/files/gradle-wrapper.properties b/scripts/android/files/gradle-wrapper.properties index aa991fcea..a59520664 100644 --- a/scripts/android/files/gradle-wrapper.properties +++ b/scripts/android/files/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists