Android - GPS - Application has stopped

Corona Version 2016.2874 (2016.5.4) (but the issue happened on previous builds also)

Android 6.0.1

Cyanogen OS 13.0

When calling Runtime:addEventListener( “location”, locationHandler ), the simulator is fine, ios is fine, but my android device with Android 6.0.1 throws the popup “<Application> has stopped.”. There are no error message in the monitor/logcat.

I tested the same build on an old android device with 4.1.2 and it works normally. 

I recently updated my android version, so i believe it is related.

Anyone else encountering this problem?

With this setup : (same device)

Corona Version 2016.2874 (2016.5.4)

Android 5.1.1

Cyanogen OS 12.1.1

 

Everything works normally, as expected.

So it seems to confirm that the issue is related to the update of Android.

 

Corona staff, do you need a bug on this or are you already on it?

FYI, Corona has a general rule that they don’t support jailbroken or modded/rooted OSes, so this issue most likely won’t get much traction. If you can demonstrate the behavior on a non-rooted Android device, then that would be something that could be addressed.

I don’t know if we have a bug report on this or not, but as Alex stated, try your app on a non-jailbroken phone and if you have issues on a stock ROM, then we can see about getting a bug report or I can look then. But on rooted devices, you’re on your own.

Rob

Hello Alex & Rob,

I went and bought a new device (Nexus 5x), using original android 6.0.1 

Same exact behavior happens, it is not related to Cyanogen.

Rob, could you look into it? It is 100% repro.

Dim

Do you have a sample app that demonstrates the issue?

Hello Rob,

I tested with the GPS app from the sample code, and everything seems fine, so I may be wrong about the origin of the problem.

I am going to try to create a sample app to pinpoint the real problem.

In the meantime, here is the logcat, if it can help you to point me in the right direction.

Thanks,

Dim

 

05-13 16:01:52.569: I/Corona(17043): catching 05-13 16:01:52.669: I/Corona(17043): askUserForLocation 05-13 16:01:52.669: I/Corona(17043): before locationHandler 05-13 16:01:52.678: W/System.err(17043): android.content.pm.PackageManager$NameNotFoundException: com.anddoes.launcher.permission.UPDATE\_COUNT 05-13 16:01:52.678: W/System.err(17043): at android.app.ApplicationPackageManager.getPermissionInfo(ApplicationPackageManager.java:246) 05-13 16:01:52.678: W/System.err(17043): at com.ansca.corona.permissions.PermissionsServices.findAllPermissionsInManifestForGroup(PermissionsServices.java:806) 05-13 16:01:52.679: W/System.err(17043): at com.ansca.corona.permissions.PermissionsServices.getRequestedPermissionsInStateForGroup(PermissionsServices.java:1151) 05-13 16:01:52.679: W/System.err(17043): at com.ansca.corona.CoronaSensorManager$1.run(CoronaSensorManager.java:259) 05-13 16:01:52.679: W/System.err(17043): at android.os.Handler.handleCallback(Handler.java:739) 05-13 16:01:52.679: W/System.err(17043): at android.os.Handler.dispatchMessage(Handler.java:95) 05-13 16:01:52.679: W/System.err(17043): at android.os.Looper.loop(Looper.java:148) 05-13 16:01:52.679: W/System.err(17043): at android.app.ActivityThread.main(ActivityThread.java:5417) 05-13 16:01:52.679: W/System.err(17043): at java.lang.reflect.Method.invoke(Native Method) 05-13 16:01:52.679: W/System.err(17043): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 05-13 16:01:52.679: W/System.err(17043): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 05-13 16:01:52.680: W/System.err(17043): java.lang.NullPointerException: Attempt to get length of null array 05-13 16:01:52.680: W/System.err(17043): at com.ansca.corona.permissions.PermissionsServices.getRequestedPermissionsInStateForGroup(PermissionsServices.java:1157) 05-13 16:01:52.680: W/System.err(17043): at com.ansca.corona.CoronaSensorManager$1.run(CoronaSensorManager.java:259) 05-13 16:01:52.680: W/System.err(17043): at android.os.Handler.handleCallback(Handler.java:739) 05-13 16:01:52.680: W/System.err(17043): at android.os.Handler.dispatchMessage(Handler.java:95) 05-13 16:01:52.680: W/System.err(17043): at android.os.Looper.loop(Looper.java:148) 05-13 16:01:52.680: W/System.err(17043): at android.app.ActivityThread.main(ActivityThread.java:5417) 05-13 16:01:52.681: W/System.err(17043): at java.lang.reflect.Method.invoke(Native Method) 05-13 16:01:52.681: W/System.err(17043): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 05-13 16:01:52.681: W/System.err(17043): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 05-13 16:01:52.682: D/AndroidRuntime(17043): Shutting down VM 05-13 16:01:52.683: E/AndroidRuntime(17043): FATAL EXCEPTION: main 05-13 16:01:52.683: E/AndroidRuntime(17043): Process: co.vooter.vooterapp, PID: 17043 05-13 16:01:52.683: E/AndroidRuntime(17043): java.lang.NullPointerException: storage == null 05-13 16:01:52.683: E/AndroidRuntime(17043): at java.util.Arrays$ArrayList.\<init\>(Arrays.java:38) 05-13 16:01:52.683: E/AndroidRuntime(17043): at java.util.Arrays.asList(Arrays.java:155) 05-13 16:01:52.683: E/AndroidRuntime(17043): at com.ansca.corona.permissions.PermissionsSettings.\<init\>(PermissionsSettings.java:97) 05-13 16:01:52.683: E/AndroidRuntime(17043): at com.ansca.corona.permissions.PermissionsSettings.\<init\>(PermissionsSettings.java:90) 05-13 16:01:52.683: E/AndroidRuntime(17043): at com.ansca.corona.permissions.PermissionsSettings.\<init\>(PermissionsSettings.java:84) 05-13 16:01:52.683: E/AndroidRuntime(17043): at com.ansca.corona.CoronaSensorManager$1.run(CoronaSensorManager.java:259) 05-13 16:01:52.683: E/AndroidRuntime(17043): at android.os.Handler.handleCallback(Handler.java:739) 05-13 16:01:52.683: E/AndroidRuntime(17043): at android.os.Handler.dispatchMessage(Handler.java:95) 05-13 16:01:52.683: E/AndroidRuntime(17043): at android.os.Looper.loop(Looper.java:148) 05-13 16:01:52.683: E/AndroidRuntime(17043): at android.app.ActivityThread.main(ActivityThread.java:5417) 05-13 16:01:52.683: E/AndroidRuntime(17043): at java.lang.reflect.Method.invoke(Native Method) 05-13 16:01:52.683: E/AndroidRuntime(17043): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 05-13 16:01:52.683: E/AndroidRuntime(17043): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 05-13 16:01:52.686: W/ActivityManager(1226): Force finishing activity co.vooter.vooterapp/com.ansca.corona.CoronaActivity

What device are you testing on? What version of Android are you running.

Rob

LG Nexus 5x, android 6.0.1

It works in the simulator, only crashes on device.

Dim

What version of Corona SDK are you using?

I was on Corona Version 2016.2874, and i just tried with Corona Version 2016.2879. Same behavior.

This sounds like a bug in the new Android 6 permission system. The engineers are going to want a bug report. If you could make a simple project that demonstrates the problem, then you can use the “Report a bug” feature at the top.

The bug report must have a main.lua, config.lua and build.settings and any other assets that we need to build and run the app on the device. Put that in a .zip file and submit the forum. It’s helpful to post the URL of this thread in the bug report so the Engineer can have a reference to what’s been discussed so far. If the submission was successful, you will get an email with a CaseID # in the subject. Please post that number back here, so if we need to look into the bug report we will know which one to look at.

Thanks

Rob

Done.

Case 45978

Cheers,

d.

Hey Rob,
 

It’s been a couple weeks and I haven’t heard back from the dev team. 
Over 15% of my users are now on Android 6+, it is starting to become a major issue (especially because it fails very inelegantly), would you know if there is anything new on the subject? Is there a way to track the status of the bugs submitted?

Thanks,

Dim

I have to look them up. I’ll see what I can find.

Rob

Are you requesting permissions to access location services? See:

https://docs.coronalabs.com/daily/api/library/native/showPopup.html#requestapppermission

With Android 6 before you can use the GPS you have to request permission for it. You put permissions in build.settings for Android 5 and earlier. There are also entries in system.getInfo() that lets you get a list of granted permissions that you would check to see if you need to ask or not.

Rob

Hello Rob,

No, i didn’t request those permissions, indeed it is related. Thanks for the information, I did not know that it was necessary for android 6+.

I do now though, but i still can’t get it to work, i get this in the logcat : 

06-06 20:22:57.550: I/Corona(17951): ERROR: --appname-- tried to request access to a permission group without having any permissions from that group in build.settings/AndroidManifest.xml!

06-06 20:22:57.550: I/Corona(17951): Before requesting access, please add a permission from the android.permission-group.LOCATION permission group!

My code is :

local options = { appPermission = "Location", --appPermission = "android.permission-group.LOCATION", urgency = "Normal", listener = appPermissionsListener, rationaleTitle = "Location", rationaleDescription = "Location access is required to access this feature. Re-request now?", settingsRedirectTitle = "Location", settingsRedirectDescription = "Without the ability to locate this device, this feature cannot properly function. Please grant GPS access within the Settings of your device." } native.showPopup( "requestAppPermission", options )

I tried both [appPermission = “Location”] and [appPermission = “android.permission-group.LOCATION”] without success for either.

And here is the relevant informations of my build.settings : 

 

 usesPermissions = { --\*\* LOCATION -- Permission to access the GPS. "android.permission.ACCESS\_FINE\_LOCATION", -- Permission to retrieve current location from WiFi or cellular service. "android.permission.ACCESS\_COARSE\_LOCATION",

Any idea of what I am missing?

Cheers,

Dim

I would recommend looking at our GPS sample app or the mapView sample app and see how they code up the permissions.

Rob

Hello Rob,

That is the first thing i did, unfortunately, neither sample apps deal with this android 6+ issue. 

Would you have a working example of the native.showPopup( “requestAppPermission”, options ) for the “Location” appPermission?

Thanks for your help,

Dim

Ok, after further investigation, it seems that neither the platform agnostic nor the permission.group (ie : “Location” or “android.permission-group.Location”) work properly when added as the appPermission in the options of the native.showPopup.

However, calling one of the item in a permission group (ie : “android.permission.ACCESS_FINE_LOCATION”) works properly.

The current documentation is either completely wrong, or there is a bug.

This workaround is not so convenient, as it is now necessary to request all the items of a permission group one by one instead of the agnostic group, which might be quite annoying for the user (one popup after another).

EDIT : Actually, it works to request an array of strings, so it is not really a problem.

Cheers,

Dim