Search code examples
androidopenstreetmaposmdroid

OSM Android dependecies failed to resolve


I'm currently trying to implement OSMDroid in to my project, but doing it has shown in the OSMDroid tutorial (http://osmdroid.github.io/osmdroid/index.html) does not seem to be working.

When I try to sync the Gradle project I get the following message:

Failed to resolve: osmdroid-android

And I have here the full build.gradle(Module: app):

   apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.example.massas.emergency_numbers_pi"
        minSdkVersion 23
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation 'org.osmdroid:osmdroid-android:6.0.0-SNAPSHOT'
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

Am I doing something wrong or is the dependencie just outdated? Should I insert the dependencies in the project build.gradle?

I'm new to android dev, so please bear with me! Thanks


Solution

  • 1) Make sure you have added the repository. You need maven central for stable releases and sonatype for snapshot. Instructions for that are included in the documentation but for the sake of this response:

    Current stable:

    repositories {
        mavenCentral()
    }
    
    dependencies {
        implementation 'org.osmdroid:osmdroid-android:6.0.1'
    }
    

    Current snapshot:

    repositories {
        mavenCentral()
        maven{
            url  'https://oss.sonatype.org/content/repositories/snapshots/'
            name 'OSS-Sonatype'
        }
    }
    dependencies {
        implementation 'org.osmdroid:osmdroid-android:6.0.2-SNAPSHOT'
    }
    

    Note: you can also add repositories to your root gradle file to the allprojects section.

    2) You should use the stable version (6.0.1 at the time of writing) uless you have a specific reason to use snapshot.