无法将Maven的库包含到Android Studio中

埃纳尔·桑德格伦

我有一个项目想要更改为使用Maven包含OSMDroid库,而不是本地依赖项。根据OSM Droid教程,我需要包括以下依赖项:

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

从这篇SO帖子中,我需要添加一行内容,以便能够通过gradle使用Maven:

repositories {
    mavenCentral()
}

这使我的Module:app的基本build.gradle成为:

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

这会导致Gradle同步错误:

 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

这是我尝试编译时从Gradle构建中得到的错误:

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

这可能是一个简单的错误,因为对于Maven和Gradle的细节我都是新手。但是我不知道为什么这不起作用。

埃纳尔·桑德格伦

解决问题的方法与该问题中建议的相同,我将repositories标签更改为:

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

}

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章