I did have quite some trouble setting up OsmAnd, despite claims it’s simple.
So, here are step by step instructions that I’ve succeeded with several times.
I used Android Studio to setup the SDK for the system
I have API 23 installed (6.0 Marshmallow)
You MUST use Java JDK 7, so get that installed
You MUST use NDK r10.
See
http://pnsurez.blogspot.com.au/2015/07/download-android-ndk-tools.html for download links.
This particular NDK (r10) is *not* setup by Android Studio, so do that manually and set ANDROID_NDK (see below) to point to it.
Once you’ve done those installs, setup your environment variables for bash
I modified my ~/.bash_profile to contain the following environment variables
------
export ANDROID_SDK=/Users/boo/Library/Android/sdk
export ANDROID_NDK=/Users/boo/Documents/software/android-ndk-r10e
export ANDROID_HOME=/Users/boo/Library/Android/sdk
export JAVA_HOME=$(/usr/libexec/java_home -v 1.7)
------
The ANDROID_SDK and ANDROID_HOME are where Android studio placed stuff
Obviously you will need to change these directories to reflect where you have stuff on your system.
The JAVA_HOME is hopefully auto-configuring, so use that line as-is.
Your new environment variables won’t take effect until you start a new bash/console session so do that now.
Now we can move onto the source code.
Let’s start with a base directory to put it all in..
mkdir Osmand
cd Osmand
download the resources….
git clone
https://github.com/osmandapp/OsmAnd-resources.git
This will create Osmand-resources directory
It needs to be renamed
mv Osmand-resources/ resources
Now we grab the source code
git clone
https://github.com/osmandapp/Osmand.git
at this point we hopefully have the following structure
Osmand
- Osmand
- resources
cd Osmand
./gradlew —refresh-dependencies clean assembleFullLegacyFatDebug
If all goes OK, it will take ages to build but eventually BUILD SUCCESSFUL.
OK, that’s the command line working, let’s get to Android Studio
We should see a .apk file or two in
Osmand/OsmAnd/build/outputs/apk
Now let’s get it all working in Android Studio
Open Android Studio
Import grade project from the Osmand directory hanging off the root directory where you started
e.g., Osmand/Osmand
click on the project tab far left and open under Gradle Scripts the build.grade for module Osmand-SRTMPlugin
change the dependencies at the bottom to this..
dependencies {
compile "com.android.support:appcompat-v7:23.0.+"
}
Under the “Build Variants” tab, select OsmAnd module, change to
FreeLegacyFatDebug
Now we need to tell Android Studio to use the correct SDK and NDK
Go ‘Files/Project Structure’ and select SDK location tab
You need to setup SDK, NDK and Java. Here are mine - yours will be a bit different, but you get the basic idea...
Java JDK —> /Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home
Android SDK —> /Users/boo/Library/Android/sdk (this is where Android Studio put it)
Android NDK —> /Users/boo/Documents/software/android-ndk-r10e (this is the NDK I installed manually)
obviously /Users/boo is my machine - so get those paths right for your machine/user and you should be good to go.
Now it should build and download to your device/emulator whenever you select
“Run/Debug ‘OsmAnd’”
Good luck!