Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Android™ Runtime Development

Reply
Contributor
LanguageBug
Posts: 28
Registered: ‎06-12-2012
My Device: 9900, PlayBook
My Carrier: Orange

Persistent storage file IO fails on second run

 

Hi,

 

I've just encountered a problem after upgrading my Dev Alpha to OS version 10.0.10.263 (software release 10.9.10.35). Basically I installed two Android apps which are both based on the same framework, the first of which runs without a problem.  However the second ran once and then crashed on all subsequent attempts. It appears that this line is to blame:

 

out = m_context.openFileOutput(path, Context.MODE_PRIVATE);

 

It throws a NullPointerException, but m_context and path are definitely not null.

 

Here's the Logcat output:

 

01-31 00:53:57.232: W/ApplicationContext(21139650): Unable to create files directory
01-31 00:53:57.234: D/AndroidRuntime(21139650): Shutting down VM
01-31 00:53:57.234: W/dalvikvm(21139650): threadid=1: thread exiting with uncaught exception (group=7950c568)
01-31 00:53:57.241: E/AndroidRuntime(21139650): FATAL EXCEPTION: main
01-31 00:53:57.241: E/AndroidRuntime(21139650): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.bobw.balloon/com.bobw.balloon.BalloonActivity}: java.lang.NullPointerException
01-31 00:53:57.241: E/AndroidRuntime(21139650): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1651)
01-31 00:53:57.241: E/AndroidRuntime(21139650): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
01-31 00:53:57.241: E/AndroidRuntime(21139650): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
01-31 00:53:57.241: E/AndroidRuntime(21139650): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
01-31 00:53:57.241: E/AndroidRuntime(21139650): at android.os.Handler.dispatchMessage(Handler.java:99)
01-31 00:53:57.241: E/AndroidRuntime(21139650): at android.os.Looper.loop(Looper.java:123)
01-31 00:53:57.241: E/AndroidRuntime(21139650): at android.app.ActivityThread.main(ActivityThread.java:3687)
01-31 00:53:57.241: E/AndroidRuntime(21139650): at java.lang.reflect.Method.invokeNative(Native Method)
01-31 00:53:57.241: E/AndroidRuntime(21139650): at java.lang.reflect.Method.invoke(Method.java:507)
01-31 00:53:57.241: E/AndroidRuntime(21139650): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
01-31 00:53:57.241: E/AndroidRuntime(21139650): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
01-31 00:53:57.241: E/AndroidRuntime(21139650): at dalvik.system.NativeStart.main(Native Method)
01-31 00:53:57.241: E/AndroidRuntime(21139650): Caused by: java.lang.NullPointerException
01-31 00:53:57.241: E/AndroidRuntime(21139650): at android.app.ContextImpl.openFileOutput(ContextImpl.java:420)
01-31 00:53:57.241: E/AndroidRuntime(21139650): at android.content.ContextWrapper.openFileOutput(ContextWrapper.java:158)
01-31 00:53:57.241: E/AndroidRuntime(21139650): at com.bobw.android.resource.ResourceLoaderNative.saveBinary(ResourceLoaderNative.java:206)
01-31 00:53:57.241: E/AndroidRuntime(21139650): at com.bobw.android.resource.ResourceLoaderNative.saveResource(ResourceLoaderNative.java:185)
01-31 00:53:57.241: E/AndroidRuntime(21139650): at com.bobw.jmes.resource.ResourceLoaderProxying.saveResource(ResourceLoaderProxying.java:200)
01-31 00:53:57.241: E/AndroidRuntime(21139650): at com.bobw.jmes.resource.Resource.save(Resource.java:322)
01-31 00:53:57.241: E/AndroidRuntime(21139650): at com.bobw.jmes.resource.ResourceBank.saveResourceFile(ResourceBank.java:185)
01-31 00:53:57.241: E/AndroidRuntime(21139650): at com.bobw.jmes.resource.ResourceBank.processResource(ResourceBank.java:142)
01-31 00:53:57.241: E/AndroidRuntime(21139650): at com.bobw.jmes.resource.ResourceBank.updateResourceFile(ResourceBank.java:521)
01-31 00:53:57.241: E/AndroidRuntime(21139650): at com.bobw.jmes.resource.ResourceUtil.writeStreamable(ResourceUtil.java:369)
01-31 00:53:57.241: E/AndroidRuntime(21139650): at com.bobw.jmes.analytics.AnalyticsTracker.savePersistentData(AnalyticsTracker.java:324)
01-31 00:53:57.241: E/AndroidRuntime(21139650): at com.bobw.jmes.analytics.AnalyticsTracker.<init>(AnalyticsTracker.java:95)
01-31 00:53:57.241: E/AndroidRuntime(21139650): at com.bobw.android.analytics.AnalyticsTrackerNative.<init>(AnalyticsTrackerNative.java:42)
01-31 00:53:57.241: E/AndroidRuntime(21139650): at com.bobw.balloon.BalloonActivity.createAnalyticsTracker(BalloonActivity.java:50)
01-31 00:53:57.241: E/AndroidRuntime(21139650): at com.bobw.jmes.appcore.App.<init>(App.java:331)
01-31 00:53:57.241: E/AndroidRuntime(21139650): at com.bobw.android.appcore.AppNative.<init>(AppNative.java:49)
01-31 00:53:57.241: E/AndroidRuntime(21139650): at com.bobw.android.appcore.AppCoreActivity.onCreate(AppCoreActivity.java:69)
01-31 00:53:57.241: E/AndroidRuntime(21139650): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1050)
01-31 00:53:57.241: E/AndroidRuntime(21139650): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615)
01-31 00:53:57.241: E/AndroidRuntime(21139650): ... 11 more
01-31 00:53:57.252: W/ActivityManager(10707134): Force finishing activity com.bobw.balloon/.BalloonActivity

 

