Android Studio 3.0 Compile Issue (Cannot choose between Configurations)

后端 未结 10 826
再見小時候
再見小時候 2020-11-30 04:34

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

10条回答
  •  暖寄归人
    2020-11-30 05:03

    Try

    implementation project(path: ':lp_messaging_sdk', configuration: 'default')

    Note:

    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.

提交回复
热议问题