build for android using non Debug keystore crashes corona simulator durring build

I can’t make a production build to send to any of the android app stores because of this issue.
When I try to do a build for android, kindle, or nook, using my own keystore
(not Debug keystore), the corona simulator crashes completely within about 10-20 seconds of starting the build.
I’ve created a new keystore and it still crashes on anything other than the Debug keystore.

This is the only stuff that’s in the console after it crashes"
[bash]
2012-11-24 16:38:37.934 Corona Simulator[45809:f03] Simulation Terminated: Lua script called os.exit() with status: 0
2012-11-24 16:38:41.863 Corona Simulator[45809:f03]
Copyright © 2009-2012 C o r o n a L a b s I n c .
2012-11-24 16:38:41.864 Corona Simulator[45809:f03] Version: 2.0.0
2012-11-24 16:38:41.864 Corona Simulator[45809:f03] Build: 2012.971
Invalid memory access of location 0x10 rip=0x10000c3fd
/Applications/CoronaSDK/Corona Terminal: line 9: 45809 Segmentation fault: 11 “$path/Corona Simulator.app/Contents/MacOS/Corona Simulator” $*
logout
[/bash]

When i rebuilt my keystore I used the keytool from within a shell (on a mac) using the following command:
keytool -genkey -v -keystore nameOfApp.keystore -alias nameOfApp -keyalg RSA -validity 10000

I updated to the latest daily build of 971 and it still crashes. I was running 964, then upgraded to 971. This is my first time actually trying to build a non-Debug keystore build using corona. I’ve been working with corona for 10 months now, but this is my first production build with it.
[import]uid: 11193 topic_id: 33304 reply_id: 333304[/import]

I can do an Android build just fine if I use the Debug keystore, and I can also do an IOS build just fine with this exact same project. [import]uid: 11193 topic_id: 33304 reply_id: 132270[/import]

I tried re-creating my keystore with the following command:
[bash]
keytool -genkey -v -alias tesla -keystore tesla.keystore -keyalg RSA -keysize 2048 -validity 10000 -dname “CN=Tesla’s Electric Mist,O=iCOOLgeeks,C=US”
[/bash]

still crashed the corona simulator on build. [import]uid: 11193 topic_id: 33304 reply_id: 132272[/import]

Additional things I’ve tried today.

  • downloaded latest java (1.7.0_09), made sure it was the java highest in my path order. I was using 1.6.0_35 prior.
  • rebuilt my keystore using this new java, also using the two different commands listed above.
  • renamed my existing corona sdk folder, then downloaded new version 971 from daily builds.
  • rebooted a bunch.

But nothing works, I’m still getting this error only when trying to do a build with one of the android build types, and selecting a keystore other than the Debug one. I’m still getting the same error listed above within a few seconds, then the corona simulator restarts, and then completely dies again after another 10 seconds or so.

[import]uid: 11193 topic_id: 33304 reply_id: 132359[/import]

I just tried copying my whole project file to a new location, still no go. Then I tried deleting some of the icon images, but no good there either… I’m grasping at straws and don’t know what else to try. I get the same error everytime!!! [import]uid: 11193 topic_id: 33304 reply_id: 132361[/import]

I just built a real simple hello world type project and tried to build it using a non-Debug keystore and it works.
So that means it’s something wrong within my project. But I have no idea what.

  • I have been working on this project for 10 months and this is the first time I’ve tried to build an android build using a non-Debug keystore.
  • I can build fine for android. kindle, and nook using the Debug keystore.
  • I can build fine for iphone.
  • the app works perfectly on the simulator.

So basically, sometime within the last 10 months, I put something in my project that has broken this end process, but since this is the first time I’ve tried to do this final piece, I have no clue what I did or when I did it. Or if this step ever worked on my machine?
And the error that it spits out is absolutely zero help to me!!! [import]uid: 11193 topic_id: 33304 reply_id: 132363[/import]

Found the problem! - it’s a bug in corona. Here’s the issue and the fix for any future users that run into this.

I needed my app to exit on suspend.
For iOS I put “UIApplicationExitsOnSuspend = true,” in the plist, but couldn’t find a similar solution for android, so I put in some code to listen for a suspend event and exit when it gets one.
This is what I put in my main.lua file:

local function onSystemEvent( event ) -- put this in to exit on suspend in android devices.  
 if event.type == "applicationSuspend" then  
 os.exit() -- exits the app  
 end  
end  
Runtime:addEventListener( "system", onSystemEvent )  

This works fine, except when you suspend the corona simulator it actually closes the simulator out of your project and pops up the prompt when you first start the simulator to select which project to work with.
So it seems this code works a little too well… :slight_smile:
Now, with this code in place, if you build for the iphone, it builds fine, but does this little reset of the simulator when it has finished the build. So I didn’t think much of this, when it first started happening. I actually thought it was due to a new daily build.
It also does the restart after the build if you do any of the android type builds but use the Debug keystore, so again, it works fine for those builds.
But… if doing the android type builds and using any keystore other than the Debug one, the simulator decides to do it’s little restart right as it starts to do the build, so then it crashes.

To keep this from happening, I modified my exit on suspend code to check and only exit if we’re Not on the simulator. Here’s the code updated to reflect this check:

local function onSystemEvent( event ) -- put this in to exit on suspend in android devices.  
 if event.type == "applicationSuspend" then  
 if system.getInfo( "environment" ) ~= "simulator" then -- don't exit if we're on the simulator.  
 os.exit() -- exits the app  
 end  
 end  
end  
Runtime:addEventListener( "system", onSystemEvent )  

This allows the simulator to keep running when it does the build, thus gets me through the build ok. Why this problem only happens with android, and non-Debug keystores, I don’t know, but I think it’s a bug.

