0

这是我的 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.

即使单击安装存储库和同步项目也绝对没有任何作用。

4

2 回答 2

0

repositories在项目级别build.gradle文件的块中添加以下内容:

 allprojects {
    repositories {
        jcenter()
        maven {
            url "https://maven.google.com"
        }
    }
}
于 2017-10-27T04:47:42.577 回答
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 版本,如下所示

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'
        }
    }
}
于 2017-10-27T05:08:57.663 回答