Skip to content

Conversation

nope3472
Copy link
Contributor

@nope3472 nope3472 commented Jul 6, 2025

Fixes #1340

Changes

  • Added two product flavors to android/app/build.gradle:
    • preApi30: For devices running Android 10 (API 29) and below (minSdkVersion 21, targetSdkVersion 29)
    • postApi30: For devices running Android 11 (API 30) and above (minSdkVersion 30, targetSdkVersion 34)
  • Enables building two APKs, ensuring compatibility with both pre-Android 11 and newer devices, as required for F-Droid distribution.
  • No hard-coded values or end-of-file edits introduced.
  • Reviewed and improved code formatting and indentation.

How to Build and Use the Two APK Versions:
For Android 10 and below:
flutter build apk --flavor preApi30 -t lib/main.dart

For Android 11 and above:
flutter build apk --flavor postApi30 -t lib/main.dart

Summary by Sourcery

Configure two Android build flavors to generate separate APKs for devices running pre-Android 11 (API 29) and Android 11+ (API 30–34) to satisfy F-Droid compatibility requirements.

New Features:

  • Add preApi30 and postApi30 product flavors with distinct minSdkVersion and targetSdkVersion settings.

Enhancements:

  • Enable building two APK variants targeting Android 10 and below vs. Android 11 and above.
  • Remove hard-coded defaultConfig SDK settings and improve build.gradle formatting.

Copy link
Contributor

sourcery-ai bot commented Jul 6, 2025

Reviewer's Guide

Introduces two API-specific Android product flavors in build.gradle to generate separate APKs for pre-Android 11 and post-Android 11 devices (as required for F-Droid), removes default SDK declarations to delegate to these flavors, and applies formatting improvements.

Flow diagram for building APKs with new product flavors

flowchart TD
    Start([Start]) --> ChooseFlavor{Select build flavor}
    ChooseFlavor -- preApi30 --> BuildPre[Build APK with minSdk 21, targetSdk 29]
    ChooseFlavor -- postApi30 --> BuildPost[Build APK with minSdk 30, targetSdk 34]
    BuildPre --> OutputPre[Output: APK for Android 10 and below]
    BuildPost --> OutputPost[Output: APK for Android 11 and above]
Loading

File-Level Changes

Change Details Files
Introduce API-specific product flavors for Android builds
  • Added flavorDimensions "api"
  • Defined preApi30 flavor with minSdkVersion 21 and targetSdkVersion 29
  • Defined postApi30 flavor with minSdkVersion 30 and targetSdkVersion 34
  • Configured separate APK outputs per flavor
android/app/build.gradle
Remove default SDK version declarations
  • Deleted minSdkVersion and targetSdkVersion from defaultConfig
android/app/build.gradle
Adjust code formatting and indentation
  • Cleaned up whitespace and aligned braces in build.gradle
android/app/build.gradle

Assessment against linked issues

Issue Objective Addressed Explanation
#1340 Build a version of the app compatible with Android versions prior to API 30.
#1340 Build a version of the app compatible with Android versions API 30 and above.
#1340 Ensure the app is available on the Fdroid store.

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that minSdkVersion and targetSdkVersion are defined only inside productFlavors, the build will fail unless a flavor is explicitly specified. Isn't it ?
so you mat define a default flavor using a Gradle property or make it clear in README.md how to specify the desired flavor?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have made a suugested change in the workfllow and updated the readme to use the correct commands

Copy link
Member

@samruddhi-Rahegaonkar samruddhi-Rahegaonkar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If someone runs flutter build without a flavor, the build will fail.
so i think keep a default flavour in fallback.
what do you think ?

@nope3472
Copy link
Contributor Author

nope3472 commented Jul 7, 2025

@samruddhi-Rahegaonkar yes i am figuring it out

@hpdang hpdang requested a review from AsCress July 10, 2025 14:54
@mariobehling mariobehling requested review from mariobehling and Jhalakupadhyay and removed request for AsCress July 14, 2025 06:50
Copy link
Member

@mariobehling mariobehling left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Thanks, this topic is super tricky as we experienced in the past: In the past it also involved providing different manifest files for different versions. Please check if adjusting the manifest files is necessary for these builds too.
  2. Please ensure there is a fallback as mentioned in the other review.

@mariobehling
Copy link
Member

Ok, I am merging this for further testing.

@mariobehling mariobehling merged commit b744550 into fossasia:development Sep 10, 2025
9 of 10 checks passed
@nope3472
Copy link
Contributor Author

@mariobehling i think we should revert this pr

@samruddhi-Rahegaonkar
Copy link
Member

@nope3472 are you having trouble while updating beta app ?

@samruddhi-Rahegaonkar
Copy link
Member

I am trying since last 5 minutes its not updating on Android 11.

@nope3472
Copy link
Contributor Author

@samruddhi-Rahegaonkar @mariobehling I think this isn’t fully resolved yet. There are still some changes missing, and other PRs are failing because of it. We should revert this for now, and I’ll try again to fix it properly. Then we can proceed with this issue

@samruddhi-Rahegaonkar
Copy link
Member

@nope3472 Yes we should.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Build two versions for Fdroid supporting pre-11 phones and newer systems
3 participants