Buildable Osmand Android Project

1,999 views
Skip to first unread message

Mihai Ro

unread,
Oct 13, 2014, 11:53:44 AM10/13/14
to osm...@googlegroups.com
Hi guys,

I need your help! I have taken the latest version of the Android Osmand project, but it is not buildable as it doesn't find the files in the package: net.osmand.core.jni

Where can I find this files, or how can I generate them on Windows?



Pere Pujal

unread,
Oct 13, 2014, 2:03:58 PM10/13/14
to osm...@googlegroups.com
Not sure if that will help, but last week I just was able to compile osmand in Linux by following this:
https://code.google.com/p/osmand/wiki/CommandLineBuildEnvironment

Pere

--
You received this message because you are subscribed to the Google Groups "Osmand" group.
To unsubscribe from this group and stop receiving emails from it, send an email to osmand+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Mihai Ro

unread,
Oct 13, 2014, 4:03:26 PM10/13/14
to osm...@googlegroups.com
Thank you Pere, but this doesn't help me.
I found that article, but it doesn't explain how to build in Windows the Osmand Core for Android, to generate the files in net.osmand.core.jni.
Any other ideas how to get these files?

Mihai Ro

unread,
Oct 14, 2014, 7:49:57 AM10/14/14
to osm...@googlegroups.com
I installed Qt for Windows, but I don't know how to set a compiler to produce the files in Osmand Core for package net.osmand.core.jni needed by the Android project.
Is there anyone who know how to make this work?

If you have these files generated (package net.osmand.core.jni for Android) please attach them here!

Thank you!

Josue Fuentes Gutierrez

unread,
Oct 15, 2014, 2:09:29 AM10/15/14
to osm...@googlegroups.com

Friend a Question 
find the solution to the problem 

I have the same problem

Harry van der Wolf

unread,
Oct 15, 2014, 4:04:48 AM10/15/14
to osmand
Hi,

First of all: You don't need the Qt files. The Qt builds are very experimental and only work in safe mode which means they are slow.

I don't know how to compile on windows as my build environments are on linux and OS/X (I wrote that article) and I don't even have a windows pc/laptop (one from my work but it is strictly forbidden to use that one).
I might have a look if I can create a virtual windows environment. Officially that will be illegal of course but only for a few days to check how to build on windows.

If you simply want the compiled core libraries you could download a nightly or default build and unzip it. An apk is nothing more then a zip file. Inside it you will find the core libraries.

Hope that helps.

Harry

Mihai L

unread,
Oct 15, 2014, 12:50:43 PM10/15/14
to osm...@googlegroups.com
Thank you very much for your message!

I have followed your idea an I taken the nightly build and I copied the from the .apk the files in the lib folder to the libs folder of the project.
These files are in the folders armeabi, armeabi-v7a, mips and x86 - 5 in each directory:
libcpufeatures_proxy.so
libgnustl_shared.so
libosmand.so
gdbserver

However, the package net.osmand.core.jni is not found and I get error at the lines:
import net.osmand.core.jni.BoolPtr;
import net.osmand.core.jni.interface_ICoreResourcesProvider;
import net.osmand.core.jni.SWIGTYPE_p_QByteArray;
import net.osmand.core.jni.SWIGTYPE_p_bool;
import net.osmand.core.jni.SwigUtilities;
...

How can I get the android libraries that define this net.osmand.core.jni package?

Mihai L

unread,
Oct 16, 2014, 9:31:21 AM10/16/14
to osm...@googlegroups.com
I am running out of ideas...
Does anyone know what are the files that define the files in net.osmand.core.jni (like BoolPtr, interface_ICoreResourcesProvider...) ?

Harry van der Wolf

unread,
Oct 16, 2014, 9:50:22 AM10/16/14
to osmand
I have no experience ith Eclipse, but as far as I know that jni is not being used at all in the old build environment. 

Mihai L

unread,
Oct 16, 2014, 10:02:59 AM10/16/14
to osm...@googlegroups.com
There are many files in the Android project that use this package.

For example, in MapVectorLayer.java we have: import net.osmand.core.jni.IMapRenderer
but this is not found in the project.

I tried to put the .so files from the nightly build apk, but the definitions in net.osmand.core.jni aren't find  anywhere :(

Jozef Matejička

unread,
Oct 17, 2014, 12:11:26 PM10/17/14
to osm...@googlegroups.com
I also second that. Please publish somewhere result of build of osmand-core.

Thank you,

Jozef

Harry van der Wolf

unread,
Oct 17, 2014, 3:49:19 PM10/17/14
to osmand
I'm not there yet, but I wanted to give you an update.

