My experince trying to port Corona iPhone app to Android

Hi,

I have been using Corona for quite a while now and I have several apps in Apple’s App store. When Apple announced the changes to the TOS for the SDK (section 3.3.1) Apple lost my “trust”. It seems that Apple have the power to ruin all my efforts and work (and not to mention the money spent on buying Corona and joining the developer program) at a whim. For several weeks after this I gave up writing apps for the iPhone and turned to other things (specifically a cluster/cloud ESMTP server written in Go: http://code.google.com/p/goesmtp/).

But now that I have calmed down a bit and I see that, as of yet, Apple hasn’t actually rejected any apps for no being “originally written” in Obj-C. I am taking a different stance. I have bought myself an Android powered phone (running Android 1.6) and I want to turn my attention to developing (and porting my existing apps) to Android with the idea that if Apple put the iPhone versions in their App store as well then all the better for me.

So I took my simplest app (which calculates the distance of a thunder storm by measuring the time between the lightning and the thunder) and built it for Android using Corona 2.0 beta 5.

Here is what I discovered:

  1. I needed to added a config.lua file to handle the resolution of my phone. In fact my phone’s resolution is the same as the iPhone 3G so by adding the config.lua file everything scaled as expected.

  2. I added a build.settings file. Without it the app was in landscape mode with some crazy zoom factor. Setting the orientation to portrait in build.settings fixed that.

  3. It works! Well kind of…

Here are the problems:

  1. No sounds… I am using playEventSound and I can’t get it to work on the Android device. I have tried .caf, .wav and .mp3 files and I get nothing… PLEASE : Could a developer from Ansca please comment on this.

  2. If I press the home key and then return to my application I only get a blank screen. This is discussed here: http://developer.anscamobile.com/forum/2010/06/19/app-has-stopped-unexpectedly-android but there doesn’t seem to be a solution. PLEASE : Could a developer from Ansca please comment on this.

I have more complicated apps using webpopups, the accelerometer, background music and so on and at the moment I won’t even try to port those.

Any comments, insights or news from an Ansca developer on these issues would be great.

Thanks,

Gary
[import]uid: 4415 topic_id: 1398 reply_id: 301398[/import]

I’ve noticed the same issues. I have an Android game ready to go and my only issue right now is the event sounds.

As for event sounds not working, that’s a major problem right now. I really hope they can fix that soon.

For the home key one, I THINK that’s been fixed for the most part. Try rebuilding. The only issue I get with that now is textfields. [import]uid: 6678 topic_id: 1398 reply_id: 3921[/import]

For event sounds on Android, try OGG. For more info please see this thread:
http://developer.anscamobile.com/forum/2010/07/16/event-sounds-dont-work-android

We are continuing to work on the resume issues in Android.

Accelerometer is implemented. We’re working on text and video at the moment.
[import]uid: 54 topic_id: 1398 reply_id: 3944[/import]

@Eric:

What did you ment by “we are working on text atm”? [import]uid: 5712 topic_id: 1398 reply_id: 3963[/import]

Hi,

OK, I am now trying beta 6…

I still can’t get the sound events to work… I am now using a .ogg file (created using Audacity)… But still nothing… media.playSound works fine (including with MP3) but media.stopSound doesn’t. I will keep trying…

As for the resume problem, I guess I can see what the issue is now… If something is happening on screen then resume works better, but if the app is on a menu and is waiting for an event the screen remains black.

So I tried just adding a simple text animation to my menu, this does help things as now the app comes back and works, but sometimes the screen is corrupt on return, especially after the phone has been in sleep mode.

I have done my initial port of my game which uses the accelerometer and indeed the accelerometer code seems to work and the game is playable… Obviously the above problems remain…

Gary [import]uid: 4415 topic_id: 1398 reply_id: 4008[/import]

Hi,

I just want to revive this thread… I have now tried my application with Beta 7 and the same problems remain… A) The application can’t recover from being suspended and then restored (the screen is either blank or corrupt), B) Sound events don’t work. playEventSound() doesn’t work (I have tried with .mp3, .wav and .ogg files), media.playSound() works fine (including with MP3) but media.stopSound() doesn’t.

The same code works fine on the iPhone.

I AM STARTING TO GET FRUSTRATED… You keep releasing Betas but nothing is changing… THESE ARE FUNDAMENTAL PROBLEMS… If you fixed them I could release 4 apps for Android TODAY.

