详解升级Android Studio3.0时遇到的几个问题

本篇文章主要介绍了升级Android Studio3.0时遇到的几个问题,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧

今天收到了Android Studio3.0更新推送,在升级过程中遇到几个问题,在这里把问题和解决方法记录下,方便要升级的童鞋。如果还有童鞋遇到不同的问题,也可以评论下我做下记录

1.gradle打包,自定义apk名称代码报错(Cannot set the value of read-only property 'outputFile' )

报错

Error:(56, 0) Cannot set the value of read-only property 'outputFile' for ApkVariantOutputImpl_Decorated{apkData=Main{type=MAIN, fullName=debug, filters=[]}} of type com.android.build.gradle.internal.api.ApkVariantOutputImpl.
< a href="openFile:D:\eclipseCode\ipay-android\xinlebao\build.gradle" rel="external nofollow" >Open File</a>​

解决 :修改文件名代码请这样写

?

1

2

3

4

5

android.applicationVariants.all { variant ->

        variant.outputs.all {

          outputFileName = "xinlebao_${defaultConfig.versionName}_${releaseTime()}.apk"

        }

      }

android.applicationVariants.all { variant -> variant.outputs.all { outputFileName = "xinlebao_${defaultConfig.versionName}_${releaseTime()}.apk" } }

2. AAPT2 编译报错 AAPT2 error

报错

Error:java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details

解决:在gradle.properties中关闭APPT2 编译

?

1

android.enableAapt2=false

android.enableAapt2=false

注:如果是eclipse转到as上的项目,可能没有gradle.properties文件,请在项目根目录中手动创建

3.apt插件问题(Error:Cannot choose between the following configurations of project :mylibrary:)

报错:

Error:Cannot choose between the following configurations of project :mylibrary:

- debugApiElements
- debugRuntimeElements
- releaseApiElements
- releaseRuntimeElements
  All of them match the consumer attributes:

解决

?

1

2

3

4

5

6

7

8

//1.在project的build.gradle中删除

classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'

//2.在module的build.gradle中删除

apply plugin: 'android-apt'

//3.将module的build.gradle文件中的dependency

apt 'com.jakewharton:butterknife-compiler:8.1.0'

//改为

annotationProcessor 'com.jakewharton:butterknife-compiler:8.1.0'

//1.在project的build.gradle中删除 classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8' //2.在module的build.gradle中删除 apply plugin: 'android-apt' //3.将module的build.gradle文件中的dependency apt 'com.jakewharton:butterknife-compiler:8.1.0' //改为 annotationProcessor 'com.jakewharton:butterknife-compiler:8.1.0'

其他使用apt的依赖,也要这样更改

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值