2

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

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

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

对于这个项目,在块build.gradle中包含这一行:dependencies

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 管理器中,我安装了 Extras > Android Support Repository 22 和 > Android Support Library 23.0.1

我能做些什么?

编辑 --------------------------------------------
我想我应该已经开始了尝试在不修改任何 build.gradle 或清单的情况下导入项目时出现错误的问题。关键是“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 安装

我收到此错误:

[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------------------------------------------------ -------------
以上所有可能都是必要的,但还不够。它的工作原理是让网络人员为 maven 的防火墙添加一个例外并添加 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 命令的位置添加到系统变量中的路径:
C:\Program Files (x86)\apache-maven-3.3.9\bin

4

2 回答 2

2

Osmdroid uses maven. (see https://github.com/osmdroid/osmdroid/wiki/HowToMaven)

Basically, you need to get maven (at least version 3.2.1), the maven-android-sdk-deployer (https://github.com/simpligility/maven-android-sdk-deployer) and the osmdroid code.

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

cd maven-android-sdk-deployer

mvn install -fn

Build osmdroid

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

cd osmdroid

mvn clean install

Edit: There are some gradle support files for the example application, but you'll need to build the rest of the stuff using maven first. The gradle bits are there for convenance with android studio.

Edit: if you're on a windows box. try the following

Path for 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

Path for the maven-android-sdk-deployer

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

Run the deployer

mvn install -fn

Build osmdroid

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

Another option:

I recently just pushed some gradle support files along with the gradle wrapper. It only builds the bare minimum at the moment but it may get you going.

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

cd osmdroid

gradlew build

于 2015-10-15T02:27:22.950 回答
1

The SDK libraries (inc. the com.android.support:appcompat) are not available in JCenter (or any other repository for that matter), not ver7 and not ver4. They are part of the SDK and need to be pre-installed. See this official doc for more info.

于 2015-10-14T22:29:49.843 回答