Skip to content

Commit cb6202b

Browse files
Optimize APK size: arm64-only, remove extractNativeLibs=false, add Android build docs to README
Agent-Logs-Url: https://github.com/winnerspiros/osu/sessions/4f02e4a3-e88b-422b-9009-a7eb331ff567 Co-authored-by: winnerspiros <1675249+winnerspiros@users.noreply.github.com>
1 parent 9fd3008 commit cb6202b

5 files changed

Lines changed: 71 additions & 13 deletions

File tree

.github/workflows/release.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,8 @@ jobs:
4848
NDK_HOME="$ANDROID_HOME/ndk/29.0.14206865"
4949
CMAKE_BIN="$ANDROID_HOME/cmake/3.22.1/bin/cmake"
5050
51-
# Only build arm64 and arm32. x86 removed to reduce APK size —
52-
# modern emulators use x86_64 or ARM translation.
53-
for ABI in arm64-v8a armeabi-v7a; do
51+
# arm64 only — matches RuntimeIdentifiers in osu.Android.props.
52+
for ABI in arm64-v8a; do
5453
echo "::group::Building osu_native for $ABI"
5554
"$CMAKE_BIN" -B "build-native/$ABI" -S osu.Android/Native \
5655
-DCMAKE_TOOLCHAIN_FILE="$NDK_HOME/build/cmake/android.toolchain.cmake" \

README.md

