无法构建osmdroid存储库

时间:2015-10-14 21:25:50

标签: android android-studio osmdroid jcenter

我已经从中克隆了osmdroid存储库 https://github.com/osmdroid/osmdroid 我无法建立它。我专注于存储库中的OpenStreetMapViewer项目。

我认为问题的根源是我不能使用maven因为我在防火墙后面。对于我创建或克隆的所有Android Studio项目,我必须通过删除来修改build.gradle mavenCentral而是使用:

jcenter {
    url "http://jcenter.bintray.com/"
}

对于此项目,build.gradledependencies区块中包含此行:

dependencies {
    compile 'com.android.support:appcompat-v4:22.2.+'
    compile 'org.osmdroid:osmdroid-android:4.3'
    compile 'org.osmdroid:osmdroid-third-party:4.3'
}

但是,在这里浏览jcenter: https://bintray.com/bintray/jcenter 我没有看到v4,只有v7(android-support-v7-appcompat)

我尝试将v7作为依赖:

compile 'com.android.support:appcompat-v7:23.0.1'

需要将compileskdversion更改为23。

这样做我得到了这个构建错误:

Error:A problem occurred configuring root project 'OpenStreetMapViewer'.
> Could not resolve all dependencies for configuration ':_debugCompile'.
   > Could not resolve android.support:compatibility-v4:21.0.3.
     Required by:
         :OpenStreetMapViewer:unspecified > org.osmdroid:osmdroid-third-party:4.3
      > Could not GET 'https://repo1.maven.org/maven2/android/support/compatibility-v4/21.0.3/compatibility-v4-21.0.3.pom'.
         > peer not authenticated
   > Could not resolve com.google.android.gms:google-play-services:22.0.0.
     Required by:
         :OpenStreetMapViewer:unspecified > org.osmdroid:osmdroid-third-party:4.3
      > Could not GET 'https://repo1.maven.org/maven2/com/google/android/gms/google-play-services/22.0.0/google-play-services-22.0.0.pom'.
         > peer not authenticated

所以看来osmdroid确实需要v4,而不是v7

在Android SDK Manager中,我安装了Extras> Android支持存储库22和> Android支持库23.0.1

我该怎么办?

编辑-------------------------------------------
我想我应该在尝试导入项目而不修改任何build.gradle或manifest时发生错误。关键是“How to Maven”上的说明在这种情况下不起作用。

Error: Cause: peer not authenticated
Untrusted Server's certificate - Server's certificate not trusted.
Issued to: Common Name plugins.jetgrains.com
Organization: Jetbrains.s.r.o
Locality: Praha 4 - Nusle
Country: CZ
ST: Praha 4 - Nusle

编辑2 --------------------------------------------- -----------------
如前所述,我从这里克隆了osmdroid:
https://github.com/osmdroid/osmdroid
我将系统环境变量M2_HOME设置为克隆的osmdroid项目的位置。

在settings.xml中:

<localRepository>D:\Users\myusername\AndroidstudioProjects\maven-android-sdk-deployer</localRepository>

我从这里下载了maven:
http://maven.apache.org/download.cgi
解压缩D:\ Program Files \ apache-maven-3.3.3 \ bin,然后我也将其包含在path系统变量中。

在DOS窗口中,我转到M2_HOME并执行以下命令:

  

mvn install

我收到此错误:

[INFO] Scanning for projects...
Downloading: https://repo.maven.apache.org/maven2/com/simpligility/maven/progressive-organization-pom/3.0.0/progressive-organization-pom-3.0.0.pom

[ERROR] Some problems were encountered while processing the POMs:
[FATAL] Non-resolvable parent POM for com.simpligility.android.sdk-deployer:maven-android-sdk-deployer:2.8.0: Could not transfer artifact com.simpligility.maven:progressive-organization-pom:pom:3.0.0 from/to central (https://repo.maven.apache.org/maven2): 
sun.security.validator.ValidatorException: 
PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: 
unable to find valid certification path to requested target and 'parent.relativePath' points at wrong local POM @ line 5, column 11
@ 
The build could not read 1 project -> [Help 1]

The project com.simpligility.android.sdk-deployer:maven-android-sdk-deployer:2.8.0 (D:\maven-android-sdk-deployer\pom.xml) has 1 error
Non-resolvable parent POM for com.simpligility.android.sdk-deployer:maven-android-sdk-deployer:2.8.0: Could not transfer artifact com.simpligility.maven:progressive-organization-pom:pom:3.0.0 from/to central (https://repo.maven.apache.org/maven2): sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: 
unable to find valid certification path to requested target and 'parent.relativePath' points at wrong local POM @ line 5, column 11 -> [Help 2]

[Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException
[Help 2] http://cwiki.apache.org/confluence/display/MAVEN/UnresolvableModelException

编辑3 --------------------------------------------- --------------
D:\Program Files\apache-maven-3.3.3\conf/settings.xml中,我添加了:

<localRepository>D:\Users\myusername\AndroidstudioProjects\maven-android-sdk-deployer</localRepository>

这没有任何区别。这样做是否正确?

编辑4 --------------------------------------------- --------------- 尝试在证书命令中添加参数:

mvn install -Dmaven.wagon.http.ssl.insecure=true -Dmaven.wagon.http.ssl.allowall=true -Dmaven.wagon.http.ssl.ignore.validity.dates=true

编辑5 --------------------------------------------- ----------------
以上所有可能都是必要的,但还不够。它的工作原理是让网络人员为防火墙添加一个例外并添加Sun Certs。 http://www.mkyong.com/webservices/jax-ws/suncertpathbuilderexception-unable-to-find-valid-certification-path-to-requested-target/

编辑6 --------------------------------------------- -----------------
将M2_HOME设置为maven的位置,例如:
    C:\ Program Files(x86)\ apache-maven-3.3.9 \ 将mvn命令的位置添加到系统变量中的Path:
    C:\ Program Files(x86)\ apache-maven-3.3.9 \ bin

2 个答案:

答案 0 :(得分:2)

Osmdroid使用maven。 (见https://github.com/osmdroid/osmdroid/wiki/HowToMaven

基本上,你需要获得maven(至少版本为3.2.1),maven-android-sdk-deployer(https://github.com/simpligility/maven-android-sdk-deployer)和osmdroid代码。

git clone https://github.com/simpligility/maven-android-sdk-deployer

cd maven-android-sdk-deployer

mvn install -fn

构建osmdroid

git clone https://github.com/osmdroid/osmdroid.git

cd osmdroid

mvn clean install

编辑:示例应用程序有一些gradle支持文件,但您需要先使用maven构建其余的东西。 gradle位是与android studio一起使用的。

编辑:如果你在一个Windows框上。尝试以下

maven的路径

set M2_HOME=D:\Program Files\apache-maven-3.3.3
set PATH=%PATH%;D:\Program Files\apache-maven-3.3.3\bin
set ANDROID_HOME=D:\whereever\android-sdk

maven-android-sdk-deployer的路径

cd D:\...\maven-android-sdk-deployer

运行部署程序

mvn install -fn

构建osmdroid

cd D:\...\osmdroid
mvn clean install`

另一种选择:

我最近刚推送了一些gradle支持文件和gradle包装器。它目前仅建立最低限度,但它可能会让你前进。

git clone https://github.com/osmdroid/osmdroid.git

cd osmdroid

gradlew build

答案 1 :(得分:1)

SDK库(包括com.android.support:appcompat)在JCenter(或任何其他存储库)中不可用,而不是ver7而不是ver4。它们是SDK的一部分,需要预先安装。有关详细信息,请参阅this official doc