Android Studio升级3.0.0遇到的问题与解决办法

  • A+
所属分类:Android

前几天,Android Studio终于推送了3.0.0的Stable正式版。其实3.0.0版本的Canary版本都发布很久了,Beta版也发了好几版了。但是我在公司的电脑跟家里的个人电脑的开发环境要保持一致,所以为了工作,我的Android Studio一直采取比较保守的更新策略,只用稳定版本。但既然3.0.0的稳定版都出来了,再不更新那我就没有理由了。

不出意外的、非常正常的、合乎情理的,在从2.3.3升级到3.0.0后,原来的项目无法通过编译了,毕竟这是一次比较大的IDE更新,出问题安全可以理解。还是来看一下有啥问题,以及如何解决吧:

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

- 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.

 

OK,细心的朋友可以发现这是项目主module所依赖的一个library报错了。改动很容易,把主module的build.gradle中的compile  project(':RTRoutineLib') 改成implementation project(':RTRoutineLib')即可。至于compile和implementation的区别,这足以单独列一篇文章了,咱今后再说。

C:\Develop\AndroidStudioSpace\xxxxxxxx(项目名)\app(主module)\build.gradle

Error:android-apt plugin is incompatible with the Android Gradle plugin.  Please use 'annotationProcessor' configuration instead.

最新版Android Studio所搭配的com.android.tools.build:gradle:3.0.0不支持目前1.8版本的apt了,所以先把project的build.gradle中

删掉。然后把module的build.gradle中的apply plugin: 'com.neenbedankt.android-apt'也删掉。再把之前dependencies中类似于apt rootProject.ext.libButterKnifeCompiler中的apt换成annotationProcessor,OK问题解决。

解决了这2个问题,一般大多数工程跑起来是没问题的。感受一下Android Studio 3.0.0带来的强大功能吧。据我所知,很多开发者非常不愿意更新IDE,但现在是移动互联网时代,你用IDE开发的App会经常更新,那么Google发布的给你用来开发App的IDE进行更新也是不难理解的。一个程序员如果抱守残缺,那么其竞争力恐怕很难长久保持。

KaelLi

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: