From c717eacd30a58ef7c566890284fa901727aca231 Mon Sep 17 00:00:00 2001 From: Nedifinita Date: Tue, 15 Jul 2025 14:33:37 +0800 Subject: [PATCH] feat: add multi-architecture APK support for all Android platforms --- .github/workflows/android-release.yml | 39 ++++++++++++++++++++++++--- .gitignore | 1 + .idea/appInsightsSettings.xml | 6 +++++ app/build.gradle.kts | 16 ++++++++++- app/proguard-rules.pro | 31 +++++++++------------ 5 files changed, 71 insertions(+), 22 deletions(-) create mode 100644 .idea/appInsightsSettings.xml diff --git a/.github/workflows/android-release.yml b/.github/workflows/android-release.yml index fa04b35..422bef9 100644 --- a/.github/workflows/android-release.yml +++ b/.github/workflows/android-release.yml @@ -13,6 +13,9 @@ permissions: jobs: release: runs-on: ubuntu-latest + strategy: + matrix: + abi: ["arm64-v8a", "armeabi-v7a", "x86", "x86_64"] steps: - name: Checkout repository @@ -40,18 +43,48 @@ jobs: - name: Grant execute permission for gradlew run: chmod +x gradlew - - name: Build Release APK + - name: Modify build.gradle for specific ABI + run: | + sed -i 's/abiFilters += listOf("arm64-v8a", "armeabi-v7a", "x86", "x86_64")/abiFilters += listOf("${{ matrix.abi }}")/g' app/build.gradle.kts + + - name: Build Release APK for ${{ matrix.abi }} run: ./gradlew assembleRelease env: KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }} KEY_ALIAS: ${{ secrets.KEY_ALIAS }} KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }} + - name: Rename APK with ABI suffix + run: | + cd app/build/outputs/apk/release + for file in *.apk; do + mv "$file" "${file%.apk}-${{ matrix.abi }}.apk" + done + + - name: Upload APK artifact + uses: actions/upload-artifact@v4 + with: + name: apk-${{ matrix.abi }} + path: app/build/outputs/apk/release/*-${{ matrix.abi }}.apk + + create-release: + needs: release + runs-on: ubuntu-latest + if: startsWith(github.ref, 'refs/tags/') + + steps: + - name: Download all APK artifacts + uses: actions/download-artifact@v4 + with: + path: apks + - name: Create Release - if: startsWith(github.ref, 'refs/tags/') uses: softprops/action-gh-release@v1 with: - files: app/build/outputs/apk/release/*.apk + files: | + apks/**/*.apk generate_release_notes: true + name: ${{ github.ref_name }} + body: "" env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.gitignore b/.gitignore index 7ca217f..393e827 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,4 @@ captures .cxx local.properties local.properties +*.ps1 \ No newline at end of file diff --git a/.idea/appInsightsSettings.xml b/.idea/appInsightsSettings.xml new file mode 100644 index 0000000..6bbe2ae --- /dev/null +++ b/.idea/appInsightsSettings.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 71afdae..439595e 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -16,17 +16,31 @@ android { versionName = "1.0" testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + + ndk { + abiFilters += listOf("arm64-v8a", "armeabi-v7a", "x86", "x86_64") + } } buildTypes { release { - isMinifyEnabled = false + isMinifyEnabled = true + isShrinkResources = true proguardFiles( getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro" ) } } + + splits { + abi { + isEnable = true + reset() + include("arm64-v8a", "armeabi-v7a", "x86", "x86_64") + isUniversalApk = true + } + } compileOptions { sourceCompatibility = JavaVersion.VERSION_11 targetCompatibility = JavaVersion.VERSION_11 diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index 481bb43..ceae6c8 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -1,21 +1,16 @@ -# Add project specific ProGuard rules here. -# You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. -# -# For more details, see -# http://developer.android.com/guide/developing/tools/proguard.html +-keepattributes SourceFile,LineNumberTable +-renamesourcefileattribute SourceFile -# If your project uses WebView with JS, uncomment the following -# and specify the fully qualified class name to the JavaScript interface -# class: -#-keepclassmembers class fqcn.of.javascript.interface.for.webview { -# public *; -#} +-keep class org.json.** { *; } +-keep class org.osmdroid.** { *; } +-keep class org.mapsforge.** { *; } -# Uncomment this to preserve the line number information for -# debugging stack traces. -#-keepattributes SourceFile,LineNumberTable +-keepclassmembers class * { + @androidx.compose.runtime.Composable ; +} -# If you keep the line number information, uncomment this to -# hide the original source file name. -#-renamesourcefileattribute SourceFile \ No newline at end of file +-keep class androidx.compose.** { *; } +-keep class kotlin.** { *; } + +-dontwarn org.osmdroid.** +-dontwarn org.mapsforge.** \ No newline at end of file