So here’s the fix documented in case anyone else runs in to this. I’ve burnt two solid days troubleshooting this one. [import]uid: 11193 topic_id: 33304 reply_id: 132365[/import]

I can do an Android build just fine if I use the Debug keystore, and I can also do an IOS build just fine with this exact same project. [import]uid: 11193 topic_id: 33304 reply_id: 132270[/import]

I tried re-creating my keystore with the following command:
[bash]
keytool -genkey -v -alias tesla -keystore tesla.keystore -keyalg RSA -keysize 2048 -validity 10000 -dname “CN=Tesla’s Electric Mist,O=iCOOLgeeks,C=US”
[/bash]

still crashed the corona simulator on build. [import]uid: 11193 topic_id: 33304 reply_id: 132272[/import]

Additional things I’ve tried today.

  • downloaded latest java (1.7.0_09), made sure it was the java highest in my path order. I was using 1.6.0_35 prior.
  • rebuilt my keystore using this new java, also using the two different commands listed above.
  • renamed my existing corona sdk folder, then downloaded new version 971 from daily builds.
  • rebooted a bunch.

But nothing works, I’m still getting this error only when trying to do a build with one of the android build types, and selecting a keystore other than the Debug one. I’m still getting the same error listed above within a few seconds, then the corona simulator restarts, and then completely dies again after another 10 seconds or so.

[import]uid: 11193 topic_id: 33304 reply_id: 132359[/import]

I just tried copying my whole project file to a new location, still no go. Then I tried deleting some of the icon images, but no good there either… I’m grasping at straws and don’t know what else to try. I get the same error everytime!!! [import]uid: 11193 topic_id: 33304 reply_id: 132361[/import]

I just built a real simple hello world type project and tried to build it using a non-Debug keystore and it works.
So that means it’s something wrong within my project. But I have no idea what.

  • I have been working on this project for 10 months and this is the first time I’ve tried to build an android build using a non-Debug keystore.
  • I can build fine for android. kindle, and nook using the Debug keystore.
  • I can build fine for iphone.
  • the app works perfectly on the simulator.

So basically, sometime within the last 10 months, I put something in my project that has broken this end process, but since this is the first time I’ve tried to do this final piece, I have no clue what I did or when I did it. Or if this step ever worked on my machine?
And the error that it spits out is absolutely zero help to me!!! [import]uid: 11193 topic_id: 33304 reply_id: 132363[/import]

Found the problem! - it’s a bug in corona. Here’s the issue and the fix for any future users that run into this.

I needed my app to exit on suspend.
For iOS I put “UIApplicationExitsOnSuspend = true,” in the plist, but couldn’t find a similar solution for android, so I put in some code to listen for a suspend event and exit when it gets one.
This is what I put in my main.lua file:

local function onSystemEvent( event ) -- put this in to exit on suspend in android devices.  
 if event.type == "applicationSuspend" then  
 os.exit() -- exits the app  
 end  
end  
Runtime:addEventListener( "system", onSystemEvent )  

This works fine, except when you suspend the corona simulator it actually closes the simulator out of your project and pops up the prompt when you first start the simulator to select which project to work with.
So it seems this code works a little too well… :slight_smile:
Now, with this code in place, if you build for the iphone, it builds fine, but does this little reset of the simulator when it has finished the build. So I didn’t think much of this, when it first started happening. I actually thought it was due to a new daily build.
It also does the restart after the build if you do any of the android type builds but use the Debug keystore, so again, it works fine for those builds.
But… if doing the android type builds and using any keystore other than the Debug one, the simulator decides to do it’s little restart right as it starts to do the build, so then it crashes.

To keep this from happening, I modified my exit on suspend code to check and only exit if we’re Not on the simulator. Here’s the code updated to reflect this check:

local function onSystemEvent( event ) -- put this in to exit on suspend in android devices.  
 if event.type == "applicationSuspend" then  
 if system.getInfo( "environment" ) ~= "simulator" then -- don't exit if we're on the simulator.  
 os.exit() -- exits the app  
 end  
 end  
end  
Runtime:addEventListener( "system", onSystemEvent )  

This allows the simulator to keep running when it does the build, thus gets me through the build ok. Why this problem only happens with android, and non-Debug keystores, I don’t know, but I think it’s a bug.

So here’s the fix documented in case anyone else runs in to this. I’ve burnt two solid days troubleshooting this one. [import]uid: 11193 topic_id: 33304 reply_id: 132365[/import]

Thanks a lot for your posts above. I spent several hours yesterday trying to figure out the same problem, before I found your fix.
You would think that Corona would have fixed this two years on. In fact it seems to be worse now, because my system crashed the simulator while using the Debug key.
[import]uid: 205335 topic_id: 33304 reply_id: 143702[/import]

Thanks a lot for your posts above. I spent several hours yesterday trying to figure out the same problem, before I found your fix.
You would think that Corona would have fixed this two years on. In fact it seems to be worse now, because my system crashed the simulator while using the Debug key.
[import]uid: 205335 topic_id: 33304 reply_id: 143702[/import]

Thanks a lot for your posts above. I spent several hours yesterday trying to figure out the same problem, before I found your fix.
You would think that Corona would have fixed this two years on. In fact it seems to be worse now, because my system crashed the simulator while using the Debug key.
[import]uid: 205335 topic_id: 33304 reply_id: 143702[/import]

Thanks a lot for your posts above. I spent several hours yesterday trying to figure out the same problem, before I found your fix.
You would think that Corona would have fixed this two years on. In fact it seems to be worse now, because my system crashed the simulator while using the Debug key.
[import]uid: 205335 topic_id: 33304 reply_id: 143702[/import]