Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Skobbler Map crashes after returning from background

I am developing an application where I am using skobbler sdk 2.4 and I have encountered a problem when I open Map and then I go to background and open an app that needs a lot of memory like Clash of Clans :P.

After a few seconds when I return to the activity that contains the map it goes black and after 2 seconds it give this error to logcat:

A/libc﹕ Fatal signal 11 (SIGSEGV), code 1, fault addr 0x44 in tid 27000 (GLThread 72284)

I have tried the same thing with the example that comes with the sdk and at first it crashes because it cant find String path that is kept inside application instance. I have made a workaround for this problem and fixed the null exception crash coming from application class DemoApplication. This wasnt a problem. The problem is with the map.

After this I went at the same point, I had the same problem even with the example app. The maps crashes and it cant initialize itself again after activity has been in background.

Any suggestion is appreciated :)

like image 382
Ultimo_m Avatar asked Dec 07 '25 02:12

Ultimo_m


1 Answers

Thanks to SylviA while I was checking my sample app I was trying to fix the problem of Null Pointer Exception and send it via email.

While I was writing the code for the second time I realized that I was doing something wrong and that was the reason of this absurd crash.

Here I am posting a part from the code where I have made my changes when map is initialized in MapActivity.class. These changes are made inside DemoUtils.class

/**
 * Initializes the SKMaps framework
 */
public static void initializeLibrary(final Context context) {
    final DemoApplication app = (DemoApplication)context.getApplicationContext();
    // get object holding map initialization settings
    SKMapsInitSettings initMapSettings = new SKMapsInitSettings();
    // set path to map resources and initial map style

    SharedPreferences mSharedPreferences = context.getSharedPreferences("map",0);
    if(app.getMapResourcesDirPath()==null) { // here happens the first error
        Toast.makeText(context,"Null Exception Error avoided", Toast.LENGTH_SHORT).show();
        app.setMapResourcesDirPath(mSharedPreferences.getString("map_path",null));
    }else {
        SharedPreferences.Editor mEditor = mSharedPreferences.edit();
        mEditor.putString("map_path",app.getMapResourcesDirPath());
        mEditor.commit();
    }

    initMapSettings.setMapResourcesPaths(app.getMapResourcesDirPath(),
            new SKMapViewStyle(app.getMapResourcesDirPath() + "daystyle/", "daystyle.json"));

What I was doing wrong was at this line, and it was something like this:

initMapSettings.setMapResourcesPaths(app.getMapResourcesDirPath(),
            new SKMapViewStyle( null + "daystyle/", "daystyle.json"));

And it has to be done like this:

initMapSettings.setMapResourcesPaths(app.getMapResourcesDirPath(),
            new SKMapViewStyle( app.getMapResourcesDirPath() + "daystyle/", "daystyle.json"));

Thanks for your time :)

like image 106
Ultimo_m Avatar answered Dec 08 '25 15:12

Ultimo_m



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!