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`.
This commit is contained in:
Robert Müller 2024-05-08 12:44:53 +02:00
parent cdbe1f775a
commit 664b0e98bb
3 changed files with 20 additions and 12 deletions

View file

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="tw.DDNet">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-feature
android:glEsVersion="0x00030000" />
<uses-feature
@ -21,7 +20,6 @@
android:usesCleartextTraffic="true"
android:label="@string/app_name"
android:hasCode="true"
android:extractNativeLibs="true"
android:supportsRtl="true"
android:isGame="true"
android:icon="@mipmap/ic_launcher"
@ -29,16 +27,16 @@
android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
<activity
android:name=".NativeMain"
android:exported="true"
android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"
android:screenOrientation="landscape">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<meta-data android:name="android.app.lib_name"
<meta-data
android:name="android.app.lib_name"
android:value="DDNet" />
</activity>
</application>
</manifest>

View file

@ -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']

View file

@ -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