Lines changed: 63 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ You can see some examples of custom rulesets by visiting the [custom ruleset dir
5151

5252
Please make sure you have the following prerequisites:
5353

54-
- A desktop platform with the [.NET 8.0 SDK](https://dotnet.microsoft.com/download) installed.
54+
- A desktop platform with the [.NET 10.0 SDK](https://dotnet.microsoft.com/download/dotnet/10.0) installed (this fork targets .NET 10; upstream ppy/osu uses .NET 8).
5555

5656
When working with the codebase, we recommend using an IDE with intelligent code completion and syntax highlighting, such as the latest version of [Visual Studio](https://visualstudio.microsoft.com/vs/), [JetBrains Rider](https://www.jetbrains.com/rider/), or [Visual Studio Code](https://code.visualstudio.com/) with the [EditorConfig](https://marketplace.visualstudio.com/items?itemName=EditorConfig.EditorConfig) and [C# Dev Kit](https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.csdevkit) plugin installed.
5757

@@ -96,6 +96,68 @@ When running locally to do any kind of performance testing, make sure to add `-c
9696

9797
If the build fails, try to restore NuGet packages with `dotnet restore`.
9898

99+
#### Building for Android
100+
101+
**Prerequisites:**
102+
- [.NET 10.0 SDK](https://dotnet.microsoft.com/download/dotnet/10.0) (this fork targets .NET 10)
103+
- JDK 17 (`sudo apt install openjdk-17-jdk` or use [Microsoft's JDK](https://learn.microsoft.com/en-us/java/openjdk/download))
104+
- Android workload: `dotnet workload install android`
105+
106+
**Debug build** (auto-signed with debug keystore, suitable for local testing):
107+
108+
```shell
109+
dotnet build -c Debug osu.Android/osu.Android.csproj
110+
```
111+
112+
The APK will be at `osu.Android/bin/Debug/net10.0-android/sh.ppy.osulazer.apk`. Debug builds are always signed with the Android debug keystore and can be installed directly via `adb install`.
113+
114+
**Release build** (optimised with AOT, trimming, and compression):
115+
116+
```shell
117+
dotnet publish -c Release osu.Android/osu.Android.csproj -f net10.0-android
118+
```
119+
120+
The APK will be at `osu.Android/bin/Release/net10.0-android/publish/sh.ppy.osulazer.apk`.
121+
122+
**Signing the Release APK:**
123+
124+
Release APKs may not be automatically signed by the .NET SDK. If you get `INSTALL_PARSE_FAILED_NO_CERTIFICATES` when installing, sign the APK manually:
125+
126+
```shell
127+
# Find your build-tools (adjust version as needed)
128+
BUILD_TOOLS="$ANDROID_HOME/build-tools/$(ls $ANDROID_HOME/build-tools | sort -V | tail -1)"
129+
130+
# Zipalign (required before signing)
131+
"$BUILD_TOOLS/zipalign" -f -p 4 sh.ppy.osulazer.apk sh.ppy.osulazer-aligned.apk
132+
mv sh.ppy.osulazer-aligned.apk sh.ppy.osulazer.apk
133+
134+
# Sign with debug keystore (or your own release keystore)
135+
"$BUILD_TOOLS/apksigner" sign \
136+
--ks ~/.android/debug.keystore \
137+
--ks-pass pass:android \
138+
--key-pass pass:android \
139+
--ks-key-alias androiddebugkey \
140+
sh.ppy.osulazer.apk
141+
142+
# Verify
143+
"$BUILD_TOOLS/apksigner" verify sh.ppy.osulazer.apk
144+
```
145+
146+
If `~/.android/debug.keystore` does not exist, generate it:
147+
148+
```shell
149+
keytool -genkeypair -v -keystore ~/.android/debug.keystore \
150+
-storepass android -keypass android -alias androiddebugkey \
151+
-keyalg RSA -keysize 2048 -validity 10000 \
152+
-dname "CN=Android Debug,O=Android,C=US"
153+
```
154+
155+
**Install via ADB:**
156+
157+
```shell
158+
adb install sh.ppy.osulazer.apk
159+
```
160+
99161
### Testing with resource/framework modifications
100162

101163
Sometimes it may be necessary to cross-test changes in [osu-resources](https://github.com/ppy/osu-resources) or [osu-framework](https://github.com/ppy/osu-framework). This can be quickly achieved using included commands:

osu.Android.props

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
<Project>
22
<PropertyGroup>
33
<SupportedOSPlatformVersion>33.0</SupportedOSPlatformVersion>
4-
<!-- arm64-v8a covers 99%+ of modern Android devices.
5-
armeabi-v7a is kept for older 32-bit devices.
6-
x86 removed — only used by legacy emulators; modern x86_64 emulators
7-
run arm64 binaries via native translation (no dedicated x86 build needed). -->
8-
<RuntimeIdentifiers>android-arm;android-arm64</RuntimeIdentifiers>
4+
<!-- arm64-v8a only. Modern Android devices are 99%+ arm64; 32-bit arm32 (armeabi-v7a)
5+
adds ~200 MB of duplicate native libraries for negligible device coverage.
6+
x86 was already removed — modern x86_64 emulators run arm64 via translation. -->
7+
<RuntimeIdentifiers>android-arm64</RuntimeIdentifiers>
98
<AndroidPackageFormat>apk</AndroidPackageFormat>
109
<!-- CJK and Mideast encodings are needed for song metadata display.
1110
Rare covers supplementary Unicode blocks. West is the default Latin set. -->

osu.Android/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version='1.0' encoding='utf-8'?>
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="sh.ppy.osulazer" android:installLocation="auto">
33
<uses-sdk android:minSdkVersion="33" android:targetSdkVersion="36" />
4-
<application android:extractNativeLibs="false" android:allowBackup="true" android:supportsRtl="true" android:label="osu!" android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher" android:largeHeap="true">
4+
<application android:allowBackup="true" android:supportsRtl="true" android:label="osu!" android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher" android:largeHeap="true">
55
<provider android:name="androidx.core.content.FileProvider" android:authorities="sh.ppy.osulazer.fileprovider" android:grantUriPermissions="true" android:exported="false">
66
<meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/filepaths" />
77
</provider>

osu.Android/osu.Android.csproj

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,8 @@
2727
<None Remove="Native\CMakeLists.txt" />
2828
</ItemGroup>
2929
<!-- Include pre-built native libraries when present (built by the release workflow or local NDK build).
30-
When absent, native features (Oboe audio, Vulkan probe) are gracefully disabled at runtime.
31-
x86 removed — only arm64 and arm32 are shipped (see RuntimeIdentifiers in osu.Android.props). -->
30+
When absent, native features (Oboe audio, Vulkan probe) are gracefully disabled at runtime. -->
3231
<ItemGroup>
3332
<AndroidNativeLibrary Include="libs\arm64-v8a\libosu_native.so" Condition="Exists('libs\arm64-v8a\libosu_native.so')" Abi="arm64-v8a" />
34-
<AndroidNativeLibrary Include="libs\armeabi-v7a\libosu_native.so" Condition="Exists('libs\armeabi-v7a\libosu_native.so')" Abi="armeabi-v7a" />
3533
</ItemGroup>
3634
</Project>

0 commit comments

Comments
 (0)