I've started a new project on my computer but I'm not able anymore to build for android
When I run
ionic cordova platform run android
I get this error :
All flavors must now belong to a named flavor dimension.
I've started a new project on my computer but I'm not able anymore to build for android
When I run
ionic cordova platform run android
I get this error :
All flavors must now belong to a named flavor dimension.
The "flavours" error will occur if you have the
cordova-plugin-crosswalk-webview
plugin installed in your project and you try to build with Gradle v4.However, if you want to upgrade to
cordova-android@6.4.0
(e.g. to open your Cordova Android platform project in Android Studio 3 to debug native plugin code), you'll need to upgrade to Gradle v4. Hencecordova-plugin-crosswalk-webview
is currently incompatible withcordova-android@6.4.0
.As a manual workaround for the "flavours" error, you can insert a default flavour in the
platforms/android/build.gradle
(see here):Update
If you want to build with Gradle v4/
cordova-android@6.4+
andcordova-plugin-crosswalk-webview
, update to Gradle v4 then installcordova-android
off the master branch, since this PR to resolve the "flavours" error with multiple APK builds has now been merged:I get the same error and i have created a script to solve it.
As there was said in the answer, the problem is: gradle 4 wants flavorDimensions on gradle.build.
If you check here: https://cordova.apache.org/docs/en/latest/guide/platforms/android/#extending-buildgradle
We can create a file named gradle-extra.build with will be included on gradle.build, we just need to create a script to paste this file on /platform/android/.
So i created this file build-extras.gradle in my project root
and the script on ./hooks/after_platform_add/copy_build-extras.gradle.js
You can check about hooks here: https://cordova.apache.org/docs/en/latest/guide/appdev/hooks/index.html
every script under /hooks/after_platform_add will be executed after ionic platform add ***
With this, we don't need to downgrade gradle nor change cordova-android version.
Found the solution. :)
Gradle version was the problem. I had to downgrade from 4.X to 3.5.1, which workds great!
Check you gradle version by doing
If if's > 4.x, downgrade it!