How to Compile the Android Version

In this article

Android SDK: Min sdk version: 21 Target sdk version: 29 Target sdk tools: 29

Android NDK: 23.

Compile Android apk

  1. First setup the development environment, see How to Setup the Development Environment.
  2. 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
    
  3. Android Studio:
    import android project and run module flavor `android.OsmAnd`
    
  4. 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 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.

FlavorPackageDescription
nightlyFreenet.osmand.devNightly free build that could be installed next to both of GPlay versions for testing and exploring needs
androidFullnet.osmand.plusFull OsmAnd~ version could be used for F-Droid builds. Doesn't use GooglePlay services.
amazonFreenet.osmandAmazon OsmAnd - doesn't use GooglePlay services
amazonFullnet.osmand.plusAmazon OsmAnd+ - doesn't use GooglePlay services
gplayFreenet.osmandGoogle Play OsmAnd version - uses GooglePlay services.
gplayFullnet.osmand.plusGoogle Play OsmAnd+ version - uses GooglePlay services.
huaweinet.osmandSpecial 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 targtes 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.

  1. First setup the development environment, see How to Setup the Development Environment.
  2. Install tools.
    • Android SDK - 29.
    • Android NDK - 23.
    • CMake > 3.6 (cmake -version).
    • SWIG - 3.0.*
    • Local c++ compiler (preferrable clang).
    • Bash tools: wget, curl, python ...
  3. 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
    
    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.

Make a contribution

There are 3 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)
(cd OsmAnd-qt-core-sample && ./gradlew clean assembleRelease)

Read more.

Did this doc help you?

Privacy policy

Help us make these docs great!

All OsmAnd docs are open source. See something that's wrong or unclear? Submit a pull request.

Make a contribution

Or, learn how to contribute.