diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index dba772755..e403c1355 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -288,7 +288,7 @@ jobs: - uses: actions/setup-java@v4 with: distribution: "zulu" - java-version: 11 + java-version: 17 - uses: krdlab/setup-haxe@v1 with: diff --git a/templates/android/template/app/build.gradle b/templates/android/template/app/build.gradle index f6b9fad10..00c0f4088 100644 --- a/templates/android/template/app/build.gradle +++ b/templates/android/template/app/build.gradle @@ -17,6 +17,7 @@ android { compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION) buildToolsVersion project.ANDROID_BUILD_TOOLS_VERSION ::if (ANDROID_GRADLE_PLUGIN>="4.0")::ndkPath '::ANDROID_NDK_ROOT_ESCAPED::'::end:: + ::if (ANDROID_NDK_VERSION)::ndkVersion '::ANDROID_NDK_VERSION::'::end:: defaultConfig { applicationId "::META_PACKAGE_NAME::" diff --git a/templates/android/template/build.gradle b/templates/android/template/build.gradle index 55388aaba..2a3350106 100644 --- a/templates/android/template/build.gradle +++ b/templates/android/template/build.gradle @@ -47,6 +47,7 @@ configure(subprojects.findAll {!it.file('build.gradle').exists() && it.file('bui compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION) buildToolsVersion project.ANDROID_BUILD_TOOLS_VERSION ::if (ANDROID_GRADLE_PLUGIN>="4.0")::ndkPath '::ANDROID_NDK_ROOT_ESCAPED::'::end:: + ::if (ANDROID_NDK_VERSION)::ndkVersion '::ANDROID_NDK_VERSION::'::end:: sourceSets { main { diff --git a/tools/platforms/AndroidPlatform.hx b/tools/platforms/AndroidPlatform.hx index 8451d2a70..d9925eb3d 100644 --- a/tools/platforms/AndroidPlatform.hx +++ b/tools/platforms/AndroidPlatform.hx @@ -470,7 +470,7 @@ class AndroidPlatform extends PlatformTarget context.OUTPUT_DIR = targetDirectory; context.ANDROID_INSTALL_LOCATION = project.config.getString("android.install-location", "auto"); context.ANDROID_MINIMUM_SDK_VERSION = project.config.getInt("android.minimum-sdk-version", 21); - context.ANDROID_TARGET_SDK_VERSION = project.config.getInt("android.target-sdk-version", 30); + context.ANDROID_TARGET_SDK_VERSION = project.config.getInt("android.target-sdk-version", 34); context.ANDROID_EXTENSIONS = project.config.getArrayString("android.extension"); context.ANDROID_PERMISSIONS = project.config.getArrayString("android.permission", [ "android.permission.WAKE_LOCK", @@ -478,8 +478,8 @@ class AndroidPlatform extends PlatformTarget "android.permission.VIBRATE", "android.permission.ACCESS_NETWORK_STATE" ]); - context.ANDROID_GRADLE_VERSION = project.config.getString("android.gradle-version", "7.4.2"); - context.ANDROID_GRADLE_PLUGIN = project.config.getString("android.gradle-plugin", "7.3.1"); + context.ANDROID_GRADLE_VERSION = project.config.getString("android.gradle-version", "8.9"); + context.ANDROID_GRADLE_PLUGIN = project.config.getString("android.gradle-plugin", "8.7.3"); context.ANDROID_USE_ANDROIDX = project.config.getString("android.useAndroidX", "true"); context.ANDROID_ENABLE_JETIFIER = project.config.getString("android.enableJetifier", "false"); @@ -529,6 +529,29 @@ class AndroidPlatform extends PlatformTarget context.ANDROID_SDK_ESCAPED = StringTools.replace(context.ENV_ANDROID_SDK, "\\", "\\\\"); context.ANDROID_NDK_ROOT_ESCAPED = StringTools.replace(context.ENV_ANDROID_NDK_ROOT, "\\", "\\\\"); + // we need to specify ndkVersion in build.gradle, and the value can be + // found in the NDK's source.properties file + var ndkSrcPropsPath = Path.join([context.ENV_ANDROID_NDK_ROOT, "source.properties"]); + if (FileSystem.exists(ndkSrcPropsPath)) + { + try + { + var srcProps = File.getContent(ndkSrcPropsPath); + var lines = srcProps.split("\n"); + for (line in lines) + { + var parts = ~/\s+=\s+/.split(StringTools.trim(line)); + if (parts.length == 2 && parts[0] == "Pkg.Revision") + { + context.ANDROID_NDK_VERSION = parts[1]; + } + } + } + catch (e:Dynamic) + { + } + } + if (Reflect.hasField(context, "KEY_STORE")) context.KEY_STORE = StringTools.replace(context.KEY_STORE, "\\", "\\\\"); if (Reflect.hasField(context, "KEY_STORE_ALIAS")) context.KEY_STORE_ALIAS = StringTools.replace(context.KEY_STORE_ALIAS, "\\", "\\\\"); if (Reflect.hasField(context, "KEY_STORE_PASSWORD")) context.KEY_STORE_PASSWORD = StringTools.replace(context.KEY_STORE_PASSWORD, "\\", "\\\\");