Issue with latest 3.0 build (Beta 2) My project has 1 sub module by a 3rd party so I only have access to their build.gradle.
My project has 3 flavours, snap, uat, pr
When I updated my project from API level 23 to 27 and Gradle to 3.1 this error comes that
Can not choose between different configuration
So to solve this problem.
replace the
compile project(':your projectName')
with
implementation project(':projectname')
in Gradle, this solves the problem.
This error is also due to if the following is NOT true:
android {
flavorDimensions "dimen"
productFlavors {
someProduct {
dimension "dimen"
}
}
}
dependencies {
api project(path: ':module-B')
}
So someProduct
has to exist in B
android {
flavorDimensions "dimen"
productFlavors {
someProduct {
dimension "dimen"
}
}
}
GL
Error:Cannot choose between the following configurations of project.......
There may be gradle writing problems When I changed to the following wording there is no such error
// compile project(':MPChartLib')
implementation project(':MPChartLib')
Maybe when the reference depends on other modules should be written in this implementation
In my, similar, case the solution was:
build.gradle:
android {
defaultConfig {
// because I have two project flavors in that library
missingDimensionStrategy 'project', 'myProjectName'
// because I have a "full" and a "debug" flavor in that library
missingDimensionStrategy 'mode', 'full'
}
buildTypes {
debug { ... }
release { ... }
}
}
dependencies {
// because the project(path:'', configuration:'') did not work in this case
implementation project(':myModuleName1')
implementation project(':myModuleName2')
}
Maybe this helps others ending up here with a similar problem.
If you are using the complex setup where there is a module and than there are some submodules etc. Than you need to add the build variants to the module(say top module) and than to submodule and other modules that might be using your module. You can not directly add to submodule or else android studio will get confused as to which one to pick.
Just to give an Example, let us say there is snapDebug for submodule as build variant, now it should be clubbed with a snapDebug for Top Module or snapDebug of a module using it. If snapDebug is not there in either of them, android studio will get confused which one to pick with the one of other one. Hence the error in latest builds of android studio.
Hope it helps to understand the problem and solution.
Try
implementation project(path: ':lp_messaging_sdk', configuration: 'default')
You can avoid this bug by update gradle to 4.3
check this.
Explanation :
Using Dependency Configurations makes it easy to define and specify what to use in sub-project.
In my answer, we used default configuration and this will publish and expose only the "release" flavor to other Android projects and modules.
Assume you need to include this flavor only with demo flavor or with release flavor, it would be like :
configurations {
// Initializes placeholder configurations that the Android plugin can use when targeting
// the corresponding variant of the app.
demoDebugCompile {}
fullReleaseCompile {}
...
}
dependencies {
// If the library configures multiple build variants using product flavors,
// you must target one of the library's variants using its full configuration name.
demoDebugCompile project(path: ':lp_messaging_sdk', configuration: 'demoDebug')
fullReleaseCompile project(path: ':lp_messaging_sdk', configuration: 'fullRelease')
...
}
And so, in your case, you may use your build flavors, and that's what appeared in the error log.
Cannot choose between the following configurations of project :lp_messaging_sdk
And that's mean, that your lp_messaging_sdk
have various build configurations:-
- debugApiElements
- debugRuntimeElements
- releaseApiElements
- releaseRuntimeElements
And android-studio telling you, that "I can't choose one configuration from these various, Would you define one for me?"
You can read more over here.