2017-06-20 252 views
11

幾天前我已經安裝了android studio 3.0(預覽版),之後在穩定版本(studio 2.3.3)當我嘗試導入項目時它給了我一個錯誤。 在預覽中一切正常。 這是一個錯誤:找不到gradle 3.0.0-alpha4

Error:Could not find com.android.tools.build:gradle:3.0.0-alpha4. 
Searched in the following locations: 
    file:/C:/Program Files/Android/Android Studio/gradle/m2repository/com/android/tools/build/gradle/3.0.0-alpha4/gradle-3.0.0-alpha4.pom 
    file:/C:/Program Files/Android/Android Studio/gradle/m2repository/com/android/tools/build/gradle/3.0.0-alpha4/gradle-3.0.0-alpha4.jar 
    https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.0-alpha4/gradle-3.0.0-alpha4.pom 
    https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.0-alpha4/gradle-3.0.0-alpha4.jar 
Required by: 
    project : 
+0

的[可能的複製找不到com.android.tools.build:gradle:3.0.0-alpha1在圈ci](https://stackoverflow.com/questions/44071080/could-not-find-com-android-tools-buildgradle3-0-0-alpha1-in-circle-ci) –

回答

29

If you're opening an existing project using Android Studio 3.0 Preview 1 or later, follow the prompts to automatically update your project to the latest version of the Android plugin. To manually update your project, include the maven repo and change the plugin version in your project-level build.gradle file as follows:

打開項目水平build.gradle節。

您應該添加maven { url 'https://maven.google.com' }

buildscript { 
     repositories { 
      jcenter() 
      // You need to add the following repository to download the new plugin. 
      maven { url 'https://maven.google.com' } 
     } 
     dependencies { 
      classpath 'com.android.tools.build:gradle:3.0.0-alpha4' // Same for alpha6 

     } 
    } 

    allprojects { 
     repositories { 
      jcenter() 
      maven { url 'https://maven.google.com' } 
     } 
    } 
+0

我已經添加buildsctipt和所有項目但它不起作用 –

+0

你能分享你的'build.gradle' –

+0

'清潔重建'和'重新啓動'你的IDE –

2

一種更好的方式,可以只使用

buildscript { 
    repositories { 
     google() 
    } 

    dependencies { 
     classpath 'com.android.tools.build:gradle:3.0.0' 
    } 
} 
相關問題