我想在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
但是,没有任何帮助,有人知道如何打开该项目吗?
更新: Android版本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
}
答案 0 :(得分: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
}
答案 1 :(得分:0)
检查顶级build.gradle的存储库中是否存在google()
allprojects {
repositories {
jcenter()
google()
}
}
P.S-如果您使用的是Android Studio 3.1或更高版本,则应该可以点击Add Google Maven repository and sync project
并允许Android Studio自行进行必要的更正并重新同步gradle。