Skip to content

Commit

Permalink
Default to Android target-sdk-version 34, and support 35 (closes #1888)
Browse files Browse the repository at this point in the history
34 is the minimum required version by Google Play, so it should be default.

Bumping to 34 and 35 requires updating both gradle-version and gradle-plugin-version.

The new versions now require an ndkVersion flag in build.gradle. This can be obtained by reading source.properties in the root of the NDK.

JDK 17 will be required for these updates. Previously required JDK 11.
  • Loading branch information
joshtynjala committed Jan 14, 2025
1 parent 8bfc0be commit 2e578d3
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions templates/android/template/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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::"
Expand Down
1 change: 1 addition & 0 deletions templates/android/template/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
29 changes: 26 additions & 3 deletions tools/platforms/AndroidPlatform.hx
Original file line number Diff line number Diff line change
Expand Up @@ -470,16 +470,16 @@ 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",
"android.permission.INTERNET",
"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");

Expand Down Expand Up @@ -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, "\\", "\\\\");
Expand Down

0 comments on commit 2e578d3

Please sign in to comment.