【问题标题】:Could not find com.android.tools.build:gradle:3.0.1. project from Github找不到 com.android.tools.build:gradle:3.0.1。来自 Github 的项目
【发布时间】:2019-07-13 17:07:52
【问题描述】:

我想在 Android Studio 中打开十个https://github.com/mukundmadhav/Wordpress-to-Android-app 项目。但是,我有一个问题。

我遇到了错误

错误:找不到 com.android.tools.build:gradle:3.0.1。 在以下位置搜索: 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 要求: 项目 : 添加 Google Maven 存储库并同步项目 打开文件

我尝试用这些方法解决问题

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

但是,没有任何帮助,有人知道如何打开这个项目吗?

更新: 安卓版本 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
}

【问题讨论】:

    标签: android gradle


    【解决方案1】:

    存储库中应该有 google() 存储库,用于搜索 google 存储库中的插件/库。

    另外,com.android.tools.build 的版本号应与 Android Studio 版本匹配。例如:对于 Android studio 3.4.1,类路径依赖应该是:

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

    这是 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
    }
    

    【讨论】:

      【解决方案2】:

      检查 google() 是否存在于顶级 build.gradle 的存储库中

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

      P.S - 如果您使用的是 Android Studio 3.1 或更高版本,您应该可以点击 Add Google Maven repository and sync project 并允许 Android Studio 自行进行必要的更正并重新同步 gradle。

      【讨论】:

      • 我有 3.4.1 版本的 android studio 我添加了 maven。它不起作用。
      猜你喜欢
      • 2018-07-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-01-05
      • 2018-10-25
      • 1970-01-01
      • 2018-06-28
      • 1970-01-01
      相关资源
      最近更新 更多