ByneappLLC / flutter_config

Config Variables for your Flutter Apps.
BSD 2-Clause "Simplified" License
148 stars 66 forks source link

Flutter config broken for Gradle 8.1.0 #63

Open derekpitts28 opened 1 year ago

derekpitts28 commented 1 year ago

See solution here for fix: https://issuetracker.google.com/issues/277166577

From the issue:

Status: Won't Fix (Intended Behavior)
Thanks for sharing the repro. The issue is in the build script that triggers eager task creation, which breaks AGP task configuration. Please use:

tasks.configureEach {
     if(name.startsWith("connectedNet")) {
        enabled = false
    }
}
instead of tasks.whenTaskAdded (see [Gradle docs](https://docs.gradle.org/current/userguide/task_configuration_avoidance.html#sec:old_vs_new_configuration_api_overview) for more info). After this modification, R8 will fail with missing classes, so please follow instructions at https://developer.android.com/build/releases/past-releases/agp-7-0-0-release-notes#r8-missing-class-warning to fix that.

Sidenote: I'd advise against disabling tasks in this way. If you'd like to disable instrumented tests, see https://github.com/android/gradle-recipes/blob/0db8094e5a1a9661f61958db85380320157f5050/Groovy/disableAndroidTest/app/build.gradle#L15.
kevtechi commented 8 months ago

Can confirm, builds failing because namespace is not set in this plugin.

When you try and set it manually, it generates the error in the link above.

Was not able to solve.

derekpitts28 commented 7 months ago

Any idea when we can expect a bump to AGP 8.0+?

unacorbatanegra commented 2 months ago

In the mean time you can add this to the end of your build.gradle it will fix the problem for all the packages

subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}

subprojects {
    afterEvaluate { project ->
        if (project.hasProperty('android')) {
            project.android {
                if (namespace == null) {
                    namespace project.group
                }
            }
        }        
    }

}

subprojects {
    project.evaluationDependsOn(':app')
}

tasks.register("clean", Delete) {
    delete rootProject.buildDir
}