天天看點

android studio 最經典的報錯 解決

總是遇到這個問題,今天記錄一下,以後不用總去問了 啊哈

Error:(1, 0) Plugin with id 'com.android.application' not found.

打開報錯的項目的build.gradle,看看有沒有buildscript{}

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

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}      

需要注意的是:

classpath 'com.android.tools.build:gradle:1.5.0'     這個gradle 版本要改成自己使用的 版本 我的是 2.2.2的

解決了這個 還有一個。。。。。。

如圖所示

Error:(39, 17) Failed to resolve: junit:junit:4.12

<a href="openFile:D:/androidstudioProject/CheckBoxRecyclerView/build.gradle" target="_blank" rel="external nofollow" >Show in File</a><br><a href="open.dependency.in.project.structure" target="_blank" rel="external nofollow" >Show in Project Structure dialog</a>

這個就簡單多了,

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:25.2.0-beta1'
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:recyclerview-v7:25.2.0'
}      

直接上解決方案  親們自己對比下哈

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])

    compile 'com.android.support:appcompat-v7:25.2.0'

    compile 'com.android.support:recyclerview-v7:25.2.0'
}      

try Again 一下 完美解決

繼續閱讀