I'm not a (java) developer, only a builder so I don't want/need an IDE like eclipse.
I could not get it running via "standard" windows as that is simply not supported so I installed cygwin move to a unix like environment within windows.
From cygwin I installed git, svn(-load), (gnu)make, python and swig
I downloaded repo 
I downloaded (apache-)ant

I opened the cygwin shell
I set my git environment settings.
I created a ~/development/osmandapp folder in my cygwin home user folder 
where I did a repo init and downloaded the necessary repositories with repo
I exported my ndk and sdk folder
Then from my ~/development/osmandapp folder I did the "./android/OsmAnd/old-ndk-build.sh" which nicely built all my libraries (including the jni thing)

Now I'm struggling with ant. Problems with backward and forward slashes. It uses the OsmAnd build.xml via forward slashes and is trying to find the android sdk build.xml via backward slashes

To be continued.


--

Mihai L

unread,
Oct 17, 2014, 5:15:30 PM10/17/14
to osm...@googlegroups.com
Yes, this is what we need when we want to build the Android project.

If there is someone that have the result of the build Osmand Core for Android please attach it here or give us a link to download!

Thank you,

Mihai

Mihai L

unread,
Oct 20, 2014, 7:34:50 AM10/20/14
to osm...@googlegroups.com
Did you succeed to produce the needed Android library?
If you did, please attach it here!

Jozef Matejička

unread,
Oct 20, 2014, 8:11:04 AM10/20/14
to osm...@googlegroups.com
Well I am unable to build it using cygwin.

Did you used Linux SDK and NDK or windows?

[x86] SharedLibrary : libcpufeatures_proxy.so
C:/prj/Osmand/android-ndk-r10c/toolchains/x86-4.8/prebuilt/windows/bin/../lib/gcc/i686-linux-android/4.8/../../../../i686-linux-android/bin/ld.exe:
error: cannot open ./obj/local/x86/libgnustl_shared.so: Permission
denied
collect2.exe: error: ld returned 1 exit status
/cygdrive/c/prj/Osmand/android-ndk-r10c/build/core/build-binary.mk:647:
recipe for target 'obj/local/x86/libcpufeatures_proxy.so' failed
make: *** [obj/local/x86/libcpufeatures_proxy.so] Error 1

Harry van der Wolf

unread,
Oct 20, 2014, 2:31:53 PM10/20/14
to osmand
Hi,

As mentioned: I don't have a windows laptop myself so I did it on another one. Wednesday afternoon I can continue on that one. I will attach the libraries to the mail. I will also write it down more extensively.

Secondly: I downloaded the windows sdk and ndk. As such it doesn't matter at all. It is only the installer, the content is the same. First I tried to compile it under windows and that was not succesful. Then I installed cygwin and built the libraries with the "windows sdk/ndk" (as mentioned: it doesn't matter).

Your error message is a strange one: "C:/prj/Osmand/android-ndk-
r10c/toolchains/x86-4.8/prebuilt/windows/bin/../lib/gcc/i686-linux-android/4.8/../../../../i686-linux-android/bin/ld.exe:

error: cannot open ./obj/local/x86/libgnustl_shared.so: Permission
denied
"
It seems to be there but the next step can't open it. If you are on windows on the C: partition on some win 7 pro you might have authorization errors when writing to the root without admin rights.
I installed "the stuff" on the D: drive.
I put cygwin as d:\cygwin
I created a development folder inside d:\cygwin like d:\cygwin\development and in that one I unzipped the SDK and the NDK.
I started a bash shell. That will have as root the d:\cygwin folder, so I exported the ndk and sdk folder as /development/android-ndk.... and /development/android-sdk....


Harry


Harry van der Wolf

unread,
Oct 21, 2014, 1:53:30 AM10/21/14
to osmand
2014-10-20 20:31 GMT+02:00 Harry van der Wolf <hvd...@gmail.com>:


Secondly: I downloaded the windows sdk and ndk. As such it doesn't matter at all. It is only the installer, the content is the same. First I tried to compile it under windows and that was not succesful. Then I installed cygwin and built the libraries with the "windows sdk/ndk" (as mentioned: it doesn't matter).


I wrote that but that's not correct of course. Almost everything is the same, but the tools (aapt, adb, gcc, etc.) in the windows sdk and ndk  are windows exe files of course and not linux or osx binaries.

Harry

Michał Gątkowski

unread,
Nov 21, 2014, 1:46:56 PM11/21/14
to osm...@googlegroups.com
Have anyone sound this net.osmand.core.jni i'm also stuck with building this project. ;/

