Reputation: 311
I have an app that I upgraded to build with Flutter 2. I'm still to do the null-safety stuff, but one step at a time.
When I do builds (both release and debug) the apk
's and aab
's get output to the wrong location and (in the case of aab
's) this causes flutter to throw up at the end.
In this screenshot you will see the output gets generated to the android/app/build
folder, this is not correct
In the case of building apk
's it also generates it to the build/app/outputs
folder which is better but still not 100% as it should be build/app/outputs/apk/nonprod/release/app-nonprod-release.apk
So my app has two flavors [ prod | nonprod ] and I do builds for aab
's and apk
's on both release and debug builds.
here is also the output of al 4 builds (all on the nonprod
flavor)
flavorDimensions "environment"
productFlavors {
prod {
dimension "environment"
}
nonprod {
dimension "environment"
versionNameSuffix "-test"
applicationIdSuffix ".test"
}
}
So how do I solve this to generate the artefacts to the correct folder
build/app/outputs/apk/{flavor}/{buildType}/app-{flavor}-{buildType}.apk
and
build/app/outputs/bundle/{flavor}{buildType}/app-{flavor}-{buildType}.aab
and not fail completely on appbundle's
Thank you in advance.
Upvotes: 2
Views: 1707
Reputation: 311
So as part of my migration to Flutter 2 I made a mistake.
in android/build.gradle
where the subprojects
are defined I tried being clever and combined them into a single subprojects
block. This caused the problem.
It's important that if you currently have two separate blocks, they are kept separate, like so
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
When generating a new flutter project it will in fact be generated with a single block.
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
project.evaluationDependsOn(':app')
}
Don't try to use that in an older one.
Credit to this answer https://stackoverflow.com/a/63414006/2181352
Upvotes: 3