这是我的gradle文件。我使用的是Appcompat 25.3.1版本,但错误发生在Appcompat 26.1.0上。删除导航SDK包时,此错误会消失。我不明白发生了什么。非常感谢任何帮助。
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "26.0.2"
defaultConfig {
applicationId "com.example.aadhilahmed.test3"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories{
mavenCentral()
}
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:25.3.1'
compile 'com.mapbox.mapboxsdk:mapbox-android-navigation:0.6.2' //error is here
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
}
这是我的错误信息:
Failed to resolve: com.android.support.appcompat-v7:26.1.0
Error:- Install repository and sync project.
Open file.
Show in Project Structure Dialog.
即使点击安装存储库和同步项目也绝对没有。
答案 0 :(得分:0)
在项目级<div vc-recaptcha key="publicKey" lang="en"></div>
文件的repositories
块中添加此内容:
build.gradle
答案 1 :(得分:0)
这是最好的方法。
在根级别gradle.build使用下面的
buildscript {
repositories {
mavenCentral()
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenCentral()
jcenter()
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
并在gradle-wrapper.properties
文件中更改包装器版本,如下所示
distributionUrl=https\://services.gradle.org/distributions/gradle-4.2.1-all.zip
同样在您的应用级别build.gradle中,请确保您使用26 vesion,如下所示
android {
compileSdkVersion 26
buildToolsVersion "26.0.2"
defaultConfig {
applicationId "com.xxxx"
minSdkVersion 16
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}