Urgent: Amazon Rejected App for Kindle Fire HD

Apparently Corona SDK has the following issues with the new Kindle Fire and the new Kindle Fire HD, and our apps will be rejected by Amazon:

  • Hibernation: Open apps select any part of the game, start playing-Hibernate-power on-before unlocking-change the device orientation app force closes. For other options app resets and comes to main menu page

  • Core Functionality : On 1st launch app music is muted, Sound plays after a few navigations and hibernating device. Also when music is playing, sometimes after hibernation music is muted. It’s inconsistent but its reproducible at several intervals.

All of my apps were rejected because of these issues. The first one is reproducible pretty easily. Open a landscape app, lock the device. Turn the device to portrait, unlock, and the app crashes.

The second one I have not been able to reproduce yet and am wondering if it’s a result of the same issues as the first.

I will submit this as a bug as well, but need some urgency around this.

Thanks,
Kevin [import]uid: 84258 topic_id: 31200 reply_id: 331200[/import]

Was just able to reproduce the second error. Had to leave the device suspended/locked for a few minutes, then when I unlocked the app had no sound at all. Exiting and resuming the app and sound is back. [import]uid: 84258 topic_id: 31200 reply_id: 124751[/import]

Got ABD working and this is what I see:

09-20 18:09:36.557: W/ActivityManager(199): Unable to start service Intent { act=android.intent.action.SCREEN_ON }: not found
09-20 18:09:37.026: W/dalvikvm(23279): threadid=13: thread exiting with uncaught exception (group=0x40a841f8)
09-20 18:09:37.034: E/AndroidRuntime(23279): FATAL EXCEPTION: GLThread 744
09-20 18:09:37.034: E/AndroidRuntime(23279): java.lang.NullPointerException
09-20 18:09:37.034: E/AndroidRuntime(23279): at com.ansca.corona.Controller.onDrawFrame(Controller.java:237)
09-20 18:09:37.034: E/AndroidRuntime(23279): at com.ansca.corona.CoronaRenderer.onDrawFrame(CoronaRenderer.java:74)
09-20 18:09:37.034: E/AndroidRuntime(23279): at android.opengl.derived.SwapGLSurfaceView$GLThread.guardedRun(SwapGLSurfaceView.java:968)
09-20 18:09:37.034: E/AndroidRuntime(23279): at android.opengl.derived.SwapGLSurfaceView$GLThread.run(SwapGLSurfaceView.java:825)
09-20 18:09:37.073: D/Sensors(199): ALS readEvent
09-20 18:09:37.120: W/ActivityManager(199): Force finishing activity com.kevinbradford.games.firstgradefull/com.ansca.corona.CoronaActivity
09-20 18:09:37.620: W/ActivityManager(199): Activity pause timeout for ActivityRecord{415010c8 com.kevinbradford.games.firstgradefull/com.ansca.corona.CoronaActivity}
[import]uid: 84258 topic_id: 31200 reply_id: 124758[/import]

Hello Kevin,

Regarding the audio issue, I’ve tested our SimpleMixer sample app on our Kindle Fire HD, but the audio always suspends/resumes correctly when at the screen lock or when pressing the home key. I’m thinking the app reviewer had some other app claiming the audio hardware at the time and he didn’t know it… and after switching to enough apps the device shutdown the background process that was claiming the audio hardware. At least that’s my theory.

Regarding the orientation change crash, I wasn’t able to reproduce it. I’ve done quite a lot of orientation tests with the Kindle Fire HD this week such as fixed portrait, fixed landscapeRight, portrait & landscapeRight, landscapeRight & landscapeLeft, and portrait & portraitUpsideDown. Not once have I ever seen any crashes. Even after the screen lock and suspend/resume. I’m not convinced that an orientation change is the cause of this issue. Can you reproduce this crash with any of our sample projects? How about the “Interface/NativeDisplayObjects” sample app that is included with the Corona SDK?

