Fork me on GitHub

Building osmdroid from the command line

osmdroid's current, authoritative, build environment is with gradle. We also maintain maven build files however it's non-functional at the moment. As of Jan 2015, all of the Maven projects have been migrated over to Gradle.

Building with Maven

** NOTICE ** since April 2016, Google's Android team in their infinite wisdom have broken all things related to the maven repository for Google Play Services and Google Maps. As such, osmdroid's maven based build has been failing on on both the 3rd party library and the Google Wrapper APK project. As such, we've been actively using Gradle for the primary build system. See here for details.

  • Download the latest Android SDK and update the packages. The command line build requires the Google-Play-Services package.
    • Create the ANDROID_HOME path variable, pointing to your Android SDK install location.
      • Windows: Right Click on My Computer, select Properties, Select Environment Variables, and create the variable ANDROID_HOME with the location of your Android SDK
      • Linux: export ANDROID_HOME=(path to Android SDK install)
  • Download Maven (Project requires at least version 3.2.1)
    • Add the maven/bin to your PATH.
      • Windows: set PATH=$PATH%;(path to maven/bin).
      • Linux: export PATH=$PATH:(path to maven/bin)
  • Download Maven Android SDK Deployer. This project will make available the necessary Android dependencies for a maven build.
    • git clone https://github.com/simpligility/maven-android-sdk-deployer
    • Navigate to Maven Android SDK Deployer folder and run the command mvn install -fn
      • This command will try to make available all Android packages for Maven, do not worry about the errors for the platforms we are not using.
  • Checkout the osmdroid source from git to a local folder.
    • git clone https://github.com/osmdroid/osmdroid.git
  • Navigate to the osmdroid folder and run the command mvn clean install. NOTE: You will need a device or emulator running.

You have now completed all steps to compile osmdroid using Maven

Building with Gradle

  • Checkout the osmdroid source from git to a local folder.
    • git clone https://github.com/osmdroid/osmdroid.git
  • Navigate to the osmdroid folder and run the command gradlew clean install. This will also install to your local maven repository.
  • To run tests against a device or avd, run gradlew cC

You have now completed all steps to compile osmdroid using Gradle

Building osmdroid from Eclipse

  • Follow the above instructions for command line builds first.
  • Install Maven support for Eclipse from Eclipse Marketplace. Search for "android m2e" and install "Android Connector for Maven". http://rgladwell.github.io/m2e-android/
  • In Eclipse Import -> Maven -> Existing Maven project. Import all the osmdroid projects.
  • Right click on osmdroid-parent project. Click Run as --> Maven install.

Building osmdroid using Android Studio

  • Follow the above instructions for command line builds first (the gradle instructions).
  • Ensure you can build from the command line first!
  • Start up Android Studio and import the project in your checkout_folder

Building osmdroid from NetBeans (with maven)

Needs updating - See note above on the status of maven builds

  • Follow the above instructions for command line builds first.
  • As long as the environment variable for ANDROID_HOME is set, it should build by right clicking on "osmdroid parent", then "Clean and Build"