Search code examples
androidandroid-studiobuild.gradleopenstreetmaposmdroid

osmdroid Cannot resolve method "setUserAgentValue"


I use osmdroid to build a map app. I have a error in this line:

org.osmdroid.tileprovider.constants.OpenStreetMapTileProviderConstants.setUserAgentValue(BuildConfig.APPLICATION_ID);

Method "setUserAgentValue" is red and cannot resolve. This is my Gradle:

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'

    implementation 'org.osmdroid:osmdroid-android:6.0.3'
    implementation 'com.squareup.retrofit2:retrofit:2.5.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.3.0'

    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

Any help would be greatly appreciated because I'm losing my mind! Thanks so much!!!


Solution

  • Try replacing with the newer

    Configuration.getInstance().setUserAgentValue(BuildConfig.APPLICATION_ID)
    

    Source: https://github.com/osmdroid/osmdroid/wiki/Important-notes-on-using-osmdroid-in-your-app#set-the-http-user-agent-variable