Android Studio3.0多渠道打包遇到的问题

最近升级到了Android Studio3.0,在给测试打包的时候突然出错,错误如下:

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.  

查了以下,发现在3.0上打包的话,如果你的app moudle有几种buildTypes的话,所依赖的moudle也必须有几种(不做具体实现也可以),什么意思呢?
比如,你的app目录下的build.gradle文件中,buildTypes如下:

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{

        }
    }

同时,你的app依赖一个第三方moudle比如叫UMUpdate,则在UMUpdate目录下的build.gradle文件中,也必须声明上边儿这三种buildTypes,当然,可以不做具体处理:

buildTypes {
        release {

        }

        debug {

        }

        debug2{

        }
    }

你可能感兴趣的:(Android Studio3.0多渠道打包遇到的问题)