Ionic android build error : "All flavors must now belong to a named flavor dimension"

Viewed 16251

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. 
4 Answers

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. Hence cordova-plugin-crosswalk-webview is currently incompatible with cordova-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):

android { 
    ...
    flavorDimensions "default"
    ...
} 

Update

If you want to build with Gradle v4/cordova-android@6.4+ and cordova-plugin-crosswalk-webview, update to Gradle v4 then install cordova-android off the master branch, since this PR to resolve the "flavours" error with multiple APK builds has now been merged:

cordova platform rm android 
  && cordova platform add https://github.com/apache/cordova-android

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

gradle -v

If if's > 4.x, downgrade it!

Related