Jindřich Makovička

unread,
Nov 23, 2014, 11:45:58 AM11/23/14
to Osmand ML
Actually it seems that it's enough to cherrypick
"db38c0589e80c2a516de71746810bc6a8dba18ba Fix" into the 1.9 branch,
which makes it build with the new wrapper.
> --
> You received this message because you are subscribed to the Google Groups
> "Osmand" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to osmand+un...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



--
Jindřich Makovička

Jindřich Makovička

unread,
Nov 23, 2014, 12:08:39 PM11/23/14
to Osmand ML
Oops, the proper commit ID is 97fe54fc15753a23ec122d79cab7ea55c0594fcc
--
Jindřich Makovička

Mihai L

unread,
Nov 24, 2014, 12:49:27 PM11/24/14
to osm...@googlegroups.com
I am not very familiar with the git repository.
How do you get the commit 97fe54fc15753a23ec122d79cab7ea55c0594fcc?
And what do you copy from it?

You received this message because you are subscribed to a topic in the Google Groups "Osmand" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/osmand/RuthdQWuExE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to osmand+un...@googlegroups.com.

Mihai L

unread,
Nov 24, 2014, 1:30:16 PM11/24/14
to osm...@googlegroups.com
Actually I found the commit  you were talking about: https://github.com/osmandapp/Osmand/tree/97fe54fc15753a23ec122d79cab7ea55c0594fcc/OsmAnd

But this doesn't have the jni libraries.

Could someone post here the lib files that are needed to compile the project (when import net.osmand.core.jni)? Or tell us how to build them on Windows?

Jindřich Makovička

unread,
Nov 25, 2014, 12:03:35 AM11/25/14
to Osmand ML
This commit was already merged by Victor.

It does not contain any libraries - it makes the source build with the
current ones instead.

Mihai L

unread,
Nov 25, 2014, 5:50:08 AM11/25/14
to osm...@googlegroups.com
So what files should we use from this old commit to make the latest Android project build?
The latest build has errors when importing net.osmand.core.jni for example in NativeRenderer.java when calling: import net.osmand.core.jni.AreaI;?


--
You received this message because you are subscribed to a topic in the Google Groups "Osmand" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/osmand/RuthdQWuExE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to osmand+un...@googlegroups.com.

Phil

unread,
Nov 25, 2014, 10:04:19 AM11/25/14
to osm...@googlegroups.com
When using branch r1.9 instead of master the build works for me.

To use r1.9 instead of master:
Edit osmand/.repo/manifest.xml:
<project path="core" name="osmandapp/OsmAnd-core.git" revision="legacy_1.9" />
<project path="android" name="osmandapp/Osmand.git" revision="r1.9"/>
<project path="resources" name="osmandapp/OsmAnd-resources.git" revision="r1.9" />
<project path="help" name="osmandapp/osmandapp.github.io.git" revision="master"/>

then:
repo sync -d
and build again

Mihai L

unread,
Dec 9, 2014, 5:23:00 AM12/9/14
to osm...@googlegroups.com
Hi Phil,
Thank you for your help, but r1.9 at the address https://github.com/osmandapp/Osmand/tree/r1.9
has old updated source files.

I took the master again today (master and core prj also) from https://github.com/osmandapp/Osmand
and this version have errors when calling for example: import net.osmand.core.jni.IMapTiledSymbolsProvider;

What is the file that should be added in the Android project to have these core.jni files recognized?

Fabien Nicollet

unread,
Feb 24, 2015, 7:18:21 PM2/24/15
to osm...@googlegroups.com
Hello,

I am trying to do a similar thing but just like you, eclipse (ADT) won't find anything related to net.osmand.core.jni.*

I tried to get the libs from the pre-built APK and put them in my /libs/ folder but it doesn't change anything. I also ran "./android/OsmAnd/old-ndk-build.sh" like Harry said in this thread and compiled for a while then basically recreated the files I already had in /libs/.

By the way, to get rid of the "Permission denied" error when running old-ndk-build.sh", you need to chmod your eclipse workspace. In cygwin, it gives something like:
chmod -R 777 /cygdrive/e/Workspaces/Android/

This thread seem to have someone for which it just works:

But refreshing / rebuilding the Eclipse project doesn't seem to do anything, just as if the .so (shared library that were compiled by the NDK) were absent or not in the build path.

Have you made any progress with this? I just want to be able to run the code and have breakpoints to check some stuff but I am stuck on this JNI stuff

Thanks,
Fabien

Fabien Nicollet

unread,
Feb 26, 2015, 5:01:33 PM2/26/15
to osm...@googlegroups.com
Hello,

