Skip to content

Bug persists: Release build fails with dynamic install-time module on Flutter 3.35.0+ (compileOnly dependency issue) #177037

@devhpmobile

Description

@devhpmobile

Steps to reproduce

This issue is still reproducible on Flutter 3.35.0+, even though the original report (#175713) was closed.
The problem described there has not been resolved — the release build continues to fail when using a dynamic install-time module that includes compileOnly dependencies.

After further investigation, I found that this issue originates from the FlutterPlugin.kt file, which is part of Flutter’s own referenced source code, specifically in the following code snippet:

rootProject.allprojects {
    repositories.maven {
        url = uri(repository!!)
    }
    if (plugins.hasPlugin("com.android.application") && isInvokedFromAndroidStudio()) {
        dependencies.add("compileOnly", "io.flutter:flutter_embedding_debug:$engineVersion")
        dependencies.add("compileOnly", "io.flutter:armeabi_v7a_debug:$engineVersion")
        dependencies.add("compileOnly", "io.flutter:arm64_v8a_debug:$engineVersion")
        dependencies.add("compileOnly", "io.flutter:x86_64_debug:$engineVersion")
    }
}
Image

I temporarily modified the code as follows, and the build succeeded:

rootProject.allprojects {
            repositories.maven {
                url = uri(repository!!)
            }
            if (plugins.hasPlugin("com.android.application") && isInvokedFromAndroidStudio()) {
                dependencies.add("debugImplementation", "io.flutter:flutter_embedding_debug:$engineVersion")
                dependencies.add("debugImplementation", "io.flutter:armeabi_v7a_debug:$engineVersion")
                dependencies.add("debugImplementation", "io.flutter:arm64_v8a_debug:$engineVersion")
                dependencies.add("debugImplementation", "io.flutter:x86_64_debug:$engineVersion")
            }
        }
Image

This is the FlutterPlugin.kt file from version 3.32.6, and it does not contain the line in question.
Please take a look at my analysis and detailed description above for further context.

        val hostedRepository: String =
            System.getenv(FlutterPluginConstants.FLUTTER_STORAGE_BASE_URL)
                ?: FlutterPluginConstants.DEFAULT_MAVEN_HOST
        val repository: String? =
            if (FlutterPluginUtils.shouldProjectUseLocalEngine(project)) {
                project.property(PROP_LOCAL_ENGINE_REPO) as String?
            } else {
                "$hostedRepository/${engineRealm}download.flutter.io"
            }
        rootProject.allprojects {
            repositories.maven {
                url = uri(repository!!)
            }
        }

        project.apply {
            from(
                Paths.get(
                    flutterRoot!!.absolutePath,
                    "packages",
                    "flutter_tools",
                    "gradle",
                    "src",
                    "main",
                    "scripts",
                    "native_plugin_loader.gradle.kts"
                )
            )
        }

Expected results

The project should build successfully in release mode without any errors, as it functions with Flutter versions 3.32.6 and below.

Actual results

The release build process fails with the following error:

The following Android dependencies are set to compileOnly which is not supported:
 -> io.flutter:arm64_v8a_debug:1.0.0-c29809135135e262a912cf583b2c90deb9ded610
 -> io.flutter:armeabi_v7a_debug:1.0.0-c29809135135e262a912cf583b2c90deb9ded610
 -> io.flutter:flutter_embedding_debug:1.0.0-c29809135135e262a912cf583b2c90deb9ded610
 -> io.flutter:x86_64_debug:1.0.0-c29809135135e262a912cf583b2c90deb9ded610.

Code sample

https://github.com/devhpmobile/flutter_android_demo_dynamic_module.git

Screenshots or Video

Image Image

Logs

No response

Flutter Doctor output

Flutter Doctor output
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.35.4, on macOS 26.0 25A354 darwin-arm64, locale en-VN)
[✓] Android toolchain - develop for Android devices (Android SDK version 36.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 26.0)
[✓] Chrome - develop for the web
[!] Android Studio (not installed)
[✓] IntelliJ IDEA Ultimate Edition (version 2025.1.3)
[✓] Connected device (3 available)
! Error: Browsing on the local area network for DS iPhone 15 PM. Ensure the device is unlocked and attached with a cable or associated with the same local area network as this Mac.
The device must be opted into Developer Mode to connect wirelessly. (code -27)
[✓] Network resources

! Doctor found issues in 1 category.

Metadata

Metadata

Assignees

No one assigned

    Labels

    a: buildBuilding flutter applications with the toolplatform-androidAndroid applications specificallyr: fixedIssue is closed as already fixed in a newer versiont: gradle"flutter build" and "flutter run" on Androidteam-androidOwned by Android platform teamtoolAffects the "flutter" command-line tool. See also t: labels.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions