美文网首页
谈谈今天升级Android Studio2.0遇到的坑

谈谈今天升级Android Studio2.0遇到的坑

作者: DarkAndroid | 来源:发表于2016-05-17 14:13 被阅读1913次

今天在使用cheesesquare项目时,因为布局中使用了android.support.design库的好多控件,但是因为我使用的是Android Studio1.2版本,AS提示我不能预览布局的效果,按照网上的提示修改布局design界面中的API版本、Theme样式均无果。无奈之下,只能升级Android Studio版本(2.0)。

 开始一切还好,plugins也能正常更新,但是当项目Gradle Sync的时候,一直Refreshing Gradle Project。

 之前翻了墙,在grade-wrapper.properties中设置:

distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip

 可以直接同步的到,无奈不知是代理服务器出问题了还是gradle官网的问题,一直在同步(肯定是代理的问题)。

 网上各种找资料,想起来之前有人说把gradle-2.10-all.zip包下载下来,上传到百度云,在grade-wrapper.properties贴上百度云的地址,AS直接报Response 403(我并不知道这是什么错)。

 又想起同事说的设置本地Gradle同步的方法,在AS的Setting中设置offline work和Gradle home。不知道是不是因为Mac的问题,grade相关的内容在.gradle文件夹下,隐藏的文件夹,在Setting里面引入之后第一次可以,再次进入Setting后发现设置的gradle home提示无效的路径,然后打开AS之后又进入到Refresh Gradle Project状态中……然后整个人就抓狂了……

 怒上Gradle官网,发现能正常访问啊……(估计这时候代理又可以了),然后打开AS Gradle Sync果断起作用了,然后整个项目又可以Sync了,然后泪奔了……打开Module中的布局文件,发现效果可以预览了,整个人癫狂了……
遂写下该文,纪念一下。

再提一点:

Gradle sync failed: /Applications/Android Studio.app/Contents/gradle/gradle-X.X.X/lib/plugins/gradle-diagnostics-X.X.X.jar (No such file or directory)

解决方法:
To solve the Gradle sync error, open gradle-wrapper.properties file and update the Gradle wrapper distribution version from:

distributionUrl=https\://services.gradle.org/distributions/gradle-X.X.X-all.zip

To:

 Android Studio 1.3 :

distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip

 Android Studio 1.5:

distributionUrl=https\://services.gradle.org/distributions/gradle-2.8-all.zip

 Android Studio 2.0 :

distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip

 You can find the latest Gradle wrapper version visiting:
  https://services.gradle.org/distributions/

 Make sure your project build.gradle file contains the new repository and the new classpath:

buildscript {
  repositories {
      jcenter()
  }
  dependencies {
    classpath 'com.android.tools.build:gradle:1.5.0'
  }
}
allprojects {
  repositories {
      jcenter()
  }
}

This is not strictly related to the question problem, but since we are already migrating to the new IDE preview it's better to make sure everything is in place.

相关文章

网友评论

      本文标题:谈谈今天升级Android Studio2.0遇到的坑

      本文链接:https://www.haomeiwen.com/subject/lcazlttx.html