0

Here is my gradle file. I am using Appcompat 25.3.1 version, but the error is on Appcompat 26.1.0. This error goes off when navigation SDK package is removed. I dont understand what is happening. Any help is greatly appreciated.

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'
}

And this is my error message:

Failed to resolve: com.android.support.appcompat-v7:26.1.0
      Error:- Install repository and sync project.
               Open file.
               Show in Project Structure Dialog.

Even clicking on Install repository and sync project does absolutely nothing.

Aadhil Ahmed
  • 111
  • 15

2 Answers2

0

Add this inside your repositories block in your project level build.gradle file:

 allprojects {
    repositories {
        jcenter()
        maven {
            url "https://maven.google.com"
        }
    }
}
Sneh Pandya
  • 8,197
  • 7
  • 35
  • 50
AskNilesh
  • 67,701
  • 16
  • 123
  • 163
0

This is the best way to do it.

In your root level gradle.build use below

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
}

and in your gradle-wrapper.properties file change the wrapper version as below

distributionUrl=https\://services.gradle.org/distributions/gradle-4.2.1-all.zip

also in your app level build.gradle make sure you are using 26 vesion as below

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'
        }
    }
}
Niraj Sanghani
  • 1,493
  • 15
  • 23