Al Lelopath Al Lelopath - 2 months ago 25
Android Question

Cannot build osmdroid repository

I have cloned the osmdroid repository from
https://github.com/osmdroid/osmdroid
and I am unable to get it to build. I'm focussed on the OpenStreetMapViewer project in the repository.

I think the source of the problem is that I cannot use maven because I am behind a firewall. For all Android Studio projects I have created or cloned, I have to modify the build.gradle by removing

mavenCentral
and instead use:

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


For this project,
build.gradle
includes this line in the
dependencies
block:

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


However, browsing jcenter here:
https://bintray.com/bintray/jcenter
I do not see v4, only v7 (android-support-v7-appcompat)

I tried v7 as a dependency:

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


which the requires changing the
compileskdversion
to 23.

Doing that I get this build error:

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


So it appears that osmdroid really needs v4, not v7

In the Android SDK Manager, I have installed Extras > Android Support Repository 22 and > Android Support Library 23.0.1

What can I do?

Edit -------------------------------------------

I guess I should have started the question with the error the occurs when attempting to import the project without modifying any build.gradle or manifest. The point being that the instructions on "How to Maven" don't work in this case.

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


Edit 2 --------------------------------------------------------------

As stated previously, I cloned osmdroid from here:

https://github.com/osmdroid/osmdroid

I set the system environment variable M2_HOME to the location of the cloned osmdroid project.

In settings.xml:

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


I downloaded maven from here:

http://maven.apache.org/download.cgi

Unzipped D:\Program Files\apache-maven-3.3.3\bin, which I then also included in the
path
system variable.

In a DOS window, I go to M2_HOME and execute this command:


mvn install


I get this error:

[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


Edit 3 -----------------------------------------------------------

In
D:\Program Files\apache-maven-3.3.3\conf/settings.xml
, I added:

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


This didn't make any difference. Is it correct to do this?

Edit 4 ------------------------------------------------------------
Tried adding parameters to the command for certs:

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


Edit 5 -------------------------------------------------------------

All of the above may have been necessary but not sufficient. What got it working was having the network persons add an exception to the firewall for maven and adding Sun Certs.
http://www.mkyong.com/webservices/jax-ws/suncertpathbuilderexception-unable-to-find-valid-certification-path-to-requested-target/

Edit 6 --------------------------------------------------------------

Set M2_HOME to location of maven, e.g.:

C:\Program Files (x86)\apache-maven-3.3.9\
Add location of mvn command to Path in System variables:

C:\Program Files (x86)\apache-maven-3.3.9\bin

spy spy
Answer

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

Comments