[Android][AS]Error:Failed to find Build Tools revision 26.0.2

今天手癢,去升級 AS 到3.0.1,然後出現如下錯誤,

===

Error:Failed to find Build Tools revision 26.0.2

Consult IDE log for more details (Help | Show Log)

<a href="install.build.tools">Install Build Tools 26.0.2 and sync project</a>

===================================

原因:

Sdk\build-tools目錄下沒有 26.0.2 安裝版本

================================

嘗試解決方法:

從同事那 copy 一份,放到以下目錄,

C:\Users\xxx\AppData\Local\_Android\Sdk\build-tools\26.0.2

===============================================

結果報如下錯誤:


Error:Could not run build action using Gradle distribution 'https://services.gradle.org/distributions/gradle-4.1-all.zip'.

===============================================

然後按如下方法改:


dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}
将appcompat-v7:26.1.0' 改为:
appcompat-v7:26.+'
将以下这两行代码删掉.然后同步:
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation'com.android.support.test.espresso:espresso-core:3.0.1'


=====================================================
結果報以下錯誤

Error:Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve junit:junit:4.12.
<a href="openFile:D:/Users/champwang/AndroidStudioProjects/My_Application_20171218/app/build.gradle">Open File</a><br><a href="Unable to resolve dependency for &#39;:app@debugUnitTest/compileClasspath&#39;: Could not resolve junit:junit:4.12.">Show Details</a>

==========================================

將以下這行刪除,然後就OK了。

    testImplementation 'junit:junit:4.12'

==========================================


总结,从一开始按以下改就可以了,改的地方为 app下的  build.gradle 。

=====================================

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
//    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support:appcompat-v7:26.+'

    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
//    testImplementation 'junit:junit:4.12'
//    androidTestImplementation 'com.android.support.test:runner:1.0.1'
//    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}


============================================== 


现在还有一个小问题, 每次去 创建新的 activity的 时候, 又會去修改上面這一段。
如果有新建 aty, 還是要手動再改一下。 







猜你喜欢

转载自blog.csdn.net/champwang/article/details/78831883
今日推荐