How to Compile the Android Version
Android SDK: Min sdk version: 21 Target sdk version: 29 Target sdk tools: 29
Android NDK: 23.
Compile Android apkβ
- First setup the development environment.
- Gradle (command line):
- Specify environment variables. ANDROID_SDK and ANDROID_HOME are where Android studio places things:
export ANDROID_SDK=/[your-path]/Android/sdk
export ANDROID_NDK=/[your-path]/android-ndk-23
export ANDROID_HOME=/[your-path]/Android/sdk- Compile with command line
cd android/OsmAnd && ../gradlew assembleNightlyFreeLegacyFatDebug
- Android Studio:
import android project and run module flavor `android.OsmAnd`
- You may use our debug.keystore to make builds compatible with the nightly build.
Gradle tasks / flavorsβ
Gradle task assembleNightlyFreeLegacyFatDebug will produce apk at android/OsmAnd/build/outputs/apk/ nightlyFreeLegacyFat/debug/OsmAnd-nightlyFree-legacy-fat-debug.apk. Task name assembleNightlyFreeLegacyFatDebug consists of :
- assemble - standard task to build apk
- nightlyFree - build flavor described below
- legacy - legacy / opengl / opengldebug - defines whether produced apk will have native libraries to use opengl map rendering or not. More information in OsmAnd development plugin.
- fat - fat (all native targets) / armv7 / arm64 / x86 / armonly - select which native libraries will be inside apk.
- debug - debug / release - standard task
To build bundle you could use bundle${FLAVOR}LegacyFatRelease.
Flavor | Package | Description |
---|---|---|
nightlyFree | net.osmand.dev | Nightly free build that could be installed next to both of GPlay versions for testing and exploring needs |
androidFull | net.osmand.plus | Full OsmAnd~ version could be used for F-Droid builds. Doesn't use GooglePlay services. |
amazonFree | net.osmand | Amazon OsmAnd - doesn't use GooglePlay services |
amazonFull | net.osmand.plus | Amazon OsmAnd+ - doesn't use GooglePlay services |
gplayFree | net.osmand | Google Play OsmAnd version - uses GooglePlay services. |
gplayFull | net.osmand.plus | Google Play OsmAnd+ version - uses GooglePlay services. |
huawei | net.osmand | Special build for Huawei market - uses Huawei services but not Google Play |
Debugβ
Enable NDK debug for legacy native library (OsmAnd-core-legacy)β
In OsmAnd/OsmAnd/jni/Application.mk uncomment lines
APP_OPTIM := debug
APP_DEBUG := true
Add debug symbols in the Android Studio project configuration. For this go to Edit Configuration / in the left menu select Android App "OsmAnd" / in right side select tab "Debugger". And add OsmAnd/obj/local where build libraries for different configuration (arm64-v8a, armeabi-v7a, x86, x86_64).
Compile OpenGL libraryβ
Opengl library is needed for targets like assembleNightlyFreeOpenglFatDebug and by default downloaded from OsmAnd ivy repository - gradle task. For local development you might need to compile those library and publish to local ivy repo.
- First setup the development environment, see {% link /setup-the-dev-environment %}.
- Install tools.
- Android SDK - 29.
- Android NDK - 23.
- CMake > 3.6 (cmake -version).
- SWIG - 4.1.1 (or compatible).
- Local c++ compiler (preferrable clang).
- Bash tools: wget, curl, python ...
- Gradle (command line):
- Specify environment variables. ANDROID_SDK and ANDROID_HOME are where Android studio places things:
export ANDROID_SDK=/[your-path]/Android/sdk
export ANDROID_NDK=/[your-path]/android-ndk-23
export ANDROID_HOME=/[your-path]/Android/sdk- Compile with gradle build task
cd core/wrappers/android && ../gradlew build
Hint: Compilation might take a long time and you will likely don't need all platforms, so you can comment out unwanted arch in the script and build only for 1 platform (x86, x86_64, arm, arm64) debug or relelease.
Debugβ
To be completed: how to set up Android ndk debug.
Compile API samplesβ
This article is incomplete & needs to be reviewed. You can help by creating a pull request.
There are 2 types of samples apps provided by OsmAnd, they are all represented in osmand-api-demo Github repo and compiled regularly at OsmAnd Builder.
Compile script:
(cd OsmAnd-api-sample && ./gradlew clean assembleRelease)
(cd OsmAnd-map-sample && ./gradlew clean assembleRelease)
- OsmAnd-api-sample - the simplest sample application that interacts with with already installed OsmAnd via AIDL interface and Intents.
- OsmAnd-map-sample - a sample application has fully integrated OsmAnd inside it as SDK. Allows to use all internall APIs.