前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Android Studio3.0多渠道打包遇到的问题

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

作者头像
coderZhen
发布2018-06-28 16:55:32
1.5K0
发布2018-06-28 16:55:32
举报
文章被收录于专栏:Android开发经验

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

代码语言:javascript
复制
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如下:

代码语言:javascript
复制
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,当然,可以不做具体处理:

代码语言:javascript
复制
buildTypes {
        release {

        }

        debug {

        }

        debug2{

        }
    }
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2017.12.12 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档