Einar Sundgren
Einar Sundgren

Reputation: 4423

Failing to include libraries by Maven to Android studio

I have a project which I want to change to use Maven to include the libraries for OSMDroid instead of local dependencies. According the OSM Droid tutorial I need to include the following dependencies:

dependencies {
    compile 'org.osmdroid:osmdroid-android:4.2'
    compile 'org.slf4j:slf4j-simple:1.6.1'
}

And from this SO post I need to add a line to be able to use Maven through the gradle:

repositories {
    mavenCentral()
}

That makes my basic build.gradle for Module: app to this:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.1"

    defaultConfig {
        applicationId "se.einarsundgren.anApp"
        minSdkVersion 14
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
     }
 }

repositories {
    mavenCentral()
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:21.0.3'
    compile 'org.osmdroid:osmdroid-android:4.2'
    compile 'org.slf4j:slf4j-simple:1.6.1'
}

This results in the errors from Gradle sync:

 Error:(29, 13) Failed to resolve: org.slf4j:slf4j-simple:1.6.1
 Error:(28, 13) Failed to resolve: org.osmdroid:osmdroid-android:4.2

This is the error I get from Gradle build when I try to compile:

Error:A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:_debugCompile'.
   > Could not resolve org.osmdroid:osmdroid-android:4.4.
     Required by:
         Mappish:app:unspecified
      > Could not GET 'https://jcenter.bintray.com/org/osmdroid/osmdroid-android/4.4/osmdroid-android-4.4.pom'.
         > peer not authenticated
      > Could not GET 'https://repo1.maven.org/maven2/org/osmdroid/osmdroid-android/4.4/osmdroid-android-4.4.pom'.
         > peer not authenticated
   > Could not resolve org.slf4j:slf4j-simple:1.6.1.
     Required by:
         Mappish:app:unspecified
      > Could not GET 'https://jcenter.bintray.com/org/slf4j/slf4j-simple/1.6.1/slf4j-simple-1.6.1.pom'.
         > peer not authenticated
      > Could not GET 'https://repo1.maven.org/maven2/org/slf4j/slf4j-simple/1.6.1/slf4j-simple-1.6.1.pom'.
         > peer not authenticated

This might be an easy error since I'm a newbie both to Maven and to the details of Gradle. But I have no idea why this is not working.

Upvotes: 3

Views: 4345

Answers (1)

Einar Sundgren
Einar Sundgren

Reputation: 4423

What resolved the problem was the same as suggested in this question I changed the repositories tag to:

repositories {
    mavenCentral()
        jcenter {
            url "http://jcenter.bintray.com/"
        }

}

Upvotes: 7

Related Questions