3

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.

Community
  • 1
  • 1
Einar Sundgren
  • 4,325
  • 9
  • 40
  • 59
  • 1
    Are there any errors preceding those ones? The dependency specification looks correct to me, and at least the slf4j-simple artifact exists in the repository. – yole Feb 28 '15 at 16:59
  • @Yole In my eventlog I get this '18:01:57 Gradle build finished with 1 error(s) in 2 sec' Not sure why it says it is 1 error since the messages clearly shows 2. I guess it is because it is the same type. – Einar Sundgren Feb 28 '15 at 17:03
  • @Yole: Added the error from Gradle build. The previous was from Gradle sync. – Einar Sundgren Feb 28 '15 at 17:10
  • The download fails because the https connection to the Maven repository can't be authenticated. Did you do anything with the Java HTTPS configuration? Are you connecting to the internet through some kind of proxy? – yole Feb 28 '15 at 17:13
  • @Yole No, none of those. I'm running a pretty clean installation of Ubuntu 14.10 64 bit. – Einar Sundgren Feb 28 '15 at 17:16

1 Answers1

7

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/"
        }

}
Community
  • 1
  • 1
Einar Sundgren
  • 4,325
  • 9
  • 40
  • 59