From e02fb9cd820ef36195d9ae911c03340d01775610 Mon Sep 17 00:00:00 2001 From: Luo Zhihao Date: Sat, 28 Mar 2026 17:20:56 +0800 Subject: [PATCH 1/2] Remove cmake and dummy.cpp in Android example --- examples/mobile/android_example/app/CMakeLists.txt | 5 ----- examples/mobile/android_example/app/build.gradle | 11 ----------- .../mobile/android_example/app/src/main/cpp/dummy.cpp | 2 -- .../mobile/android_example_native/app/CMakeLists.txt | 5 ----- .../mobile/android_example_native/app/build.gradle | 11 ----------- .../android_example_native/app/src/main/cpp/dummy.cpp | 2 -- 6 files changed, 36 deletions(-) delete mode 100644 examples/mobile/android_example/app/CMakeLists.txt delete mode 100644 examples/mobile/android_example/app/src/main/cpp/dummy.cpp delete mode 100644 examples/mobile/android_example_native/app/CMakeLists.txt delete mode 100644 examples/mobile/android_example_native/app/src/main/cpp/dummy.cpp diff --git a/examples/mobile/android_example/app/CMakeLists.txt b/examples/mobile/android_example/app/CMakeLists.txt deleted file mode 100644 index c388547c20a0e..0000000000000 --- a/examples/mobile/android_example/app/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -# This is part of a hack to convince gradle to insert libc++_shared.so -cmake_minimum_required(VERSION 3.4.1) -project(cppshared_dummy) -set (SRC_DIR ./src/main/cpp) -add_library (dummy SHARED ${SRC_DIR}/dummy.cpp) diff --git a/examples/mobile/android_example/app/build.gradle b/examples/mobile/android_example/app/build.gradle index c21a9de6295fc..cbc71c42aa498 100644 --- a/examples/mobile/android_example/app/build.gradle +++ b/examples/mobile/android_example/app/build.gradle @@ -12,23 +12,12 @@ android { targetSdk 33 versionCode 1 versionName "1.0" - // need this otherwise it won't insert libc++_shared.so - externalNativeBuild { - cmake { - arguments "-DANDROID_STL=c++_shared" - } - } // set up targets ndk { abiFilters 'arm64-v8a' } testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } - externalNativeBuild { - cmake { - path "CMakeLists.txt" - } - } buildTypes { release { minifyEnabled false diff --git a/examples/mobile/android_example/app/src/main/cpp/dummy.cpp b/examples/mobile/android_example/app/src/main/cpp/dummy.cpp deleted file mode 100644 index c20beb86c6f7a..0000000000000 --- a/examples/mobile/android_example/app/src/main/cpp/dummy.cpp +++ /dev/null @@ -1,2 +0,0 @@ -// Intentionally blank -- this is a dummy code! -// This is part of a hack to convince gradle to insert libc++_shared.so \ No newline at end of file diff --git a/examples/mobile/android_example_native/app/CMakeLists.txt b/examples/mobile/android_example_native/app/CMakeLists.txt deleted file mode 100644 index c388547c20a0e..0000000000000 --- a/examples/mobile/android_example_native/app/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -# This is part of a hack to convince gradle to insert libc++_shared.so -cmake_minimum_required(VERSION 3.4.1) -project(cppshared_dummy) -set (SRC_DIR ./src/main/cpp) -add_library (dummy SHARED ${SRC_DIR}/dummy.cpp) diff --git a/examples/mobile/android_example_native/app/build.gradle b/examples/mobile/android_example_native/app/build.gradle index 4b33cd78017f4..5ebd41c42b3d8 100644 --- a/examples/mobile/android_example_native/app/build.gradle +++ b/examples/mobile/android_example_native/app/build.gradle @@ -12,23 +12,12 @@ android { targetSdk 33 versionCode 1 versionName "1.0" - // need this otherwise it won't insert libc++_shared.so - externalNativeBuild { - cmake { - arguments "-DANDROID_STL=c++_shared" - } - } // set up targets ndk { abiFilters 'arm64-v8a' } testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } - externalNativeBuild { - cmake { - path "CMakeLists.txt" - } - } buildTypes { release { minifyEnabled false diff --git a/examples/mobile/android_example_native/app/src/main/cpp/dummy.cpp b/examples/mobile/android_example_native/app/src/main/cpp/dummy.cpp deleted file mode 100644 index c20beb86c6f7a..0000000000000 --- a/examples/mobile/android_example_native/app/src/main/cpp/dummy.cpp +++ /dev/null @@ -1,2 +0,0 @@ -// Intentionally blank -- this is a dummy code! -// This is part of a hack to convince gradle to insert libc++_shared.so \ No newline at end of file From ab7eddfd31f725153c853bf5a92b6d3c50ac8b03 Mon Sep 17 00:00:00 2001 From: Luo Zhihao Date: Sat, 28 Mar 2026 23:04:50 +0800 Subject: [PATCH 2/2] Clean up the rest --- docs-template/EXAMPLE_README.md.tpl | 9 --------- examples/README.md | 9 --------- examples/mobile/android_example/app/build.gradle | 4 ---- examples/mobile/android_example_native/app/build.gradle | 5 ----- 4 files changed, 27 deletions(-) diff --git a/docs-template/EXAMPLE_README.md.tpl b/docs-template/EXAMPLE_README.md.tpl index f92ad89385726..2f3e994d43092 100644 --- a/docs-template/EXAMPLE_README.md.tpl +++ b/docs-template/EXAMPLE_README.md.tpl @@ -45,7 +45,6 @@ git checkout v0.4.0 - [Android](#android) - [Setup](#setup) - [Build & Run](#build--run) - - [About `libc++_shared.so`](#about-libc_sharedso) - [Old phones](#old-phones) - [About `cargo-apk`](#about-cargo-apk) - [iOS](#ios) @@ -130,14 +129,6 @@ Or build it with Android Studio. Then you can test it in your Android project. -##### About `libc++_shared.so` - -Bevy may require `libc++_shared.so` to run on Android, as it is needed by the `oboe` crate, but typically `cargo-ndk` does not copy this file automatically. - -To include it, you can manually obtain it from NDK source or use a `build.rs` script for automation, as described in the `cargo-ndk` [README](https://github.com/bbqsrc/cargo-ndk?tab=readme-ov-file#linking-against-and-copying-libc_sharedso-into-the-relevant-places-in-the-output-directory). - -Alternatively, you can modify project files to include it when building an APK. To understand the specific steps taken in this project, please refer to the comments within the project files for detailed instructions(`app/CMakeList.txt`, `app/build.gradle`, `app/src/main/cpp/dummy.cpp`). - #### Debugging You can view the logs with the following command: diff --git a/examples/README.md b/examples/README.md index f1b5b7eaa8c93..3899b91777269 100644 --- a/examples/README.md +++ b/examples/README.md @@ -77,7 +77,6 @@ git checkout v0.4.0 - [Android](#android) - [Setup](#setup) - [Build & Run](#build--run) - - [About `libc++_shared.so`](#about-libc_sharedso) - [Old phones](#old-phones) - [About `cargo-apk`](#about-cargo-apk) - [iOS](#ios) @@ -730,14 +729,6 @@ Or build it with Android Studio. Then you can test it in your Android project. -##### About `libc++_shared.so` - -Bevy may require `libc++_shared.so` to run on Android, as it is needed by the `oboe` crate, but typically `cargo-ndk` does not copy this file automatically. - -To include it, you can manually obtain it from NDK source or use a `build.rs` script for automation, as described in the `cargo-ndk` [README](https://github.com/bbqsrc/cargo-ndk?tab=readme-ov-file#linking-against-and-copying-libc_sharedso-into-the-relevant-places-in-the-output-directory). - -Alternatively, you can modify project files to include it when building an APK. To understand the specific steps taken in this project, please refer to the comments within the project files for detailed instructions(`app/CMakeList.txt`, `app/build.gradle`, `app/src/main/cpp/dummy.cpp`). - #### Debugging You can view the logs with the following command: diff --git a/examples/mobile/android_example/app/build.gradle b/examples/mobile/android_example/app/build.gradle index cbc71c42aa498..94be007f51f1c 100644 --- a/examples/mobile/android_example/app/build.gradle +++ b/examples/mobile/android_example/app/build.gradle @@ -31,10 +31,6 @@ android { buildFeatures { prefab true } - // The final part to insert libc++_shared.so only - packagingOptions { - exclude 'lib/*/libdummy.so' - } sourceSets { main { assets.srcDirs += files('../../../../assets') diff --git a/examples/mobile/android_example_native/app/build.gradle b/examples/mobile/android_example_native/app/build.gradle index 5ebd41c42b3d8..68237739283b6 100644 --- a/examples/mobile/android_example_native/app/build.gradle +++ b/examples/mobile/android_example_native/app/build.gradle @@ -31,11 +31,6 @@ android { buildFeatures { viewBinding true } - // The final part to insert libc++_shared.so only - packagingOptions { - exclude 'lib/*/libdummy.so' - } - sourceSets { main { assets.srcDirs += files('../../../../assets')