From aa645fe67c886538373bff21486e213de72787a6 Mon Sep 17 00:00:00 2001 From: Anuken Date: Sat, 6 Jul 2024 14:57:49 -0400 Subject: [PATCH] Updated Gradle and AGP to 8 --- android/build.gradle | 13 ++++++++----- android/proguard-rules.pro | 5 +++-- android/src/mindustry/android/AndroidLauncher.java | 2 ++ gradle.properties | 1 + gradle/wrapper/gradle-wrapper.properties | 2 +- 5 files changed, 15 insertions(+), 8 deletions(-) diff --git a/android/build.gradle b/android/build.gradle index f7f1ce377b..e73cace96d 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -7,7 +7,7 @@ buildscript{ } dependencies{ - classpath 'com.android.tools.build:gradle:7.2.1' + classpath 'com.android.tools.build:gradle:8.5.0' } } @@ -29,8 +29,9 @@ task deploy(type: Copy){ } android{ - buildToolsVersion '33.0.2' - compileSdkVersion 33 + namespace = "io.anuke.mindustry" + buildToolsVersion = '34.0.0' + compileSdk = 34 sourceSets{ main{ manifest.srcFile 'AndroidManifest.xml' @@ -56,7 +57,7 @@ android{ applicationId "io.anuke.mindustry" minSdkVersion 14 - targetSdkVersion 33 + targetSdkVersion 34 versionName versionNameResult versionCode = vcode @@ -65,6 +66,8 @@ android{ props['androidBuildCode'] = (vcode + 1).toString() } props.store(file('../core/assets/version.properties').newWriter(), null) + + multiDexEnabled true } compileOptions{ @@ -72,7 +75,7 @@ android{ targetCompatibility JavaVersion.VERSION_1_8 } - flavorDimensions "google" + flavorDimensions = ["google"] signingConfigs{ release{ diff --git a/android/proguard-rules.pro b/android/proguard-rules.pro index 368b7f4e1e..ebda968ae6 100644 --- a/android/proguard-rules.pro +++ b/android/proguard-rules.pro @@ -1,11 +1,12 @@ -dontobfuscate -#these are essential packages that should not be "optimized" in any way -#the main purpose of d8 here is to shrink the absurdly-large google play games libraries -keep class mindustry.** { *; } -keep class arc.** { *; } -keep class net.jpountz.** { *; } -keep class rhino.** { *; } -keep class com.android.dex.** { *; } +-keepattributes Signature,*Annotation*,InnerClasses,EnclosingMethod + +-dontwarn javax.naming.** #-printusage out.txt \ No newline at end of file diff --git a/android/src/mindustry/android/AndroidLauncher.java b/android/src/mindustry/android/AndroidLauncher.java index fdb8a4ec56..c8175aa4f0 100644 --- a/android/src/mindustry/android/AndroidLauncher.java +++ b/android/src/mindustry/android/AndroidLauncher.java @@ -72,6 +72,8 @@ public class AndroidLauncher extends AndroidApplication{ @Override public ClassLoader loadJar(Fi jar, ClassLoader parent) throws Exception{ + //Required to load jar files in Android 14: https://developer.android.com/about/versions/14/behavior-changes-14#safer-dynamic-code-loading + jar.file().setReadOnly(); return new DexClassLoader(jar.file().getPath(), getFilesDir().getPath(), null, parent){ @Override protected Class loadClass(String name, boolean resolve) throws ClassNotFoundException{ diff --git a/gradle.properties b/gradle.properties index a72d1e7346..a87b03065c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -25,4 +25,5 @@ org.gradle.caching=true #used for slow jitpack builds; TODO see if this actually works org.gradle.internal.http.socketTimeout=100000 org.gradle.internal.http.connectionTimeout=100000 +android.enableR8.fullMode=false archash=b857594d11 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 3994438e22..0d1842103b 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.4-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists