Problem with Android permissions

I’m having a problem with my game crashing, and it seems like it’s related to Android permissions. Whenever I try to use the vibrate feature or network access, my app crashes. I added the appropriate settings to my build document:

settings = { orientation = { default = "landscapeRight", supported = { "landscapeRight", "landscapeLeft", } }, iphone = { plist = { UIStatusBarHidden = true, UIPrerenderedIcon = true, -- set to false for "shine" overlay UIAppFonts = { "C64 User Mono.ttf" } } }, --[[-- Android permissions android = { usesPermissions = { "android.permission.INTERNET", "android.permission.VIBRATE", "android.permission.ACCESS\_NETWORK\_STATE" }, },]]-- }

However, this still doesn’t seem to be working. When I install the app on my phone, I get a message informing me that my app “does not require any special access.” And whenever I get to a part of my game that uses network access or the system.vibate functionality, the crash will occur.

Am I missing something basic? It seems like everything should be set up correctly. I tried both with and without the versionCode, but it doesn’t seem to make a difference.

Nothing looks wrong with that to me.

I would suggest having the Android device connected to your PC while you test it so you can see the log of what the crash is.  That might help to pinpoint the issue better.

http://coronalabs.com/blog/2013/07/09/tutorial-basic-debugging/

I’ve tried that. With the internet connectivity, it looks like the crashes are the result of GameAnalytics code like “local ping = socket.tcp()”. Ping is nil because permission to access the network is denied.

The vibrating functionality doesn’t cause any crashes, but it does pop up a warning box about how the Android permissions are not set. So the two things do seem related to permission issues.

According to the Plugins page, GameAnalytics is only available to Basic and Pro subscribers, not Starter subscribers - which your forum information indicates you are.

Just wondering if that has anything to do with this?

When you do the build, are you getting any errors or warnings in the Terminal box?

How are you installing the APK to your device?

Your android permissions are commented.

Remove the “–[[” and “]]–” from your code

I’m using the LUA version of GameAnalyics, not the plugin version.

I seem to have figured out the problem. It seems like I do need a “versionCode” variable in the build setting, and I had to make sure that number matches the version code when building the app in Corona. I wasn’t under the impression that “versionCode” was essential, but my game won’t work without it.

Oh, and that.  :slight_smile:

Dang, I saw that too and didn’t even think of it.  Can’t believe it.

Hah, well yes, maybe that was the issue. Sometimes it just takes a fresh pair of eyes. :slight_smile:

Actually, you don’t need the versionCode variable in there.  I have never put that in and my Android builds have always worked fine.

Renato did catch something that was really obvious though.  :slight_smile:

Nothing looks wrong with that to me.

I would suggest having the Android device connected to your PC while you test it so you can see the log of what the crash is.  That might help to pinpoint the issue better.

http://coronalabs.com/blog/2013/07/09/tutorial-basic-debugging/

I’ve tried that. With the internet connectivity, it looks like the crashes are the result of GameAnalytics code like “local ping = socket.tcp()”. Ping is nil because permission to access the network is denied.

The vibrating functionality doesn’t cause any crashes, but it does pop up a warning box about how the Android permissions are not set. So the two things do seem related to permission issues.

According to the Plugins page, GameAnalytics is only available to Basic and Pro subscribers, not Starter subscribers - which your forum information indicates you are.

Just wondering if that has anything to do with this?

When you do the build, are you getting any errors or warnings in the Terminal box?

How are you installing the APK to your device?

Your android permissions are commented.

Remove the “–[[” and “]]–” from your code

I’m using the LUA version of GameAnalyics, not the plugin version.

I seem to have figured out the problem. It seems like I do need a “versionCode” variable in the build setting, and I had to make sure that number matches the version code when building the app in Corona. I wasn’t under the impression that “versionCode” was essential, but my game won’t work without it.

Oh, and that.  :slight_smile:

Dang, I saw that too and didn’t even think of it.  Can’t believe it.

Hah, well yes, maybe that was the issue. Sometimes it just takes a fresh pair of eyes. :slight_smile:

Actually, you don’t need the versionCode variable in there.  I have never put that in and my Android builds have always worked fine.

Renato did catch something that was really obvious though.  :slight_smile: