Set current location enabled crashing for Android version 6

For devices having Android version 6 the following line causes the application to crash
this.tomtomMap.setMyLocationEnabled(true);
Any solution for this?

It’s hard to guess what is the problem without any logs or source code examples.
Are you sure that you are running this.tomtomMap.setMyLocationEnabled(true); after the onMapReady(...) method? Documentation which might be helpful here: https://developer.tomtom.com/maps-sdk-android/map-initialization

1 Like

Hi,
Yes I am running it in onMapReady() method as specified in the example.

    @Override
    public void onMapReady(@NonNull TomtomMap tomtomMap) {

        this.tomtomMap = tomtomMap;
        this.tomtomMap.setMyLocationEnabled(true);

}

That’s good! Can you share your whole activity code, crash logs or double check the differences between our example tutorial code here: https://github.com/tomtom-international/tomtom-use-case-search-along-a-route-android/tree/develop ?
I’m asking because it uses that method and I can’t reproduce the issue:(

Hi,
Here is the exception
java.lang.IllegalArgumentException: provider doesn’t exist: network
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3103)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3134)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1388)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.lang.IllegalArgumentException: provider doesn’t exist: network
at android.os.Parcel.readException(Parcel.java:1603)
at android.os.Parcel.readException(Parcel.java:1552)
at android.location.ILocationManager$Stub$Proxy.requestLocationUpdates(ILocationManager.java:606)
at android.location.LocationManager.requestLocationUpdates(LocationManager.java:880)
at android.location.LocationManager.requestLocationUpdates(LocationManager.java:464)
at com.tomtom.online.sdk.location.BasicLocationSource.activate(Unknown Source)
at com.tomtom.online.sdk.map.aa.setLocationSource(Unknown Source)
at com.tomtom.online.sdk.map.aa.b(Unknown Source)
at com.tomtom.online.sdk.map.MapView.j(Unknown Source)
at com.tomtom.online.sdk.map.MapView.a(Unknown Source)
at com.tomtom.online.sdk.map.MapView$a.onDidFinishInitializingMap(Unknown Source)
at com.tomtom.core.maps.NativeMapViewImpl.lambda$notifyOnDidFinishInitializingMap$12(NativeMapViewImpl.java:774)
at com.tomtom.core.maps.-$$Lambda$NativeMapViewImpl$DagX0iTFUb4zU9Qh_mpbi7xhCHo.apply(lambda)
at com.tomtom.online.sdk.common.func.FuncUtils.forEach(Unknown Source)
at com.tomtom.online.sdk.common.callbacks.ListCallbackContainer.doOnEachCallback(Unknown Source)

Thanks.

Please share also your module build.gradle file so that we can see which versions of libraries you are using.

Can you reproduce the problem inside an Search Along A Route app?

implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.annotation:annotation:1.1.0'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation 'androidx.lifecycle:lifecycle-extensions:2.1.0'
implementation 'com.google.android.gms:play-services-plus:17.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'

def tomtomSDKVersion = "2.4307"
implementation "com.tomtom.online:sdk-maps:$tomtomSDKVersion"


implementation 'com.android.support:multidex:1.0.3'
implementation 'com.squareup.retrofit2:retrofit:2.6.1'
implementation 'com.squareup.retrofit2:converter-gson:2.6.1'

def lifecycle_version = '2.1.0'
implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version"
annotationProcessor "androidx.lifecycle:lifecycle-compiler:$lifecycle_version"
// alternately - if using Java8, use the following instead of lifecycle-compiler
implementation "androidx.lifecycle:lifecycle-common-java8:$lifecycle_version"

// optional - ReactiveStreams support for LiveData
implementation "androidx.lifecycle:lifecycle-reactivestreams:$lifecycle_version"
// For Kotlin use lifecycle-reactivestreams-ktx

// optional - Test helpers for LiveData
testImplementation "androidx.arch.core:core-testing:$lifecycle_version"

def room_version = "2.2.1"

implementation "androidx.room:room-runtime:$room_version"
annotationProcessor "androidx.room:room-compiler:$room_version"

def work_version = "2.2.0"

// (Java only)
implementation("androidx.work:work-runtime:$work_version") {
    exclude group: 'com.google.guava', module: 'listenablefuture'
1 Like

Hi,
I downloaded the sample application that you shared in the link and replicated the same code from there and my app seems to work fine :).
Thank alot Marteusz.
Regards,
Nigel.

2 Likes