2
votes

I have some problems with integration MapBox SDK into my project.

Here is description how to add dependency into Gradle: https://www.mapbox.com/mapbox-android-sdk/#gradle

So, I should add this into my build.gradle:

repositories {
    mavenCentral()
}

dependencies {
    compile ('com.mapbox.mapboxsdk:mapbox-android-sdk:0.7.4@aar'){
        transitive=true
    }
}

After that my build.gradle looks like:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"

    defaultConfig {
        applicationId "com.samusko.journeyproject"
        minSdkVersion 15
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

repositories {
    mavenCentral()
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:appcompat-v7:22.1.1'
    compile 'com.android.support:cardview-v7:22.1.1'

    compile ('com.mapbox.mapboxsdk:mapbox-android-sdk:0.7.4@aar'){
        transitive=true
    }
}

When I compile this I have this error:

Error:Failed to resolve: com.android.support:support-v4:22.2.0

I don't know what is wrong :(. Please help me to resolve this error..

1

1 Answers

0
votes

You are missing this line in the gradle file, put it before the "com.mapboxsdk:..." line (the support libraries you used were too old):

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')

    ##### begin fix   
    # modified 2.1.1 to 2.2.0
    compile 'com.android.support:appcompat-v7:22.2.0'
    compile 'com.android.support:cardview-v7:22.2.0'
    ##### end fix   

    compile ('com.mapbox.mapboxsdk:mapbox-android-sdk:0.7.4@aar'){
        transitive=true
    }
}

Note that this version of MapBox is no longer supported upstream. They deprecated it, even tough (IMHO) as I am writing this message the new API is not usable enough.