1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-11 13:10:58 +00:00

Update Android dependencies for the project

- Update Java version from 11 to 17
- Update Android gradle plugin version from 7.2.1 to 8.2.0
- Update gradle version from 7.4.2 to 8.2
- Update target SDK from 33 to 34
- Update build tools version from 33.0.2 to 34.0.0
- Update kotlin version from 1.7.0 to 1.9.20
- Update Android fragment version from 1.3.6 to 1.6.2
- Update AndroidX window version from 1.0.0 to 1.2.0
- Update Nexus plugin version from 1.1.0 to 1.3.0
This commit is contained in:
Fredia Huya-Kouadio
2024-01-25 09:20:33 -08:00
parent 584dc09ff8
commit eba77be573
19 changed files with 187 additions and 95 deletions

View File

@@ -226,7 +226,7 @@ static const char *APK_ASSETS_DIRECTORY = "res://android/build/assets";
static const char *AAB_ASSETS_DIRECTORY = "res://android/build/assetPacks/installTime/src/main/assets";
static const int DEFAULT_MIN_SDK_VERSION = 19; // Should match the value in 'platform/android/java/app/config.gradle#minSdk'
static const int DEFAULT_TARGET_SDK_VERSION = 33; // Should match the value in 'platform/android/java/app/config.gradle#targetSdk'
static const int DEFAULT_TARGET_SDK_VERSION = 34; // Should match the value in 'platform/android/java/app/config.gradle#targetSdk'
#ifndef ANDROID_ENABLED
void EditorExportPlatformAndroid::_check_for_changes_poll_thread(void *ud) {
@@ -2012,6 +2012,15 @@ Ref<Texture> EditorExportPlatformAndroid::get_run_icon() const {
return run_icon;
}
String EditorExportPlatformAndroid::get_java_path() {
String exe_ext = "";
if (OS::get_singleton()->get_name() == "Windows") {
exe_ext = ".exe";
}
String java_sdk_path = EditorSettings::get_singleton()->get("export/android/java_sdk_path");
return java_sdk_path.plus_file("bin/java" + exe_ext);
}
String EditorExportPlatformAndroid::get_adb_path() {
String exe_ext = "";
if (OS::get_singleton()->get_name() == "Windows") {
@@ -2142,6 +2151,32 @@ bool EditorExportPlatformAndroid::has_valid_export_configuration(const Ref<Edito
err += TTR("Release keystore incorrectly configured in the export preset.") + "\n";
}
String java_sdk_path = EditorSettings::get_singleton()->get("export/android/java_sdk_path");
if (java_sdk_path == "") {
err += TTR("A valid Java SDK path is required in Editor Settings.") + "\n";
valid = false;
} else {
// Validate the given path by checking that `java` is present under the `bin` directory.
Error errn;
// Check for the bin directory.
DirAccessRef da = DirAccess::open(java_sdk_path.plus_file("bin"), &errn);
if (errn != OK) {
err += TTR("Invalid Java SDK path in Editor Settings.");
err += TTR("Missing 'bin' directory!");
err += "\n";
valid = false;
} else {
// Check for the `java` command.
String java_path = get_java_path();
if (!FileAccess::exists(java_path)) {
err += TTR("Unable to find 'java' command using the Java SDK path.");
err += TTR("Please check the Java SDK directory specified in Editor Settings.");
err += "\n";
valid = false;
}
}
}
String sdk_path = EditorSettings::get_singleton()->get("export/android/android_sdk_path");
if (sdk_path == "") {
err += TTR("A valid Android SDK path is required in Editor Settings.") + "\n";
@@ -2931,6 +2966,10 @@ Error EditorExportPlatformAndroid::export_project_helper(const Ref<EditorExportP
}
}
const String assets_directory = get_assets_directory(p_preset, export_format);
String java_sdk_path = EDITOR_GET("export/android/java_sdk_path");
ERR_FAIL_COND_V_MSG(java_sdk_path.empty(), ERR_UNCONFIGURED, "Java SDK path must be configured in Editor Settings at 'export/android/java_sdk_path'.");
print_verbose("Java sdk path: " + java_sdk_path);
String sdk_path = EDITOR_GET("export/android/android_sdk_path");
ERR_FAIL_COND_V_MSG(sdk_path.empty(), ERR_UNCONFIGURED, "Android SDK path must be configured in Editor Settings at 'export/android/android_sdk_path'.");
print_verbose("Android sdk path: " + sdk_path);
@@ -2975,8 +3014,11 @@ Error EditorExportPlatformAndroid::export_project_helper(const Ref<EditorExportP
print_verbose("Storing command line flags..");
store_file_at_path(assets_directory + "/_cl_", command_line_flags);
print_verbose("Updating JAVA_HOME environment to " + java_sdk_path);
OS::get_singleton()->set_environment("JAVA_HOME", java_sdk_path);
print_verbose("Updating ANDROID_HOME environment to " + sdk_path);
OS::get_singleton()->set_environment("ANDROID_HOME", sdk_path); //set and overwrite if required
OS::get_singleton()->set_environment("ANDROID_HOME", sdk_path);
String build_command;
#ifdef WINDOWS_ENABLED
@@ -3010,6 +3052,7 @@ Error EditorExportPlatformAndroid::export_project_helper(const Ref<EditorExportP
bool clean_build_required = is_clean_build_required(enabled_plugins);
List<String> cmdline;
cmdline.push_back("validateJavaVersion");
if (clean_build_required) {
cmdline.push_back("clean");
}