Android Studio 3.0 Channel Packaging Problems

Keywords: Android Gradle Java

;

Recently upgraded to Android Studio 3.0, there was a sudden error when packaging the test. The error is as follows:

Error:Cannot choose between the following configurations of project :UMUpdate:  
  - debugApiElements  
  - debugRuntimeElements  
  - releaseApiElements  
  - releaseRuntimeElements  
All of them match the consumer attributes:  
  - Configuration 'debugApiElements':  
      - Found com.android.build.api.attributes.BuildTypeAttr 'debug' but wasn't required.  
      - Found com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' but wasn't required.  
      - Found com.android.build.gradle.internal.dependency.VariantAttr 'debug' but wasn't required.  
      - Found org.gradle.api.attributes.Usage 'java-api' but wasn't required.  
  - Configuration 'debugRuntimeElements':  
      - Found com.android.build.api.attributes.BuildTypeAttr 'debug' but wasn't required.  
      - Found com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' but wasn't required.  
      - Found com.android.build.gradle.internal.dependency.VariantAttr 'debug' but wasn't required.  
      - Found org.gradle.api.attributes.Usage 'java-runtime' but wasn't required.  
  - Configuration 'releaseApiElements':  
      - Found com.android.build.api.attributes.BuildTypeAttr 'release' but wasn't required.  
      - Found com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' but wasn't required.  
      - Found com.android.build.gradle.internal.dependency.VariantAttr 'release' but wasn't required.  
      - Found org.gradle.api.attributes.Usage 'java-api' but wasn't required.  
  - Configuration 'releaseRuntimeElements':  
      - Found com.android.build.api.attributes.BuildTypeAttr 'release' but wasn't required.  
      - Found com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' but wasn't required.  
      - Found com.android.build.gradle.internal.dependency.VariantAttr 'release' but wasn't required.  
      - Found org.gradle.api.attributes.Usage 'java-runtime' but wasn't required.  

Looking at the following, I find that if your app moudle s have several buildTypes packaged on 3.0, there must be several moudles to depend on (no implementation is possible). What does that mean?
For example, under your app directoryBuild.gradleIn the file, buildTypes are as follows:

buildTypes {
        release {
            buildConfigField "boolean", "LOG_DEBUG", "false"
            zipAlignEnabled true
            shrinkResources true
            minifyEnabled true
            proguardFiles 'proguard-rules.pro'
        }

        debug {
            buildConfigField "boolean", "LOG_DEBUG", "true"
            zipAlignEnabled true
            shrinkResources false
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }

        debug2{

        }
    }

At the same time, your app relies on a third-party moudle, such as UMUpdate, which is located in the UMUpdate directoryBuild.gradleThe three buildTypes above must also be declared in the file, although they can be left untouched:

buildTypes {
        release {

        }

        debug {

        }

        debug2{

        }
    }

Posted by unxposed on Fri, 05 Jun 2020 10:15:43 -0700