No amount of uninstalling and reinstalling will resolve this, although the app runs perfectly well on many Android devices.  The scary bit is that this exact same thing happened the last time I updated my Dev Alpha OS to 10.0.09.2320, however that time it was my other app that had an identical issue (unsurprising, using the same framework).  I eventually "fixed" it by reinstalling the OS, and I could probably do the same here, but my worry is that it's an issue that will crop up on real device.  That would be a really good way to earn a bunch of 1-star ratings real fast...  :-(

 

Any help appreciated!

 

Bob

 

Please use plain text.
Contributor
LanguageBug
Posts: 28
Registered: ‎06-12-2012
My Device: 9900, PlayBook
My Carrier: Orange

Re: Persistent storage file IO fails on second run

I've probably understated the severity of this issue.  One of the affected games, Balloon Gunner 3D, works on literally hundreds of Android devices, and is doing nothing out of the ordinary to cause this bug.  If this error occurs in production BB10 firmware then I assume a lot of Android apps will fail in the same way!

 

Please use plain text.
Contributor
LanguageBug
Posts: 28
Registered: ‎06-12-2012
My Device: 9900, PlayBook
My Carrier: Orange

Re: Persistent storage file IO fails on second run

Fantastic, I now have a 1-star review of Balloon Gunner 3D on BB10 saying that it won't open, but no other information has been given, and the user has not contacted me.  Am I seeing this problem in action?

Please use plain text.
Contributor
LanguageBug
Posts: 28
Registered: ‎06-12-2012
My Device: 9900, PlayBook
My Carrier: Orange

Re: Persistent storage file IO fails on second run

I believe this thread is describing the same problem: http://supportforums.blackberry.com/t5/Android-Runtime-Development/Permission-denied-when-trying-to-...

 

I can fairly reliably repeat this bug by taking a freshly-"security wiped" developer Z10 (software release 10.0.10.90):

1) Install both "Balloon Gunner 3D" and "Hordz 3D".

2) Start each app and go into Options, change a value (so it saves a file), back out, and then quit the app.

3) Restart the device.

4) Start one or both of the apps and one will most likely crash, showing either a black screen or an exception.

 

Once the exception error has occurred once the app cannot perform ANY file IO, even after being uninstalled and reinstalled - the only solution is a complete "security wipe" of the device.

 

It's interesting to note that the same versions of the apps didn't seem to show the problem when I was installing them directly from my computer, which suggests it's something to do with being downloaded from BlackBerry World.

 

Is there anyone at BlackBerry listening to this, as I've had to withdraw both apps for BB10 devices to avoid getting low ratings!

 

Please use plain text.