3

I having problem to compile new gradle as shown below here :

Error:Could not find com.android.tools.build:gradle:3.0.0-beta2. Searched in the following locations: file:/C:/Program Files/Android/android-studio-preview/gradle/m2repository/com/android/tools/build/gradle/3.0.0-beta2/gradle-3.0.0-beta2.pom file:/C:/Program Files/Android/android-studio-preview/gradle/m2repository/com/android/tools/build/gradle/3.0.0-beta2/gradle-3.0.0-beta2.jar https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.0-beta2/gradle-3.0.0-beta2.pom https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.0-beta2/gradle-3.0.0-beta2.jar Required by: project : Open File

This is my gradle :

buildscript {
ext.kotlin_version = '1.1.4-2'
repositories {
    jcenter()
}
dependencies {
    classpath "com.android.tools.build:gradle:3.0.0-beta2"
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}
Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841
Mohd Hafiz
  • 177
  • 2
  • 12
  • Possible duplicate of [android studio 3.0 Canary 1 : project refresh failed](https://stackoverflow.com/questions/44039762/android-studio-3-0-canary-1-project-refresh-failed) – DeKaNszn Aug 25 '17 at 06:38
  • https://developer.android.com/studio/preview/features/new-android-plugin-migration.html – DeKaNszn Aug 25 '17 at 06:41
  • 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

8

You have to add the gradle maven repo:

 maven { url 'https://maven.google.com' }

Something like:

buildscript {
    //..
    repositories {
        jcenter()
        maven { url 'https://maven.google.com' }
    }
    //..
}

You can also use the google() shortcut if you are using Android Studio 3.x and gradle v.4

buildscript {
    repositories {
        ...
        // You need to add the following repository to download the
        // new plugin.
        google()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.0-beta-2'
    }
}
Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841
  • For me it worked just by adding google(), but for example, if I was using Android Studio 2.x, will it work with google()? Or do I have to add the maven repo? – HyunJin Aug 30 '17 at 23:13
  • 1
    @HyunJin in my experience it requires gradle plugin 3.3, gradle v.4 and Android Studio v.3.x. May be it can also work with the latest Android Studio 2.3 but always with plugin 3.3 and gradle v.4 – Gabriele Mariotti Aug 31 '17 at 05:36
0

I resolved it by adding depemdency in this manner-

dependencies {
    classpath 'com.android.tools.build:gradle:3.0.0-beta4' 

}
Aayushi
  • 1,736
  • 1
  • 26
  • 48