Skip to content

HowToInclude

MKer edited this page Mar 14, 2017 · 29 revisions

Prerequisites

You should be familiar with Android SDK.

1. Using Android Studio

OSMBonusPack library is now available as an AAR.

1.1 Including using JitPack

OSMBonusPack is available through JitPack (it is not available on Maven Central).

In the build.gradle of your Project (top level), add the jitpack repository:

repositories { 
     ...
     maven { url "https://jitpack.io" }
}

Then in the build.gradle of your app, add this dependency:

dependencies {
    ...
    compile 'com.github.MKergall:osmbonuspack:6.3'
}

and that's it.

1.2 Including as a local lib

  • In Releases, download the latest osmbonuspack.aar file.
  • 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_v6.3', ext:'aar')
    compile "com.android.support:support-v4:23.2.1"
    compile 'org.osmdroid:osmdroid-android:5.6.4'
    compile 'org.apache.commons:commons-lang3:3.3.2'
    compile 'com.google.code.gson:gson:2.7'
    compile 'com.squareup.okhttp3:okhttp:3.4.1'
}

2. Using Eclipse (deprecated)

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.5 are based on osmdroid v5.0.1

(OSMBonusPack jars from v5.1 to v5.4 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