很抱歉这个愚蠢的问题但是在安装Android Studio之后,在创建新项目时它给了我以下错误:
Error:Failed to resolve: com.android.support:support-core-ui:27.1.1
我在gradle依赖文件中添加了这个依赖项,如下所示:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-
core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:27.+'
compile "com.android.support:support-core-ui:27.1.1"
testCompile 'junit:junit:4.12'
}
但它仍然显示相同的错误。请建议我解决这个问题的一些解决方案。
Build.gradle for My project:
// 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:2.2.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
答案 0 :(得分:2)
您缺少存储库URL 添加以下内容:
buildscript {
repositories {
google()
jcenter()
}
...
}
allprojects {
repositories {
google()
jcenter()
...
}
}
如果您使用的Gradle版本低于4.1,请使用以下代替google()
:
maven {
url 'https://maven.google.com'
// An alternative URL is 'https://dl.google.com/dl/android/maven2/'
}