After a lot of headache, I have been able to build and run OsmAnd on Windows. Here are some notes I took while it was compiling, hope it helps others :)
There are part that still wouldn't work so I had to find workarounds. Someone should open a wiki page to explain everything and how it can be done on Windows easily, because it took me about 3 nights.

*Tools you will need*

Cygwin: You could need Cygwin to execute .sh files: http://cygwin.com/install.html

Android SDK: Download them from the official website, using the Windows Installer: http://developer.android.com/sdk/index.html#Other. Once installed, launch the SDK Manager to install the optionnal packages. Do not download the packages for Android 5.0.1 but the packages for Android 4.4.2 instead (OsmAnd is preconfigured for android-19 : SDK version 19). If you have an Android device, I would suggest you don't download their disk image (emulator) as it is completly terrible and slow. If you have a device, try debugging on your device via USB, you will lose a lot less time. If you need to use an emulator, try "Genymotion", I heard very good things about it.

Android ADB drivers: You will need the ADB drivers for your phone so that it is recognized via USB. To check if your device can be seen by your computer, open a "cmd", cd to "/sdk/platform-tools/" in the Android SDK and type "adb kill-server", then "adb start-server" then "adb devices". Your device should be listed there. Note that you need to set it to debug mode, see this tutorial 

Eclipse Luna: Download the "Eclipse IDE for Java developers" from here : http://www.eclipse.org/downloads/. Unzip it somewhere, then run eclipse.exe (no install). Then follow these instructions to install the Android Developer Tools:


*Downloading sources via repositories*
I tried following the instructions from the wiki:
But unfortunately, I tried running the "repo" tool from Cygwin and got into a lot of errors, mostly Python complaining about files not found in /cygdrive/, read online that it was a conflict with my local install of Python for Windows. Didn't find a solution so instead I downloaded the sources directly from Github. If you are trying to build OsmAnd to make pull request, I suggest you try to make the "repo" tool work because if you download the sources manually, you will not be linked to the repositories anymore, so no more code updates.

To check which repositories to download, you need to check out this file:
"repo sync" is supposed to go fetch those repositories and rename them. You can do it manually. For instance, for this one:

<project path="core" name="osmandapp/OsmAnd-core.git" revision="legacy_1.9" />



You need to go to:
Then pick the "legacy_1.9" branch from the dropdown menu
So that you go to:

Bottom-right corner, click Download zip, extract it in your workspace are rename the resulting folder to the corresponding "path" attribute, here "core".

Do that for all the repos, you will get repos "android", "core", "tools", "misc", "resources", "help".

I believe it should be possible to download the repos via a tool like egit (in Eclipse) or TortoiseGit or something but I am not so good at Git. If you have some advice, please post it.



*Import projects into Eclipse*
Now that you have the sources, open your Eclipse that you installed with the ADT tooling. point your Workspace to the folder containing all the repositories you just downloaded. If you want to change workspace location, go to File > Switch workspace.
Then right click panel on the left > Import project. A dialog window will open. Type "work" in the search field and select "Existing projects in Workspace". Browse to your workspace location and Eclipse will find a few projects. You only need "OsmAnd" and "SherlockBar".



*Compiling the native shared libraries*
This step is optionnal. Like someone else said, you can take the ones from the official build. Here is how:
Basically, get them from the APK, copy the 4 folders into /android/libs and Project > Clean in Eclipse

If you want to generate the .so files manually, you can eventually do it. Add a environment variable "ANDROID_SDK" pointing to your Android SDK install. Download the Android NDK from https://developer.android.com/tools/sdk/ndk/index.html and add an env. variable "ANDROID_NDK" pointing to the Android NDK
Then you will need to run a .sh file so open Cygwin, cd to /android/OsmAnd/ and execute 

./old-ndk-build.sh

(ndk-build.sh could work, I am not sure about the difference)

You might get a "Permission denied" message. If so, add rights by executing this command:

chmod -R 777 /cygdrive/e/Workspaces/Android/


E:\Workspaces\Android\ is the folder containing "android", "core", etc. Then execute the .sh file again. The .SO files will be created.


*JNI Compilation*
So far, Eclipse will be complaining about imports related to net.osmand.core.jni.* that cannot be found. And indeed, there is no corresponding source files. Turns out you have to generate them yourself.
Side note: JNI stands for Java Native Interface and allows OsmAnd to call some native code (C/C++), which are in the SO file you just copied or generated. It is used for native routing and native rendering. There is a Java part which is just a stub that calls the native function automatically but for some reason, it is not in the sources.

