作者:lc蓝晨 | 来源:互联网 | 2023-05-19 23:18
我有一个项目,我想更改为使用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的细节.但我不知道为什么这不起作用.
1> Einar Sundgr..:
解决问题的方法与此问题中的建议相同,
我将repositories
标记更改为:
repositories {
mavenCentral()
jcenter {
url "http://jcenter.bintray.com/"
}
}