What to do if you can’t build with the error “Product Flavor names cannot collide with BuildType names” when building with Flutter’s Android app using Flavor
When I implemented a mobile application with Flutter and tried to perform branch processing for each Configuration
called in iOS, I was able to build it on iOS, but I got an error like the title when building Android. So I will leave a memorandum of the cause and the solution.
I used flutter_flavorizr to set Flavor, and initially set the flavor called debug
/ release
.
Reproduction environment
– Flutter (Channel stable, 2.2.3, on macOS 11.4 20F71 darwin-x64, locale
ja-JP)
– Android toolchain – develop for Android devices (Android SDK version
30.0.3)
– Xcode – develop for iOS and macOS(version 13.2.1)
– Android Studio (version 4.2)
– VS Code (version 1.63.2)
I couldn’t set the debug / release to Flavor name!
I wrote the answer in the title, but in the case of Android, the flavor names debug
/ release
are used as a reserved word.
I hadn’t done much Android development, and I was able to build it on iOS without any problems, so I didn’t know the cause at all at first, but I was finally able to find the cause while investigating.
Eventually, I changed the flavor name in {ProjectName} /android/app/build.gradle
to develop
/ production
.
I usually do iOS native development, and Flutter development is done as a sub, so I understand the rules and manners of iOS development to some extent, but I did not know the rules and manners of Android development at all, so again I was reminded that I can write code (only) with Flutter ≠ I can develop Android and iOS apps.
If we want to continue developing Flutter for Android, I think we need to improve not only our pure knowledge of Flutter but also our knowledge and know-how of Android development.
Reference
- http://leckyyyyyyy.github.io/post/2015/android-product-flavor-unavailable-name/