简体   繁体   中英

Could not find com.android.tools.build:gradle:3.0.1. project from Github

I would like to open ten https://github.com/mukundmadhav/Wordpress-to-Android-app project in Android Studio. However, I have a problem.

I'm getting errors

ERROR: Could not find com.android.tools.build:gradle:3.0.1. Searched in the following locations: https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.pom https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.jar Required by: project : Add Google Maven repository and sync project Open File

I tried to solve the problem with these methods

Gradle 4.1 issue on latest android studio 3.0.1

Could not find com.android.tools.build:gradle:3.0.1

Could not find com.android.tools.build.gradle:3.0.0-alpha7

However, nothing helped, does anyone know how to open this project?

Update: Android Version 3.4.1

build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'
        classpath 'com.google.gms:google-services:3.1.0'

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

allprojects {
    repositories {
        jcenter()
        maven { url "https://maven.google.com" }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

There should be google() repo in repositories which searches plugins/libraries in google repository.

Also, version number for com.android.tools.build should match the Android Studio Version. For example: for Android studio 3.4.1, classpath dependency should be:

classpath 'com.android.tools.build:gradle:3.4.1'

Here is the modified code for build.gradle.

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.4.1'
        classpath 'com.google.gms:google-services:4.2.0'

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

allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

Check if google() is present in repositories in the top level build.gradle

allprojects {
        repositories {
            jcenter() 
            google()
        }
    }

PS - If you're using Android Studio 3.1 or higher, you should be able to click on Add Google Maven repository and sync project and allow Android Studio to make the necessary corrections by itself and resync the gradle.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM