Android crash question

Previous topic - Next topic

MrPlow

Hi All

Maybe SF or one you could tell me what crashing on

String ext_storage = getExternalFilesDir(null).toString();

line 273 of SDLactivity is caused from?

If I can fix it i can eliminate a lot of crash issues...

Comp:
Speccy-48k, Speccy-128k, Amigas, PCs

Ian Price

Looks like a path issue. You're perhaps trying to load/save to a location that isn't correct. Android hates things like that. Android is case-sensitive - ensure that all media characters are upper/lower case in the expected load/save location and path. Remember - ".PNG" != ".png" and "Media/" != "media/"

Maybe.

I came. I saw. I played.

MrPlow

Thanks Ian

Not that easy - wish it was...This occurs on only a few Android models but seems to be small % but still this small percentage are affecting my ratings buy actively giving me 1 star and saying the game wont open for them...

Its a pain! X-(

But I think it might be an issue that might be avoided if the line in question tested itself (maybe within a try catch java statement) not sure though...

I think its to do with how their device is setup with SD access....I think...I am thinking of buying one of the devices that causes the majority of my crashes so I can test changes with it...




Comp:
Speccy-48k, Speccy-128k, Amigas, PCs

MrTAToad

Are you trying to read or write a file ?  It does look as though its trying to access an invalid area or perhaps its full (and you are trying to write).

spacefractal

#4
its a Java issue, happens on launch, before glbasic code starting. But im want the full error log, so im can checking which kind of error that was.

Im do thinks its can property been a permission issue, missing android.permission.WRITE_EXTERNAL_STORAGE and/or android.permission.READ_EXTERNAL_STORAGE.

you can try to do this (which do still not checking the permission, which im cant before im sure its a permission issue or not):
Code (glbasic) Select

boolean ReadPermission = (getContext().checkCallingOrSelfPermission("android.permission.READ_EXTERNAL_STORAGE") == PackageManager.PERMISSION_GRANTED);           
boolean WritePermission = (getContext().checkCallingOrSelfPermission("android.permission.WRITE_EXTERNAL_STORAGE") == PackageManager.PERMISSION_GRANTED);
String ext_storage = "";
if (ReadPermission==true && WritePermission==true)
{ if (Build.VERSION.SDK_INT>18)
{ ext_storage = android.os.Environment.getExternalStoragePublicDirectory(android.os.Environment.DIRECTORY_DOCUMENTS).toString();
}
else
{ ext_storage = android.os.Environment.getExternalStoragePublicDirectory(android.os.Environment.DIRECTORY_DOWNLOADS).toString();
}
}


instead of this:
Code (glbasic) Select

String ext_storage = getExternalFilesDir(null).toString();
if (ext_storage==null)
{ ext_storage = android.os.Environment.getExternalStoragePublicDirectory(android.os.Environment.DIRECTORY_DOWNLOADS).toString();
}

if (Build.VERSION.SDK_INT>18)
{ ext_storage = android.os.Environment.getExternalStoragePublicDirectory(android.os.Environment.DIRECTORY_DOCUMENTS).toString();
}


And make sure to use APPDATA to save data, not DOCUMENT. Im should really swapped it, but its have allways been that, so im wont breaks compatible.
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

MrPlow

have both those permissions in manifest...

I am using
PLATFORMINFO$("DOCUMENTS")

So should I stop using it? The crashes are small in percentage terms...just wanted to reduce even more and take away some bad scores...
Comp:
Speccy-48k, Speccy-128k, Amigas, PCs

spacefractal

#6
the crashes happens before glbasic code start it's invoke oncreate() to do various thing.

You can try and use the changed code. But I'm do not sure 100% what happens without full error log.

App data is better than document, because it's might crash on some devices. It's do best practices to read from that before move app data to prevent loss of data.

This issue was happens on Ouya with document as save folder, where the download folder was write protected.

I'm should swap it, eventually swap by a option.
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/