Skip to content

HowToInclude

MKer edited this page Jun 30, 2015 · 29 revisions

Prerequisites

You should be familiar with Android SDK.

1. Using Eclipse

We assume that you have an Android project created.

First of all, you must include osmdroid library in your Android project. Refer to osmdroid documentation.

OSMBonusPack jars from v5.1 are based on osmdroid v4.3

(OSMBonusPack jars from v4.5 to v5.0 are based on osmdroid v4.2; OSMBonusPack jars from v4.2.6 to v4.4 are based on osmdroid v4.1)

Take care to:

  • put the osmdroid.jar in a "libs" directory
  • configure the Build Path of your project so that osmdroid.jar appears in the "Referenced Libraries"
  • set-up the permissions required by osmdroid in your AndroidManifest.xml (OSMBonusPack doesn't requires anything more than osmdroid).

Done? OK. Now you have to include the lib.

Download the latest version of osmbonuspack.jar

Copy it in the "libs" directory of your project, with osmdroid.jar.

Right-click on the project, "Build Path", "Configure Build Path...", "Add JARs...".

Select osmbonuspack.jar in libs, and click OK. It's added to the "Referenced Libraries", ready-to-use.

Following exactly the same method, you will also have to add the following libs:

You can get all of them here.

If you are going to use standard OSMBonusPack "bubbles", browse the source, go to OSMNavigator code repository, and download in your project resources the following files:

  • For a white bubble:
    • drawable-mpi/bonuspack_bubble.9.png
    • layout/bonuspack_bubble.xml
  • For a dark-grey bubble:
    • drawable-mpi/bonuspack_bubble_black.9.png
    • layout/bonuspack_bubble_black.xml
  • For the "more info" button:
    • drawable/btn_moreinfo.xml
    • drawable-mpi/moreinfo_arrow.png
    • drawable-mpi/moreinfo_arrow_pressed.png

2. Using Android Studio

From v5.2, the OSMBonusPack library is now available as an AAR. It is not yet available at Maven Central.

  • In Releases, download osmbonuspack_v5.2.aar
  • create a "libs" directory at the root of your project, and copy the file inside.
  • No need to copy default resources for bubbles, as they are already included in the AAR.
  • No need to copy other libraries.

In your build.gradle, add the following lines:

repositories {
    mavenCentral()
    flatDir {
      dirs 'libs'
    }
}

Then set the following dependencies:

dependencies {
    compile(name:'osmbonuspack_v5.2', ext:'aar')
    compile 'org.osmdroid:osmdroid-android:4.3'
    compile 'org.slf4j:slf4j-android:1.6.1-RC1'
    compile "com.android.support:support-v4:22.2.0"
    compile 'org.apache.commons:commons-lang3:3.3.2'
    compile 'com.google.code.gson:gson:2.3'
}