10

a few days ago i have installed android studio 3.0 (preview) and after that in stable version (studio 2.3.3) when i try to import project it give me an error. In preview everything works fine. this is an error:

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 :
Tornike Kurdadze
  • 955
  • 2
  • 10
  • 24
  • Possible duplicate of [Could not find com.android.tools.build:gradle:3.0.0-alpha1 in circle ci](https://stackoverflow.com/questions/44071080/could-not-find-com-android-tools-buildgradle3-0-0-alpha1-in-circle-ci) – Ciro Santilli OurBigBook.com Nov 06 '17 at 16:55

2 Answers2

30

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:

Open your Project level build.gradle Section .

You should add maven { url 'https://maven.google.com' } .

Example

 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' }
        }
    }
IntelliJ Amiya
  • 74,896
  • 15
  • 165
  • 198
2

A better way may be just to use

buildscript {
    repositories {
        google()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.0'
    }
}
Diego Plentz
  • 6,760
  • 3
  • 30
  • 31