Search code examples
androidosmdroid

Cannot resolve symbol StyleSelector on a osmdroid application


I'm unable to find a way to overcome the error "cannot resolve symbol..." on the following :

  • StyleSelector
  • getFiles
  • getLocalFile

on a android app . I belive all above may bellong to the same import

import org.osmdroid.bonuspack.kml.StyleSelector;

Can anyone tell if is deprecated? and if so what is the replacement?

    HashMap<String, StyleSelector> styles = MapActivity.mKmlDocument.getStyles();
    styles.remove(mInitialStyleId);
    styles.put(newStyleId, mStyle);
    
    String iconHref = eIconHref.getText().toString();
    mStyle.mIconStyle.setIcon(iconHref, MapActivity.mKmlDocument.getLocalFile(), null);
    

Solution

  • To correct this error one needs to upgrade the bobuspack like below:

    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.6.0'
    }
    

    Then set the following dependencies:

    dependencies {
        compile(name:'osmbonuspack_v6.6.0', ext:'aar')
        compile 'org.osmdroid:osmdroid-android:6.1.0'
        compile 'org.apache.commons:commons-lang3:3.3.4'
        compile 'com.google.code.gson:gson:2.8.5'
        compile 'com.squareup.okhttp3:okhttp:3.10.0'
    }