Android Studio 更新3.0 记录

来源:互联网 发布:淘宝卖家二维码生成 编辑:程序博客网 时间:2024/05/16 05:05
官方指南: https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration.html

基本上遇到的问题都在官方指南上列出来了,下面列出的是我自己遇到的问题。


1. 下载gradle4.1,一直refresh gradle project卡住不动
参考资料: http://blog.csdn.net/qq_28336351/article/details/74178349
解决办法:手动下载gradle包,再导入。
下载地址: http://services.gradle.org/distributions/
android studio设置:
gradle/wrapper/gradle-wrapper.properties

distributionUrl=file:/Users/用户名/.gradle/wrapper/dists/gradle-4.1-all.zip


2.  报错“Cannot set the value of read-only property 'outputFile' ......“

build.gradle中,

  • 修改原来的 each 为 all 
  • 原来需要指定 outputFile,改为只需要指定 outputFileName

// If you use each() to iterate through the variant objects,// you need to start using all(). That's because each() iterates// through only the objects that already exist during configuration time—// but those object don't exist at configuration time with the new model.// However, all() adapts to the new model by picking up object as they are// added during execution.android.applicationVariants.all { variant ->    variant.outputs.all {        outputFileName = "${variant.name}-${variant.versionName}.apk"    }}



3. 报错:The specified Android SDK Build Tools version (26.0.0) is ignored


按照指示,删除buildToolsVersion,刷新


4. 报错: Could not find com.android.support:cardview-v7:26.0.2.

查看了sdk manager,android support repository已经更新了。

参考资料: https://stackoverflow.com/a/45342389
build.gradle中增加google()

allprojects {    repositories {    google()        jcenter()    }}


5. Error:android-apt plugin is incompatible with the Android Gradle plugin.  Please use 'annotationProcessor' configuration instead.
参考资料: http://www.cnblogs.com/whoislcj/p/6148410.html
android-apt 是管理annotation的一个工具,不再更新了。建议使用谷歌官方的annotationProcessor。
删除build.gradle中关于apt的所有内容, dependencies中原来的apt改为annotationProcessor。
//annotationsannotationProcessor "org.androidannotations:androidannotations:$AAVersion"



6. 报错: java.lang.NoSuchMethodError: No static method getFont



原因是多个support包使用了不同的版本,全部统一使用27.0.0,重新build,就可以了。


原创粉丝点击