Skip to content

Commit b3fbef1

Browse files
author
Your Name
committed
rewrote the build to check the build for both versions
1 parent 31bb076 commit b3fbef1

File tree

4 files changed

+74
-7
lines changed

4 files changed

+74
-7
lines changed

.github/actions/android/action.yml

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ runs:
3737
with:
3838
cache: true
3939

40-
- name: Build Android APK/AAB
40+
- name: Build preApi30 APK/AAB
4141
shell: bash
4242
env:
4343
STORE_PASS: ${{ inputs.STORE_PASS }}
@@ -46,13 +46,29 @@ runs:
4646
VERSION_NAME: ${{inputs.VERSION_NAME}}
4747
VERSION_CODE: ${{inputs.VERSION_CODE}}
4848
run: |
49-
flutter build apk --debug --build-name $VERSION_NAME --build-number $VERSION_CODE
50-
flutter build apk --build-name $VERSION_NAME --build-number $VERSION_CODE
51-
flutter build appbundle --build-name $VERSION_NAME --build-number $VERSION_CODE
49+
flutter build apk --flavor preApi30 --debug --build-name $VERSION_NAME --build-number $VERSION_CODE
50+
flutter build apk --flavor preApi30 --build-name $VERSION_NAME --build-number $VERSION_CODE
51+
flutter build appbundle --flavor preApi30 --build-name $VERSION_NAME --build-number $VERSION_CODE
5252
53-
- name: Store APK file
53+
- name: Build postApi30 APK/AAB
54+
shell: bash
55+
env:
56+
STORE_PASS: ${{ inputs.STORE_PASS }}
57+
ALIAS: ${{ inputs.ALIAS }}
58+
KEY_PASS: ${{ inputs.KEY_PASS }}
59+
VERSION_NAME: ${{inputs.VERSION_NAME}}
60+
VERSION_CODE: ${{inputs.VERSION_CODE}}
61+
run: |
62+
flutter build apk --flavor postApi30 --debug --build-name $VERSION_NAME --build-number $VERSION_CODE
63+
flutter build apk --flavor postApi30 --build-name $VERSION_NAME --build-number $VERSION_CODE
64+
flutter build appbundle --flavor postApi30 --build-name $VERSION_NAME --build-number $VERSION_CODE
65+
66+
- name: Store APK files
5467
uses: actions/upload-artifact@v4
5568
with:
5669
name: apk-files
5770
path: |
58-
build/app/outputs/flutter-apk/app-debug.apk
71+
build/app/outputs/flutter-apk/app-preapi30-debug.apk
72+
build/app/outputs/flutter-apk/app-preapi30-release.apk
73+
build/app/outputs/flutter-apk/app-postapi30-debug.apk
74+
build/app/outputs/flutter-apk/app-postapi30-release.apk

.github/actions/screenshot-android/action.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,19 @@ runs:
5454
with:
5555
cache: true
5656

57-
- name: Create Android Screenshots
57+
- name: Create Android Screenshots (preApi30)
5858
uses: reactivecircus/android-emulator-runner@v2
5959
with:
6060
api-level: ${{ inputs.ANDROID_EMULATOR_API }}
6161
arch: ${{ inputs.ANDROID_EMULATOR_ARCH }}
62+
script: flutter drive --flavor preApi30 --driver=test_integration/test_driver.dart --target=test_integration/screenshots.dart -d emulator
63+
64+
- name: Create Android Screenshots (postApi30)
65+
uses: reactivecircus/android-emulator-runner@v2
66+
with:
67+
api-level: ${{ inputs.ANDROID_EMULATOR_API }}
68+
arch: ${{ inputs.ANDROID_EMULATOR_ARCH }}
69+
script: flutter drive --flavor postApi30 --driver=test_integration/test_driver.dart --target=test_integration/screenshots.dart -d emulator
6270
profile: pixel_6
6371
avd-name: pixel_6
6472
force-avd-creation: false

.github/workflows/push.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,24 @@ jobs:
2424
- name: Common Workflow
2525
uses: ./.github/actions/common
2626

27+
- name: Build preApi30 APK
28+
run: flutter build apk --flavor preApi30 -t lib/main.dart
29+
30+
- name: Build postApi30 APK
31+
run: flutter build apk --flavor postApi30 -t lib/main.dart
32+
33+
- name: Upload preApi30 APK
34+
uses: actions/upload-artifact@v4
35+
with:
36+
name: app-preapi30-release.apk
37+
path: build/app/outputs/flutter-apk/app-preapi30-release.apk
38+
39+
- name: Upload postApi30 APK
40+
uses: actions/upload-artifact@v4
41+
with:
42+
name: app-postapi30-release.apk
43+
path: build/app/outputs/flutter-apk/app-postapi30-release.apk
44+
2745
- name: Hydrate and Update Version
2846
id: flutter-version
2947
run: |

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,31 @@ For this mode it is required that both the workstation and the device are on the
131131

132132
Enable Wireless debugging as per the [documentation](https://developer.android.com/tools/adb#wireless-android11-command-line), then **pair** `adb pair <IP>:<PORT>` and **connect** `adb connect <IP>:<PORT>` and you should be able to find your device via `adb devices`.
133133

134+
## Building for Android (API Flavors)
135+
136+
This project uses product flavors to support both pre-Android 11 and Android 11+ devices. **You must specify a flavor when building or running for Android!**
137+
138+
- **For Android 10 and below:**
139+
```sh
140+
flutter build apk --flavor preApi30 -t lib/main.dart
141+
flutter run --flavor preApi30 -t lib/main.dart
142+
```
143+
Output: `build/app/outputs/flutter-apk/app-preapi30-release.apk`
144+
145+
- **For Android 11 and above:**
146+
```sh
147+
flutter build apk --flavor postApi30 -t lib/main.dart
148+
flutter run --flavor postApi30 -t lib/main.dart
149+
```
150+
Output: `build/app/outputs/flutter-apk/app-postapi30-release.apk`
151+
152+
If you do not specify a flavor, the build will fail due to missing `minSdkVersion` and `targetSdkVersion` in the default configuration.
153+
154+
**Developer Note:**
155+
- This is a standard practice for multi-target Android projects (such as those distributed on F-Droid).
156+
- It ensures clarity and prevents accidental builds for the wrong Android version.
157+
- If you want extra convenience, you can create local shell scripts or aliases, e.g., `run-pre.sh` with `flutter run --flavor preApi30 -t lib/main.dart` for faster development.
158+
- Always check the README for up-to-date build instructions.
134159

135160
## LICENSE
136161

0 commit comments

Comments
 (0)