最近我安装了 Android studio 3.0.1 ,并尝试运行一个简单的" Hello World"项目在Gradle项目同步的第一个常见步骤我遇到了这个错误并且它结束了: 无法解析com.android.support:appcompat-v7:26.0.1。 它似乎也是导致 Maven 的常见错误,并且应该通过在build.gradle项目文件中添加以下代码来解决,如https://developer.android.com/topic/libraries/support-library/setup.html中所述
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
这是我的顶级build.gradle文件:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
maven {
url "https://maven.google.com"
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
这是我的app / build.gradle文件:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.example.renayati.myapplication2"
minSdkVersion 15
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary= true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.0.1'
implementation 'com.android.support:design:26.0.1'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:support-vector-drawable:26.0.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:0.5'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:2.2.2'
}
我也是
1.从我的项目根文件夹中删除gradle并再次重建项目,但它没有工作......
2.评论下面这三行,但仍然是相同的错误信息。
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:0.5'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:2.2.2'
没有工作......
我搜索的更多,但我只是听到相同的答案。有人在这帮助我吗?
答案 0 :(得分:0)
将buildToolsVersion "26.0.1"
放在gradle build中的compileSdkVersion下面。并下载26.0.1
存储库