I almost know the solution (how) to my problem but I want to know its reason (why).

I am using mapBox for showing map on Android app in java. In the main activity layout I have an indeterminate linear progress bar and in the location fragment when the app is in progress (for finding the location) it become visible otherwise invisible. (do not mind about exact codes and workablity. In below just the block codes is shown)

    LinearProgressIndicator mainActivityProgressBar;
    MapView mapView;

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setBottomAppBarVisibility(true);
        mainActivityProgressBar = ((MainActivity) requireActivity()).getProgressBar(); //getProgressBar() method return main activity progressbar
    }
        .
        .
        .
    @Override
    public void onViewCreated(@NonNull View view,@Nullable Bundle savedInstanceState){
        super.onViewCreated(view,savedInstanceState);

        .
        .
        .
        mapView=findViewById(R.id.map);

        }

    private void showUserLocation(){
        mainActivityProgressBar.show();    // <------
        findLocation(location->{
        LatLng latLng=new LatLng(location.getLatitude(),location.getLongitude());
        onNewLocation(latLng);
        });
        }

    private void onNewLocation(LatLng newLocation){
        mainActivityProgressBar.hide();    // <------
        // move camera to the point
        }

This works fine when I use mapbox-sdk. (don't worry about methods and variables). Due to some errors on release time (libmapbox-gl.so error) I tried to use another map. I tried the above method using carto-Map and it almost works but sometimes it shows this error:

    FATAL EXCEPTION: Thread-191
        Process: PID: 3606
        android.util.AndroidRuntimeException: Animators may only be run on Looper threads
        at android.animation.ValueAnimator.end(ValueAnimator.java:1142)
        at com.google.android.material.progressindicator.DrawableWithAnimatedVisibilityChange.endAnimatorsWithoutCallbacks(DrawableWithAnimatedVisibilityChange.java:319)
        at com.google.android.material.progressindicator.DrawableWithAnimatedVisibilityChange.setVisibleInternal(DrawableWithAnimatedVisibilityChange.java:293)
        at com.google.android.material.progressindicator.IndeterminateDrawable.setVisibleInternal(IndeterminateDrawable.java:99)
        at com.google.android.material.progressindicator.DrawableWithAnimatedVisibilityChange.setVisible(DrawableWithAnimatedVisibilityChange.java:240)
        at com.google.android.material.progressindicator.IndeterminateDrawable.setVisible(IndeterminateDrawable.java:27)
        at com.google.android.material.progressindicator.BaseProgressIndicator.internalHide(BaseProgressIndicator.java:250)
        at com.google.android.material.progressindicator.BaseProgressIndicator.access$100(BaseProgressIndicator.java:70)
        at com.google.android.material.progressindicator.BaseProgressIndicator$2.run(BaseProgressIndicator.java:797)
        at com.google.android.material.progressindicator.BaseProgressIndicator.hide(BaseProgressIndicator.java:235)

I want to know why one map-sdk does not give Animators may only be run on Looper threads but other one give this error that I think can be fixed by using runOnUiThread.

NOTE: MapBox uses in-code (in application) token but the other one uses token in raw res-folder based on ShA1 fingerprint.

0

There are 0 best solutions below