Turns out the scripts are not in the legacy_1.9 branch or OsmAnd-core but in the master branch. You will find a "wrappers" folder there:

Download the sources or fetch if via git, then temporarily rename the previous "core" repo in "_core" and rename the master branch as "core" or the script won't find the right files. You can then revert to th legacy_1.9 branch.
Add a "SWIG" env variable pointing to the swig.exe file
Open cygwin and change directory to core/wrapper/java/ then execute "./generate.sh"
I had many troubles with the file paths that were wrong (could not find core.swig using relative path in cygdrive, even tho it was there), had to edit the generate.sh manually to something like:


# Actually perform generation
$SWIG \
-java \
-package net.osmand.core.jni \
-outdir "E:\Workspaces\Android\core\wrappers\java/gen/java/net/osmand/core/jni" \
-o "E:\Workspaces\Android\core\wrappers\java/gen/cpp/swig.cpp" \
-DSWIG_JAVA \
-I"E:\Workspaces\Android\core\include" \
-c++ \
-v \
"E:\Workspaces\Android\core\core.swig"
If it all goes OK, it should generate java files in wrappers\java\gen\java\net\osmand\core\jni
Just copy the "jni" folder in your OsmAnd project in src/net/osmand/core and it should solve the import issues

*Other error messages*
A lot of things went wrong during these 3 sleepless nights, I am not sure if some are my fault, useless or bad manipulation on my side, here is a couple things that could help you. Note that a lot of errors disappear with a Eclipse restart or a Project > Clean

When launching the Android emulator, if you get the error "Unable to execute dex: Multiple dex files define define Lcom/google/protobuf/MessageLite$Builder;", you need to uncheck the Android Private Library, see http://stackoverflow.com/a/16606378/808102

Error NoClassDefFound on gnu.trove.*. Not sure why but the lib was in the libs folder ("gnu-trove-osmand.jar"). I believe once I right clicked the project > Properties > Java Build Path and added the JAR manually to the build path (try the Order and Export tab as well). Then clean your project.

Unable to execute dex: GC overhead limit exceeded




Note that there has been a lot of trial-and-error for hours and didn't take note of all the cryptic errors I got so there might be more. If an administrator read this message, please open a Wiki page dedicated to building OsmAnd on Windows. There has been quite a few message about it on the Google Groups so it is not uncommon. 
These instructions might be a good start, people could edit the Wiki page and add their advice to finally get a clear guide on how to build on Windows because at the moment, this is close to impossible.

Hope it helps !
Fabien

Harry van der Wolf

unread,
Mar 5, 2015, 8:27:47 AM3/5/15
to osmand
Hi Fabien,

Thanks for your work. I have now a windows laptop as well so I can now try it for myself (last 5 years on linux. 6 years before that on OSX). If I can reproduce your workflow I will add a new wiki page or modify the current. Note that I will basically focus on Gradle command line and not so much on Eclipse. I might need your assistance in this.

Harry

Fabien Nicollet

unread,
Mar 5, 2015, 10:57:21 AM3/5/15
to osm...@googlegroups.com
Hello,

I guess it makes more sense using Gradle as it now seems to be the standard for building Android apps. I used Eclipse because there was a lot of StackOverflow material about it (a lot of users but a lot of bugs :)). Now the standard IDE is Android Studio, which is based on IntelliJ, so I don't know which IDE you should try to document.
Eclipse + ADT plugins can still be used but the Android SDK pages now reference Android Studio as standard. It might be worth a try, it could simplify the procedure.

Fabien
Fabien Nicollet
Tel : +33 (0)6 60 54 72 20

Oliver S

unread,
Apr 27, 2015, 3:04:40 AM4/27/15
to osm...@googlegroups.com
Hi,

did anyone succeed in importing the project into Android Studio? For me, the command line approach using gradle works fine, but I would like to have all the sources in one IDE. As Android Studio is the current official IDE for Android development and the OsmAnd project supports the gradle build system, I'd hoped this would be easy (but I found out that it's not).

What I did so far is to
- install gradle
- install Android Studio
- install the SDK and NDK
- fetch the OsmAnd sources via the repo tool (based on the android_build.xml manifest)
- build the OsmAnd.apk using the command line approach to ensure that everything is fine

After starting Android Studio, I choose "Import Project". At that point, I'm unsure which is the right path to the OsmAnd project: is it the 'root' path of my local OsmAnd repository (which contains the directories "android", "core-legacy", ...), or is the correct path "<LOCAL_OSMAND_REPO>/android/OsmAnd"?

Any hint is appreciated!

Oliver
Reply all
Reply to author
Forward
0 new messages