installing packaged app fails with "JSONException: Value undefined… cannot be converted to JSONObject"

RESOLVED WONTFIX

Status

()

P3
normal
RESOLVED WONTFIX
5 years ago
3 years ago

People

(Reporter: myk, Unassigned)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

(Whiteboard: [WebRuntime])

(Reporter)

Description

5 years ago
When I try to install the packaged app Cut The Rope from <http://dl.dropboxusercontent.com/u/171684/mwc-apk-test/index.html>, after the APK install completes, Fennec throws "org.json.JSONException: Value undefined of type java.lang.String cannot be converted to JSONObject" at InstallHelper.java line 92 <http://mxr.mozilla.org/mozilla-central/source/mobile/android/base/webapp/InstallHelper.java?rev=6638c6ade38c#92> with this misleading stack trace:

 14072   GeckoWebAppInstall..  E  mozApps.install failed
 14072   GeckoWebAppInstall..  E  org.json.JSONException: Value undefined of type java.lang.String cannot be converted to JSONObject
 14072   GeckoWebAppInstall..  E  at org.json.JSON.typeMismatch(JSON.java:111)
 14072   GeckoWebAppInstall..  E  at org.json.JSONObject.<init>(JSONObject.java:159)
 14072   GeckoWebAppInstall..  E  at org.json.JSONObject.<init>(JSONObject.java:172)
 14072   GeckoWebAppInstall..  E  at org.mozilla.gecko.webapp.InstallHelper.access$000(InstallHelper.java:29)
 14072   GeckoWebAppInstall..  E  at org.mozilla.gecko.webapp.InstallHelper$1.run(InstallHelper.java:59)
 14072   GeckoWebAppInstall..  E  at android.os.Handler.handleCallback(Handler.java:733)
 14072   GeckoWebAppInstall..  E  at android.os.Handler.dispatchMessage(Handler.java:95)
 14072   GeckoWebAppInstall..  E  at android.os.Looper.loop(Looper.java:136)
 14072   GeckoWebAppInstall..  E  at org.mozilla.gecko.util.GeckoBackgroundThread.run(GeckoBackgroundThread.java:32)

I haven't fully investigated yet, but I think "Value undefined" means the actual string "undefined" is being passed to the "new JSONObject" call.

The return value of that call is being passed to message.putOpt, which suggests the value is optional.  But the value is first passed to "new JSONObject", which requires it to be a value that can be turned into a JSON object and throws the exception when it isn't.

The APK in question <http://dapk.net/application.apk?manifestUrl=https%3A%2F%2Fmarketplace.firefox.com%2Fapp%2Fa22e0277-35bc-434d-9371-1568c75fc726%2Fmanifest.webapp> does not have a mini-manifest, which looks like it would live at res/raw/mini.json alongside res/raw/manifest.json.

So ApkResources.getMiniManifest should be returning a recognizably empty value like the null value rather than the string "undefined", and then InstallHelper should avoid passing that empty value to "new JSONObject".

But I also wonder if the mini-manifest is really optional for a packaged app APK.  If not, then there's also a bug in the APK Factory, which isn't including it in the APK.

Comment 1

5 years ago
> But I also wonder if the mini-manifest is really optional for a packaged app APK.  If not, then there's also a bug in the APK Factory, which isn't including it in the APK.

Good call, mini.json should be there now.
The implementation of the client relies on the existence of the mini-manifest. It could be derived by from the "manifestUrl", which in the case of packaged apps is the url of the mini-manifest, however, we put it in the APK to save another network call. 

Feasibly, we could do without the mini-manifest, but this would mean a huge change to the dom/webapps module.

Comment 3

5 years ago
It's a bug if mini.json isn't present with packaged apps.
(Reporter)

Comment 4

5 years ago
(In reply to Austin King [:ozten] from comment #3)
> It's a bug if mini.json isn't present with packaged apps.

It's a bug in the APK!  But the client should do a better job of reporting and recovering from that bug.  So let's focus this bug on implementing that better job.

Comment 5

5 years ago
> It's a bug in the APK!

Which is fixed now, right? Or is the bug different then comment#1
(Reporter)

Comment 6

5 years ago
(In reply to Austin King [:ozten] from comment #5)
> > It's a bug in the APK!
> 
> Which is fixed now, right? Or is the bug different then comment#1

Yes, it's fixed!
(Reporter)

Updated

5 years ago
Priority: -- → P3
(Reporter)

Updated

5 years ago
Whiteboard: [WebRuntime]
(Reporter)

Comment 7

3 years ago
Per bug 1235869, we're going to disable the Android web runtime, so we won't fix this bug in it.

(This is part of a bulk resolution of bugs in the Firefox for Android::Web Apps component, from which I attempted to exclude bugs that are not specific to the runtime, but it's possible that I included one accidentally.  If so, I'm sorry, and please reopen the bug!)
Status: NEW → RESOLVED
Last Resolved: 3 years ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.