flavorDimensions gradle error - Android Studio 3.0 Canary 1

匆匆过客 提交于 2019-11-30 08:38:07

Seems like a bug in the Gradle build process, I'm not quite sure why exactly it's not working. I was stuck on this for a while but I was able to fix it by changing

compile project(':util')

to

compile project(path: ':util', configuration: 'default')

Let me know if this works for you!

I had a similar issue using Canary 2, but the proposed solution didn't work. Apparently there is a way to use the implementation from a Local library or project:

// This is the old method and no longer works for local
// library modules:
// debugCompile project(path: ':foo', configuration: 'debug')
// releaseCompile project(path: ':foo', configuration: 'release')

// Instead, simply use the following to take advantage of
// variant-aware dependency resolution. You can learn more about
// the 'implementation' configuration in the section about
// new dependency configurations.
implementation project(':foo')

Reference from Studio Documentation.

I got around this by using gradle 4.3 (with Android Studio 3.0)

To use it with Android Studio 3.0:

  1. Download the binary here: https://gradle.org/releases/
  2. Configure local gradle binary in Android Studio, under preferences...

  1. Then in your gradle file replace compile with either implementation or api depending on your requirements.

references: https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration.html

ALSO: make sure that your external modules (i.e util) have the same flavors as your App or you will get the error outlined in here: Gradle 4.0 Unable to find a matching configuration

From https://issuetracker.google.com/issues/65867056:

You should have only one buildScript block in the root build.gradle. If you are using Composite builds, this is not currently supported by our plugin due to limitations in Gradle.

EDIT: I guess this now works for latest versions of gradle

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!