我有一个项目,我想更改它以使用 Maven 来包含 OSMDroid 的库而不是本地依赖项。根据OSM Droid tutorial我需要包含以下依赖项:
dependencies {
compile 'org.osmdroid:osmdroid-android:4.2'
compile 'org.slf4j:slf4j-simple:1.6.1'
}
然后从这个 SO post我需要添加一行才能通过 gradle 使用 Maven:
repositories {
mavenCentral()
}
这使得我的基本 build.gradle for Module: app 变成了这个:
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 细节的新手。但我不知道为什么这不起作用。
最佳答案
解决问题的方法与 this question 中的建议相同
我将 repositories
标签更改为:
repositories {
mavenCentral()
jcenter {
url "http://jcenter.bintray.com/"
}
}
关于android - 无法将 Maven 的库包含到 Android Studio,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28784323/