Skip to content

Getting rid of buildDir deprecation #146036

@AbdeMohlbi

Description

@AbdeMohlbi

Use case

Currently, when using the flutter create command to initialize a new Flutter project, the generated Android build.gradle file looks something like that :

allprojects {
    repositories {
        google()
        mavenCentral()
    }
}

rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
    project.evaluationDependsOn(':app')
}

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

well now '.buildDir' is deprecated so an alternative solution may be using '.layout.buildDirectory' instead so it well be :

allprojects {
    repositories {
        google()
        mavenCentral()
    }
}

rootProject.layout.buildDirectory = '../build'
subprojects {
    rootProject.layout.buildDirectory= "${rootProject.layout.buildDirectory}/${project.name}"
}
subprojects {
    project.evaluationDependsOn(':app')
}

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

Proposal

when trying to do that android studio doesn't say anything but gradle is yelling this :

FAILURE: Build failed with an exception.

* Where:
Build file 'C:\Users\bougara computer\StudioProjects\open_food_facts_api_flutter\android\build.gradle' line: 13

* What went wrong:
A problem occurred evaluating root project 'android'.
> A problem occurred configuring project ':app'.
   > Could not create service of type ProjectScopedCacheBuilderFactory using WorkerSharedProjectScopeServices.createProjectScopedCache().
      > Illegal char <:> at index 206: C:\Users\bougara computer\StudioProjects\open_food_facts_api_flutter\android\app\property(org.gradle.api.file.Directory, fixed(class org.gradle.api.internal.file.DefaultFilePropertyFactory$FixedDirectory, C:\Users\bougara computer\StudioProjects\open_food_facts_api_flutter\build))\app\tmp\.cache

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.

BUILD FAILED in 5s
Error: Gradle task assembleDebug failed with exit code 1

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listc: new featureNothing broken; request for a new capabilityc: proposalA detailed proposal for a change to Flutterplatform-androidAndroid applications specificallyt: gradle"flutter build" and "flutter run" on Androidteam-toolOwned by Flutter Tool 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