Skip to content

HowToInclude

MKer edited this page Jun 12, 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

Migration of the repo to Android Studio is on its way. The goal is to provide the lib as an aar. We also plan to make it available at Maven Central.

In the meantime, you can still add the lib as a jar. Proceed as for Eclipse (see above):

  • download osmbonuspack.jar,
  • create a "libs" directory at the root of your project, and copy osmbonuspack.jar inside.
  • copy all needed resource files, as described above.

No need to copy other libraries. In your build.gradle, thanks to the magic of Maven, just set the following dependencies:

dependencies {
    compile files('libs/osmbonuspack.jar')
    compile 'com.android.support:support-v4:18.0.0'
    compile 'com.google.code.gson:gson:2.2.4'
    compile 'org.osmdroid:osmdroid-android:4.3'
    compile 'org.apache.commons:commons-lang3:3.3.2'
    compile 'org.slf4j:slf4j-simple:1.5.8'
}