From 90758a5ea1242f445d2b4c093c8124f8fc43c02b Mon Sep 17 00:00:00 2001 From: Thibault Deckers Date: Tue, 5 Oct 2021 17:14:33 +0900 Subject: [PATCH] #88 generate split APKs for IzzyOnDroid --- .github/workflows/release.yml | 11 +++++---- android/app/build.gradle | 43 +++++++++++++++++++++++++---------- 2 files changed, 37 insertions(+), 17 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8a0cec7b9..c57a79856 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -50,8 +50,9 @@ jobs: echo "${{ secrets.KEY_JKS }}" > release.keystore.asc gpg -d --passphrase "${{ secrets.KEY_JKS_PASSPHRASE }}" --batch release.keystore.asc > $AVES_STORE_FILE rm release.keystore.asc - flutter build apk --bundle-sksl-path shaders_2.5.2.sksl.json - flutter build appbundle --bundle-sksl-path shaders_2.5.2.sksl.json + flutter build appbundle --flavor universal --bundle-sksl-path shaders_2.5.2.sksl.json + flutter build apk --flavor universal --bundle-sksl-path shaders_2.5.2.sksl.json + flutter build apk --flavor byAbi --split-per-abi --bundle-sksl-path shaders_2.5.2.sksl.json rm $AVES_STORE_FILE env: AVES_STORE_FILE: ${{ github.workspace }}/key.jks @@ -63,14 +64,14 @@ jobs: - name: Create a release with the APK and App Bundle. uses: ncipollo/release-action@v1 with: - artifacts: "build/app/outputs/apk/release/*.apk,build/app/outputs/bundle/release/*.aab" + artifacts: "build/app/outputs/bundle/universalRelease/*.aab,build/app/outputs/apk/universal/release/*.apk,build/app/outputs/apk/byAbi/release/*.apk" token: ${{ secrets.GITHUB_TOKEN }} - name: Upload app bundle uses: actions/upload-artifact@v2 with: name: appbundle - path: build/app/outputs/bundle/release/app-release.aab + path: build/app/outputs/bundle/universalRelease/app-universal-release.aab release: name: Create beta release on Play Store. @@ -89,7 +90,7 @@ jobs: with: serviceAccountJsonPlainText: ${{ secrets.PLAYSTORE_ACCOUNT_KEY }} packageName: deckers.thibault.aves - releaseFiles: app-release.aab + releaseFiles: app-universal-release.aab track: beta status: completed whatsNewDirectory: whatsnew diff --git a/android/app/build.gradle b/android/app/build.gradle index 53cf01d6c..8cf3179fb 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -77,6 +77,21 @@ android { } } + // the "splitting" dimension and its flavors are only for building purposes: + // NDK ABI filters are not compatible with split APK generation + // but we want to generate both a universal APK without x86 libs, and split APKs + flavorDimensions "splitting" + + productFlavors { + universal { + dimension "splitting" + } + + byAbi { + dimension "splitting" + } + } + buildTypes { debug { applicationIdSuffix ".debug" @@ -87,19 +102,23 @@ android { resValue 'string', 'search_provider', "${appId}.profile.search_provider" } release { - // specify architectures, to specifically exclude native libs for x86, - // which lead to: UnsatisfiedLinkError...couldn't find "libflutter.so" - // cf https://github.com/flutter/flutter/issues/37566#issuecomment-640879500 - ndk { - abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86_64' - } - signingConfig signingConfigs.release - minifyEnabled true shrinkResources true proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } + + def runTasks = gradle.startParameter.taskNames.toString().toLowerCase() + if (runTasks.contains("universal")) { + release { + // specify architectures, to specifically exclude native libs for x86, + // which lead to: UnsatisfiedLinkError...couldn't find "libflutter.so" + // cf https://github.com/flutter/flutter/issues/37566#issuecomment-640879500 + ndk { + abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86_64' + } + } + } } } @@ -120,10 +139,10 @@ dependencies { implementation 'com.caverock:androidsvg-aar:1.4' implementation 'com.commonsware.cwac:document:0.4.1' implementation 'com.drewnoakes:metadata-extractor:2.16.0' - // https://jitpack.io/p/deckerst/Android-TiffBitmapFactory - implementation 'com.github.deckerst:Android-TiffBitmapFactory:876e53870a' // forked, built by JitPack - // https://jitpack.io/p/deckerst/pixymeta-android - implementation 'com.github.deckerst:pixymeta-android:0bea51ead2' // forked, built by JitPack + // forked, built by JitPack, cf https://jitpack.io/p/deckerst/Android-TiffBitmapFactory + implementation 'com.github.deckerst:Android-TiffBitmapFactory:876e53870a' + // forked, built by JitPack, cf https://jitpack.io/p/deckerst/pixymeta-android + implementation 'com.github.deckerst:pixymeta-android:0bea51ead2' implementation 'com.github.bumptech.glide:glide:4.12.0' kapt 'androidx.annotation:annotation:1.2.0'