Regarding the stack trace that you’ve posted, I’ve looked at our code and there is a possible race condition there that can cause a crash. That part of the code has nothing to do with orientation changes (which might be why I can’t reproduce it), but I can put in some safe guards in the code to prevent that race condition and make that fix available in tomorrow’s daily build. It’ll be a blind fix since I can’t reproduce this issue, so cross your fingers. [import]uid: 32256 topic_id: 31200 reply_id: 124782[/import]

Thank you for the response. I have been testing more, and half of my apps will crash on this orientation change and the other half have no issue. I am comparing build settings and other code and so far can find no differences in apps that crash and ones that don’t. No problems on the sample projects either. Any suggestions on where to look in my code?

I can’t believe it’s not an orientation issue. It’s the only thing I do that consistently makes it crash, 100% of the time. I’ll try the daily build fix once it’s available and let you know the results. [import]uid: 84258 topic_id: 31200 reply_id: 124785[/import]

Based on the stack trace that you gave me, it’s a race condition in our rendering code that’s causing the crash. So you may just have to get lucky (or unlucky?) to make it happen. I’m putting the finishing touches into this now. [import]uid: 32256 topic_id: 31200 reply_id: 124788[/import]

Kevin,

I just added those safe guards now. This fix will be made available in daily build #920, tomorrow. If you could let me know if it fixes this issue for you then that would be great. [import]uid: 32256 topic_id: 31200 reply_id: 124798[/import]

I’ve found that the issue occurs during part of my build process after I use Corona. I have always used apkmgr to decompile the apk so that I can modify the AndroidManifest.xml and remove unneeded permissions.

If I install one of my modified apks, I can recreate this error. If I install the apk straight from Corona I receive no error at all.

Why would my apkmgr stuff cause such an error? Here’s a script of what I do:

  1. run apkmgr Script.bat
  2. select apk, decompile apk
  3. open manifest.xml in a text editor and remove permissions
  4. recompile apk using apkmgr
  5. use jarsigner to sign the apk
  6. zipalign the apk

I just ran through it again and skip step 3 (didn’t touch any files, just decompiled, recompiled and then signed/zipaligned) and it still has this error. So something about apkmgr, jarsigner, or zipalign is causing this odd behavior? [import]uid: 84258 topic_id: 31200 reply_id: 124887[/import]

IGNORE COMMENT, THIS IS AN INCORRECT STATEMENT:

Still waiting for 920 to show up, but I was looking at the change logs and saw you did some orientation changes in 919, so installed that (I had been at 912). No more crashes! So support for Android 2.3+ orientation changes must be required for the new Kindle.

I’ll still wait for 920 to show and let you know the results. [import]uid: 84258 topic_id: 31200 reply_id: 124864[/import]

I’m thinking that you’re apkmgr tool does not support some of the newest AndroidManifest.xml settings. Like it doesn’t know how to extract the newest Android 4.x settings, so it ends up stripping them out. For example, if the following “android:configChanges” attribute is not set up as shown below, then your app *will* crash on an Android 4.x device during an orientation change. I suspect that the “orientation” setting is being stripped out by the apkmgr tool.
(Note that I’m not showing all of the attributes in the below activity tag.)
[lua] [/lua]

Also, please note that we can’t offer you tech-support once you’ve hacked your APK with a 3rd party tool. This is for reasons exactly like this situation, where the Corona built app works correctly but stops working once you’ve edited it with a 3rd party tool. Of course, you’re free to do whatever you want with the APK afterwards, but you’re on your own from there.

Regarding build #920, we had some server problems last night, so the daily build should be published later today. However, based on what you are telling me up above, this build will not fix this issue. This is an issue with your AndroidManifest.xml file missing required settings. [import]uid: 32256 topic_id: 31200 reply_id: 124897[/import]

Thank you for the help. I checked the manifest and orientation is indeed there, but screenSize is missing:

android:configChanges=“keyboardHidden|orientation”

