今天在使用cheesesquare項(xiàng)目時(shí),因?yàn)椴季种惺褂昧?strong>android.support.design庫的好多控件,但是因?yàn)槲沂褂玫氖茿ndroid Studio1.2版本榆苞,AS提示我不能預(yù)覽布局的效果色迂,按照網(wǎng)上的提示修改布局design界面中的API版本、Theme樣式均無果奥额。無奈之下苫幢,只能升級(jí)Android Studio版本(2.0)。
?開始一切還好垫挨,plugins也能正常更新韩肝,但是當(dāng)項(xiàng)目Gradle Sync的時(shí)候,一直Refreshing Gradle Project九榔。
?之前翻了墻哀峻,在grade-wrapper.properties中設(shè)置:
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
?可以直接同步的到,無奈不知是代理服務(wù)器出問題了還是gradle官網(wǎng)的問題哲泊,一直在同步(肯定是代理的問題)剩蟀。
?網(wǎng)上各種找資料切威,想起來之前有人說把gradle-2.10-all.zip包下載下來喻旷,上傳到百度云,在grade-wrapper.properties貼上百度云的地址牢屋,AS直接報(bào)Response 403(我并不知道這是什么錯(cuò))且预。
?又想起同事說的設(shè)置本地Gradle同步的方法槽袄,在AS的Setting中設(shè)置offline work和Gradle home。不知道是不是因?yàn)镸ac的問題锋谐,grade相關(guān)的內(nèi)容在.gradle文件夾下遍尺,隱藏的文件夾,在Setting里面引入之后第一次可以涮拗,再次進(jìn)入Setting后發(fā)現(xiàn)設(shè)置的gradle home提示無效的路徑乾戏,然后打開AS之后又進(jìn)入到Refresh Gradle Project狀態(tài)中……然后整個(gè)人就抓狂了……
?怒上Gradle官網(wǎng),發(fā)現(xiàn)能正常訪問啊……(估計(jì)這時(shí)候代理又可以了)三热,然后打開AS Gradle Sync果斷起作用了鼓择,然后整個(gè)項(xiàng)目又可以Sync了,然后淚奔了……打開Module中的布局文件就漾,發(fā)現(xiàn)效果可以預(yù)覽了呐能,整個(gè)人癲狂了……
遂寫下該文,紀(jì)念一下抑堡。
再提一點(diǎn):
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.