Skip to content

# Flutter Dynamic Feature Module Release Build Issue Minimal reproducible example for Flutter 3.35.0+ release build failures with Android dynamic install-time modules. Issue stems from `compileOnly` dependency conflicts. This repo helps illustrate and investigate. To successfully build, use Flutter SDK 3.32.6 or lower as a workaround.

Notifications You must be signed in to change notification settings

devhpmobile/flutter_android_demo_dynamic_module

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Flutter Dynamic Feature Module Release Build Issue

This minimal example illustrates a release build error in Flutter 3.35.0+ when using Android dynamic install-time modules. The error originates from a compileOnly dependency conflict. To successfully build, using Flutter SDK 3.32.6 or lower can serve as a temporary workaround.

Problem Description

For Flutter applications integrated with Android dynamic install-time modules, release builds (using flutter build appbundle or flutter build apk --release) with Flutter SDK versions 3.35.0 and above may fail. The error is typically related to compileOnly dependency conflicts during the build process, especially when shared library versions clash between the main module and dynamic feature modules.

Note: This error only occurs when building or running in release mode. Debug mode will not exhibit this error.

Steps to Reproduce the Issue

This project is pre-configured with a dynamic feature module. Follow these steps to reproduce the error:

  1. Check Flutter SDK version: Ensure you are using Flutter SDK version 3.35.0 or newer. You can check the version with the command:

    flutter --version

    If you are on an older version, update Flutter: flutter upgrade.

  2. Prepare the environment: Run the following commands in the project's root directory to ensure dependencies are fetched and the build cache is clean:

    flutter clean
    flutter pub get
  3. Attempt to Build or Run Release (Will fail) using Android Studio / IntelliJ IDEA:

    • Open the android directory of the project in Android Studio or IntelliJ IDEA (Use File -> Open and select the android folder within your Flutter project).
    • Wait for Gradle to synchronize the project.
    • In the Build Variants window (usually on the left or bottom side of the IDE), select release for all relevant modules (your app module and your dynamic feature module).
    • Perform one of the following actions to trigger a release build:
      • Select Build -> Make Project (or Rebuild Project).
      • Select Build -> Build Bundle(s) / APK(s) -> Build Bundle(s) (or Build APK(s)).
      • Press the Run/Debug button (green arrow icon) on the toolbar after selecting a device or emulator, ensuring the run configuration is set to release mode.
    • The build or run process will stop with error messages in the IDE's Build or Run window, typically indicating dependency conflicts or compileOnly-related issues, which are characteristic of dynamic feature modules.

Temporary Solution (Successful Build)

To confirm that downgrading the Flutter SDK resolves the issue, follow these steps:

  1. Downgrade Flutter SDK: Switch the Flutter SDK to version 3.32.6:

    flutter downgrade 3.32.6

    Note: After downgrading Flutter, you may need to update the Dart SDK version in the pubspec.yaml file (under environment: sdk:) to ensure compatibility with the downgraded Flutter version. For example, Flutter 3.32.6 might require a different Dart SDK version than Flutter 3.35.0+.

  2. Prepare the environment again: After downgrading, clean and fetch dependencies again:

    flutter clean
    flutter pub get
  3. Attempt to Build or Run Release again (Will succeed) using Android Studio / IntelliJ IDEA:

    • Ensure you still have the android directory of the project open in Android Studio / IntelliJ IDEA.
    • In the Build Variants window, ensure that release is still selected for the modules.
    • Perform one of the following actions to trigger a release build:
      • Select Build -> Make Project (or Rebuild Project).
      • Select Build -> Build Bundle(s) / APK(s) -> Build Bundle(s) (or Build APK(s)).
      • Press the Run/Debug button (green arrow icon) on the toolbar, ensuring the run configuration is set to release mode.
    • This time, the build or run process should succeed, confirming that the error only occurs with Flutter SDK versions 3.35.0 and above when dynamic feature modules are present.

About

# Flutter Dynamic Feature Module Release Build Issue Minimal reproducible example for Flutter 3.35.0+ release build failures with Android dynamic install-time modules. Issue stems from `compileOnly` dependency conflicts. This repo helps illustrate and investigate. To successfully build, use Flutter SDK 3.32.6 or lower as a workaround.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published