PLEASE, PLEASE, PLEASE TELL ME WHAT IS THE PLAN TO SOLVE THESE PROBLEMS.

Gary
PS. Sorry for shouting, but this is very frustrating. [import]uid: 4415 topic_id: 1398 reply_id: 4564[/import]

The resume issue is FB#269 and is assigned priority 2 (pri 1 is for crashes, this isn’t exactly a crash). Depending on your app, you may be able to workaround for now by drawing something on resume. It is hard to predict exactly when it’ll be fixed, we’ve improved the behavior but not solved it yet. We work on it for the next beta, and discuss it with you if we can’t find a solution yet.

On sound issues, see the other thread you posted this in:
http://developer.anscamobile.com/forum/2010/07/30/corona-20-sdk-beta-7-now-available

Thanks. [import]uid: 54 topic_id: 1398 reply_id: 4577[/import]

Eric,

Thanks for your replies… I really do appreciate it… Makes me feel like I am not alone!!!

I have got the sound working (and I replied in the thread http://developer.anscamobile.com/forum/2010/07/30/corona-20-sdk-beta-7-now-available

The secret is to pre-load ALL the sound events and then call them when needed:

local soundID1 = media.newEventSound( "sfx1.ogg" )  
local soundID2 = media.newEventSound( "sfx2.ogg" )  

And then when needed call:

media.playEventSound(soundID1)  
media.playEventSound(soundID2)  

Now for the resume…

I have tried several techniques… First I tried a simple timer which changed some text every second… In general this approach meant that something came back when the application was resumed but generally the screen was corrupt with white blocks and the text was in the wrong place etc.

I also tried:

  
local function onSystemEvent( event )  
if (event.type== "applicationSuspend") then  
 button1.isVisible = false  
 button2.isVisible = false  
elseif (event.type== "applicationResume") then  
 button1.isVisible = true  
 button2.isVisible = true  
 end  
end  
  
Runtime:addEventListener ("system", onSystemEvent);  
  

But that doesn’t achieve anything, the screen remains blank / black on resume.

I don’t mind workarounds… But I need some more clues on what to try…

Is applicationResume supported on Android???

Thanks,

Gary [import]uid: 4415 topic_id: 1398 reply_id: 4626[/import]

We’re working on fixing resume on android and hope to get this in the next beta. [import]uid: 54 topic_id: 1398 reply_id: 4637[/import]

Hi,

First a BIG thanks for the Corona developers for making such big improvements in Beta 8…

The resume problem “#269 Android: crash on resume (and various redraw issues on resume)” is almost fixed but not quite… If there is no screen activity the display remains blank but this can be solved by a simple 0.5 second timer function which makes any small and imperceivable change to the screen then it works!

I had a problem where the resume worked (as described above) but if the actual phone went to sleep then the application would resume at all (just black screen again). However after a reboot of my phone this problem seems to have disappeared.

So my App is almost ready for Android… But… I have now having trouble with the following:

  1. I can’t get the icons to work… My app appears with the standard Android icon (the green droid popping out of the right corner icon). Interestingly enough I haven’t tried to do the icon until now as the icon.png copied over form the iPhone version was working (for reasons unknown) but now isn’t, so I created the 3 Icon-?dpi.png files and looking at the build log they are found:
[copy] Copying /blah/blah/Icon-hdpi.png to /var/folders/F2/F262wv5-Gi8UC88qnWzNbk+++TI/-Tmp-/1282986053/replace/res/drawable-hdpi/icon.png  

Any clues to what I could be doing wrong???

  1. I can’t seem to get any decent text rendering… I have tried using lots of different fonts but the fonts don’t seem to change… Here is the code I am using:
sysFont = native.newFont("DroidSerif-Regular")  
  
local t0 = display.newText( "Hello World", 0, 0, sysFont, 18 )  
t0:setTextColor( 255, 255, 255, 255 )  

native.getFontNames() is working and I can get a list of font names OK, but the default font is very ugly and almost unreadable…

Comments anyone?

  1. Great news that WebPopup is now working on Android… But when I try to close the webpage with corona:close the web browser gives an error about “the protocol is not supported” and then there is a web page not available error. I get the same error if I build the weboverlay sample

Thanks,

Gary
PS. I am doing builds for Android 1.6

[import]uid: 4415 topic_id: 1398 reply_id: 5366[/import]

  1. Looks like for some reason the multires icons aren’t working for an Android 1.6 build. They are for 2.2. Please file a bug: https://developer.anscamobile.com/project/issues/

  2. Looks fine to me, on N1, compiled for 1.6.

  3. This is in the release notes. We just plain ran out of time. It’ll be in the next drop.
    [import]uid: 54 topic_id: 1398 reply_id: 5371[/import]

I spoke too soon on the font issue. It works fine in 2.2, but not if compiled for 1.6. Please file a bug. [import]uid: 54 topic_id: 1398 reply_id: 5373[/import]

Garysims, regarding your comment:

The resume problem “#269 Android: crash on resume (and various redraw issues on resume)” is almost fixed but not quite… If there is no screen activity the display remains blank but this can be solved by a simple 0.5 second timer function which makes any small and imperceivable change to the screen then it works!

Do you have a reproducible test case? You can mail it to support at anscamobile dot com.
[import]uid: 54 topic_id: 1398 reply_id: 5398[/import]

Eric,

Just build the HelloWord example, then press the home key, put your phone to sleep, resume and return to HelloWord… 1 time in 3 it won’t work.

Thanks,

Gary [import]uid: 4415 topic_id: 1398 reply_id: 5472[/import]

Gary,

Does Corona handle the different resolutions of phone’s?
When i start the fishies example in de simulator for the different android phones the fishies will not hit the edge of the screen.

Did you already make an application for Andriod?

Danny

[import]uid: 6873 topic_id: 1398 reply_id: 5505[/import]

Danny,

I have several apps that are 90% working on Android, but as of yet Beta 8 isn’t good enough for them to be released… I am using Android 1.6 and it seems that support for Android 2.2 is better… but I don’t have an Android 2.2 phone nor do I have $500 to buy one!!!

To handle the different resolutions you need to use the config.lua file…

But I have run the fishies example and it works fine…

Gary [import]uid: 4415 topic_id: 1398 reply_id: 5506[/import]

Gary,

I know about the config.lua file but if i use “zoomEven” the fishies will not hit the edge of the screen.
Also the font looks very blurry on the simulator.
I don’t have an Andriod phone so i was wondering.

Danny [import]uid: 6873 topic_id: 1398 reply_id: 5508[/import]

@garysims, I just tried 10x in a row (on N1) and didn’t repro. This is with our current internal version. [import]uid: 54 topic_id: 1398 reply_id: 5871[/import]

Hi,

First a big well done to you guys… Corona 2.0 is looking good… So I have actually managed to release my first ANDROID app in the Android Market… I posted it late last night and I have a huge 68 downloads so far!!! :slight_smile:

So what’s good about 2.0:

  1. The fonts are working for Android 1.6
  2. The icons are back for Android 1.6

Shame about “Android 1.6 on resume, animation sometimes is paused. Occasionally if there is no animation, a blank screen may occur. (1022)” but, I am living with it and I have gone ahead and released the app anyway…

So what is the app, well, my first iPhone App was called Thunder Clap: A simple to use utility to calculate the distance to a storm based on the time elapsed between the lightning and the thunder.

It seemed natural to start with the same app for Android and so I did and now it has been published.

You can get it from here: http://market.android.com/search?q=pname:uk.co.garysims.android.thunderclap

I think… See below

But (and sorry that there is always a but), I can’t get the app using my Android 1.6 phone… Using the URL above doesn’t work and the error page I get is exactly the same for apps that are marked for 2.0 etc. I actually managed to find the app by doing lots of scrolling in the Market place and when I clicked it to download it I got the same error.

Obviously people are downloading this as the stats tell me so…

So two things:

  1. Could anyone here on the forum with a 1.6 and 2.x phones please try and download this and tell me your results.

  2. Is it possible that somehow the package is marked for 2.x… How do I check?

Thanks,

Gary
PS. I just realized that I spelled ‘experience’ wrong in the original title post!!!
PPS. Very much waiting for Game Edition to come out. [import]uid: 4415 topic_id: 1398 reply_id: 6269[/import]

I’ve experienced most of these same issues. Missing icons, can’t sign the device, sounds were messed up, resolution was off -
I fixed everything but the signing part. We are still working through that…

My key just won’t sign a Corona app, but I’ve got many others app built using eclipse that the key works just fine for.

Richard
[import]uid: 9046 topic_id: 1398 reply_id: 6279[/import]