From f41030f3269096fa752c0cc7100614bf95576b19 Mon Sep 17 00:00:00 2001 From: Matt Hargett Date: Sat, 11 Jul 2026 17:58:29 -0700 Subject: [PATCH] Refresh Android compatibility coverage for API 35 --- .github/workflows/build-android.yml | 2 +- .../V8Inspector/Source/V8InspectorAgent.cpp | 8 ++-- README.md | 6 +-- Tests/UnitTests/Android/app/build.gradle | 37 ++++++++++++++----- .../Android/app/src/main/cpp/JNI.cpp | 6 ++- 5 files changed, 41 insertions(+), 18 deletions(-) diff --git a/.github/workflows/build-android.yml b/.github/workflows/build-android.yml index c1ca23a6..2ba925df 100644 --- a/.github/workflows/build-android.yml +++ b/.github/workflows/build-android.yml @@ -62,7 +62,7 @@ jobs: - name: Run Connected Android Test uses: reactivecircus/android-emulator-runner@v2 with: - api-level: 33 + api-level: 35 target: google_apis arch: x86_64 emulator-options: -no-snapshot -no-window -no-boot-anim -no-audio diff --git a/Core/AppRuntime/V8Inspector/Source/V8InspectorAgent.cpp b/Core/AppRuntime/V8Inspector/Source/V8InspectorAgent.cpp index 2f1f1f5f..8eef7cd3 100644 --- a/Core/AppRuntime/V8Inspector/Source/V8InspectorAgent.cpp +++ b/Core/AppRuntime/V8Inspector/Source/V8InspectorAgent.cpp @@ -419,9 +419,9 @@ namespace Babylon } v8::Local string_value = v8::Local::Cast(value); int len = string_value->Length(); - std::basic_string buffer(len, '\0'); - string_value->Write(v8::Isolate::GetCurrent(), reinterpret_cast(&buffer[0]), 0, len); // Write expects uint16_t* but the template parameter is char16_t - return v8_inspector::StringBuffer::create(v8_inspector::StringView(reinterpret_cast(buffer.data()), len)); + std::vector buffer(len); + string_value->Write(v8::Isolate::GetCurrent(), buffer.data(), 0, len); + return v8_inspector::StringBuffer::create(v8_inspector::StringView(buffer.data(), len)); } bool AgentImpl::AppendMessage( @@ -661,4 +661,4 @@ namespace Babylon return "file://" + script_path_; } -} // namespace inspector \ No newline at end of file +} // namespace inspector diff --git a/README.md b/README.md index 7bd96831..be025099 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ npm install _Follow the steps from [All Development Platforms](#all-development-platforms) before proceeding._ **Required Tools:** -[Android Studio](https://developer.android.com/studio), [Node.js](https://nodejs.org/en/download/), [Ninja](https://ninja-build.org/) +[Android Studio](https://developer.android.com/studio) with Android NDK 28.2.13676358 and API level 35 SDK platform installed, [Node.js](https://nodejs.org/en/download/), [Ninja](https://ninja-build.org/) The minimal requirement target is Android 5.0. @@ -47,7 +47,7 @@ An `.apk` that can be executed on your device or simulator is the output. First, download the latest release of Ninja, extract the binary, and add it to your system path. -Once you have Android Studio downloaded, you need to set up an Android emulator if you do not have a physical Android device. You can do this by selecting `Tools` -> `Device Manager` and then selecting a device. (We are using Pixel 2 API 27). +Once you have Android Studio downloaded, you need to set up an Android emulator if you do not have a physical Android device. You can do this by selecting `Tools` -> `Device Manager` and then selecting a device. (We are using Pixel 2 API 35). Open the project located at `JsRuntimeHost\Tests\UnitTests\Android` with Android Studio. Note that this can take a while to load. (The bottom right corner of the Android Studio window shows you what is currently being loaded.) @@ -73,4 +73,4 @@ Security Response Center (MSRC) at [secure@microsoft.com](mailto:secure@microsof You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Further information, including the [MSRC PGP](https://technet.microsoft.com/en-us/security/dn606155) key, can -be found in the [Security TechCenter](https://technet.microsoft.com/en-us/security/default). \ No newline at end of file +be found in the [Security TechCenter](https://technet.microsoft.com/en-us/security/default). diff --git a/Tests/UnitTests/Android/app/build.gradle b/Tests/UnitTests/Android/app/build.gradle index c6137034..09bf91c9 100644 --- a/Tests/UnitTests/Android/app/build.gradle +++ b/Tests/UnitTests/Android/app/build.gradle @@ -7,6 +7,9 @@ if (project.hasProperty("jsEngine")) { jsEngine = project.property("jsEngine") } +def targetApiLevel = 35 +def requiredNdkVersion = project.findProperty("ndkVersion") ?: "28.2.13676358" + def cmakeArguments = [ "-DANDROID_STL=c++_shared", "-DNAPI_JAVASCRIPT_ENGINE=${jsEngine}", @@ -24,16 +27,13 @@ if (project.hasProperty("importHostCompilers")) { android { namespace 'com.jsruntimehost.unittests' - compileSdk 33 - ndkVersion = "23.1.7779620" - if (project.hasProperty("ndkVersion")) { - ndkVersion = project.property("ndkVersion") - } + compileSdk targetApiLevel + ndkVersion = requiredNdkVersion defaultConfig { applicationId "com.jsruntimehost.unittests" minSdk 21 - targetSdk 33 + targetSdk targetApiLevel versionCode 1 versionName "1.0" @@ -45,9 +45,28 @@ android { } } - if (project.hasProperty("abiFilters")) { - ndk { - abiFilters project.getProperty("abiFilters") + ndk { + def abiFiltersProp = project.findProperty("abiFilters")?.toString() + if (abiFiltersProp) { + def propFilters = abiFiltersProp.split(',').collect { it.trim() }.findAll { !it.isEmpty() } + if (!propFilters.isEmpty()) { + abiFilters(*propFilters) + } + } else { + def requestedAbi = project.findProperty("android.injected.build.abi") ?: System.getenv("ANDROID_ABI") + def defaultAbis = [] + if (requestedAbi) { + defaultAbis = requestedAbi.split(',').collect { it.trim() }.findAll { !it.isEmpty() } + } + if (defaultAbis.isEmpty()) { + def hostArch = (System.getProperty("os.arch") ?: "").toLowerCase() + if (hostArch.contains("aarch64") || hostArch.contains("arm64")) { + defaultAbis = ['arm64-v8a'] + } else { + defaultAbis = ['arm64-v8a', 'x86_64'] + } + } + abiFilters(*defaultAbis) } } } diff --git a/Tests/UnitTests/Android/app/src/main/cpp/JNI.cpp b/Tests/UnitTests/Android/app/src/main/cpp/JNI.cpp index 4415ce87..25818844 100644 --- a/Tests/UnitTests/Android/app/src/main/cpp/JNI.cpp +++ b/Tests/UnitTests/Android/app/src/main/cpp/JNI.cpp @@ -22,7 +22,11 @@ Java_com_jsruntimehost_unittests_Native_javaScriptTests(JNIEnv* env, jclass claz android::global::Initialize(javaVM, context); Babylon::DebugTrace::EnableDebugTrace(true); - Babylon::DebugTrace::SetTraceOutput([](const char* trace) { printf("%s\n", trace); fflush(stdout); }); + // Emit debug-trace lines straight to logcat under a dedicated "JsRuntimeHost" tag instead of + // routing them through AndroidExtensions' StdoutLogger (which forwards all stdout under a single + // tag, interleaved with the gtest output). The distinct tag keeps connected-test diagnostics + // filterable, e.g. `adb logcat -s JsRuntimeHost`. + Babylon::DebugTrace::SetTraceOutput([](const char* trace) { __android_log_print(ANDROID_LOG_INFO, "JsRuntimeHost", "%s", trace); }); auto testResult = RunTests();