I’ll look for an updated apk tool, perhaps that will help.

Understandable about not helping with modified apks. I just hope you have modifying Android permissions via build.settings high on your priority list, because this is becoming a huge issue!

[import]uid: 84258 topic_id: 31200 reply_id: 124909[/import]

Found a temporary workaround for this issue. I reverted back to Corona build 870, which is the build right before you started targeting Android 4.1 . This allows my apktool to work correctly and I can modify without causing any side affects.

Apparently there is no good working apktool for Android 4.1. If anyone can find one that doesn’t mess up the manifest like Joshua was describing, I’d love to try it out.

Thanks again Josh, you’ve been a huge help!

Kevin

[import]uid: 84258 topic_id: 31200 reply_id: 124916[/import]

I hate to keep bumping my own thread, but a note for Josh. I just installed build 921 and decided to give it a go, and it works great. It does restart my application if I change orientation while suspended, but it does not crash. According to Amazon, this should be sufficient.

Is this related to the race conditions you found, or did you change other orientation behavior? [import]uid: 84258 topic_id: 31200 reply_id: 124917[/import]

Hi Kevin,

Sorry for not getting back to you earlier. Great to hear that my new safe guards are working and is preventing that race condition crash. Thanks for that stack trace that you posted. That was a big help.

The reason that your app is restarting after an orientation change is because that “screenSize” setting is missing from your AndroidManifest.xml file. Restarting your app after an orientation change or screen size change is actually the default Android behavior. Terrible, eh? That setting in your manifest file tells Android that we want to override that behavior and prevent the restart. That’s documented on Google’s website here…
http://developer.android.com/guide/topics/manifest/activity-element.html#config

If I remember right, it will only restart your app on orientation change on Android 4.x devices. It should not restart on older Android OS versions. [import]uid: 32256 topic_id: 31200 reply_id: 124956[/import]

By the way, Kevin, if you use apktool 1.5.0, the android:configChanges=“keyboardHidden|orientation|screenSize” is preserved. I just checked. [import]uid: 160496 topic_id: 31200 reply_id: 124962[/import]

Mike, I’ve tried using apktool 1.5 and build 921 of Corona and my manifest doesn’t include that.

What command are you using to decompile? Did you do anything special with “frameworks”?

Are you using the apktool from:
http://forum.xda-developers.com/showthread.php?t=1755243 [import]uid: 84258 topic_id: 31200 reply_id: 124983[/import]

Yes, that one, and the aapt.exe he points to in the same post.

I use the script.bat of APK Multitool, but I don’t think it does anything special. Here’s the line from my AndroildManifest.xml:

< activity android:theme="@*android:style/Theme.NoTitleBar.Fullscreen" android:label=“Name of app” android:name=“com.ansca.corona.CoronaActivity” android:launchMode=“singleTask” android:screenOrientation=“landscape” android:configChanges=“keyboardHidden|orientation|screenSize” >
[import]uid: 160496 topic_id: 31200 reply_id: 124986[/import]

My latest NOOK app was rejected about 5 times (in the last 2 weeks) because they said it wasn’t playing sound. I tried everything. Well almost. The last thing worked --> changed all audio files to .mp3, it worked and they accepted it. [import]uid: 40033 topic_id: 31200 reply_id: 124988[/import]

mike, I’m using the exact same aapt and apktool and I don’t get screenSize. Wondering if it’s possibly something about how I’m building in Corona, or my build settings?

Would you be willing to share an apk with me so I can try my apktool. That would atleast narrow down what’s wrong with my setup.

If you’d be up for it, you can send it to kbradford@gmail.com [import]uid: 84258 topic_id: 31200 reply_id: 124993[/import]

Was just able to reproduce the second error. Had to leave the device suspended/locked for a few minutes, then when I unlocked the app had no sound at all. Exiting and resuming the app and sound is back. [import]uid: 84258 topic_id: 31200 reply_id: 124751[/import]