Alpha Video Training
Results 1 to 14 of 14

Thread: JSON Error With Phonegap Build

  1. #1
    Member
    Real Name
    Greg Carmody
    Join Date
    Apr 2017
    Location
    Sydney Australia
    Posts
    203

    Default JSON Error With Phonegap Build

    Hi,

    I converted my phonegap app to use client-side data caching instead of SQL access. I have a couple of list controls that I populate with data from the cache using the setListColumnsAndPopulate method.

    So I can run the app using 'Live Preview" and it will also run in Chrome without any issues. However, when I try it on Android tablet after phonegap build, I get this error as soon as the app starts:

    ----------------------------------------------
    Alert
    Error - Could not JSON.parse data in file
    ----------------------------------------------

    I don't really know where to start debugging this ? Any help appreciated.

    Thanks,
    Greg

  2. #2
    "Certified" Alphaholic
    Real Name
    David Kates
    Join Date
    Apr 2008
    Location
    Unionville, ON
    Posts
    7,567

    Default Re: JSON Error With Phonegap Build

    You'd have to post a sample UX showing this error. Where is the error occurring? At what point? Is it setListColumnsAndPopupate? Is it the data cache?

    Android is very simple to set up for debugging. Search the Web for Android debugging and you'll find how to set it up on your device... and how it works when the device is connected via a cable to your PC.
    Once you have debugging set up, the console errors will give you more detail.

  3. #3
    Member
    Real Name
    Greg Carmody
    Join Date
    Apr 2017
    Location
    Sydney Australia
    Posts
    203

    Default Re: JSON Error With Phonegap Build

    It looks like the error is occurring with the data cache. Android is trying to load a file, "http://192.168.0.4:1580/EDCMobile/A5SessionFile/jobs.json" and can't find it. (jobs is one of the entries in my client-side data cache). I checked the link to the file, and the directory "A5SessionFile" doesn't exist.

    Here is the excerpt from logcat:
    12-08 13:03:10.964 18460-18510/au.com.hymans.mobile_edc D/FileTransfer: download http://192.168.0.4:1580/EDCMobile/A5...File/jobs.json to file:///data/user/0/au.com.hymans.mobile_edc/files/files/__AADataCache/A5SessionFile/jobs.json
    12-08 13:03:10.966 18460-18533/au.com.hymans.mobile_edc D/FileTransfer: Download file:http://192.168.0.4:1580/EDCMobile/A5...File/jobs.json
    12-08 13:03:10.972 18460-18533/au.com.hymans.mobile_edc D/NetworkSecurityConfig: No Network Security Config specified, using platform default
    12-08 13:03:10.978 18460-18533/au.com.hymans.mobile_edc I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
    12-08 13:03:10.979 18460-18533/au.com.hymans.mobile_edc I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
    12-08 13:03:11.042 18460-18533/au.com.hymans.mobile_edc E/FileTransfer: {"code":1,"source":"http:\/\/192.168.0.4:1580\/EDCMobile\/A5SessionFile\/jobs.json","target":"file:\/\/\/data\/user\/0\/au.com.hymans.mobile_edc\/files\/files\/__AADataCache\/A5SessionFile\/jobs.json","body":"\u001f�\b\u0000��*Z\u0000�]PAn�0\u0010�#��\u0001�\t\u0004�HV��\u0004.�D�\u001ezt�ld��v@�^z�����j�.�Ӯ��Z\u0010����N\u00052\u001e��^aU�%�\u001b\u000f{3iN�\/\u0019�$����g�\u0016�7\u00033��\u0002����#���\u0011H���� \u0015�zsA���fp��\u0019\n\u000f�@\u0007��h\u0004��B:ph�h�pkL\u0007m��s\u001b<�Z��A��\u000f�\u0016��;*3�P{�$\u001d)VY\u000e��T���X���\n��

  4. #4
    Member
    Real Name
    Greg Carmody
    Join Date
    Apr 2017
    Location
    Sydney Australia
    Posts
    203

    Default Re: JSON Error With Phonegap Build

    Here is the remainer of the error from Logcat:
    java.io.FileNotFoundException: http://192.168.0.4:1580/EDCMobile/A5...File/jobs.json
    at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:254)
    at org.apache.cordova.filetransfer.FileTransfer.getInputStream(FileTransfer.java:588)
    at org.apache.cordova.filetransfer.FileTransfer.access$500(FileTransfer.java:69)
    at org.apache.cordova.filetransfer.FileTransfer$4.run(FileTransfer.java:878)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
    at java.lang.Thread.run(Thread.java:762)

    Not sure why it is trying to access a json file on the server (192.168.0.4 is the ip of the server). I would have thought it would be sending sql to get the data from the db, then populating the data to a json file on the client?

    Any help appreciated.

    Thanks,
    Greg

  5. #5
    "Certified" Alphaholic
    Real Name
    David Kates
    Join Date
    Apr 2008
    Location
    Unionville, ON
    Posts
    7,567

    Default Re: JSON Error With Phonegap Build

    Are the versions for your plugins set?

  6. #6
    Member
    Real Name
    Greg Carmody
    Join Date
    Apr 2017
    Location
    Sydney Australia
    Posts
    203

    Default Re: JSON Error With Phonegap Build

    Yes. However it keep generating duplicates without the version numbers everytime I do a save and submit to phonegap.

  7. #7
    "Certified" Alphaholic
    Real Name
    David Kates
    Join Date
    Apr 2008
    Location
    Unionville, ON
    Posts
    7,567

    Default Re: JSON Error With Phonegap Build

    Right... then you're using an Alpha version that is not the current pre-release? And it's a mess.

    So, Save only... and then in the Confirmation dialog that pops up, click the link "Click here to view/edit the PhoneGap Build XML configuration file". Check your plugins for versions... delete the duplicates... save it... and then, when you're returned to the Confirmation dialog, click Submit.

  8. #8
    Member
    Real Name
    Greg Carmody
    Join Date
    Apr 2017
    Location
    Sydney Australia
    Posts
    203

    Default Re: JSON Error With Phonegap Build

    Same error......any other ideas?

  9. #9
    "Certified" Alphaholic
    Real Name
    David Kates
    Join Date
    Apr 2008
    Location
    Unionville, ON
    Posts
    7,567

    Default Re: JSON Error With Phonegap Build

    You'll have to submit the issue to Alpha.

  10. #10
    Member
    Real Name
    Sean OKelly
    Join Date
    Sep 2015
    Location
    Charleston, WV
    Posts
    205

    Default Re: JSON Error With Phonegap Build

    Try using the PreRelease ONLY for the phonegap publishing. It is working for us, although it could cause other issues. Try it and let me know how it goes. I have asked Selwyn when the Stable verison will be updated, and I'm hoping very soon.

  11. #11
    "Certified" Alphaholic
    Real Name
    David Kates
    Join Date
    Apr 2008
    Location
    Unionville, ON
    Posts
    7,567

    Default Re: JSON Error With Phonegap Build

    That's unknowingly dangerous. You've no idea what's going on behind the scenes while Alpha is generating the code needed for PhoneGap Build. You're taking a component developed and tested in one version and pushing it through processes in a much higher version. You've no idea if, when, where, it could break.

  12. #12
    Member
    Real Name
    Greg Carmody
    Join Date
    Apr 2017
    Location
    Sydney Australia
    Posts
    203

    Default Re: JSON Error With Phonegap Build

    Will stick with the current release in that case. It is building without an issue if I follow the instructions provided by David to modify the config.xml before submit.

    Back to the original issue, I had a change to my approach re using client-side data cache. After it became obvious it would be a major effort to sync changes back to the cache, and then sync the cache back to the db, I have eliminated the data cache and converted my drop-down controls to list controls. That way I can setup a hierarchy of list controls, and use the persist feature of the parent list control to cache the data for offline use, and also be able to sync back to the db once back online.

    Eliminating the data cache seems to have fixed the JSON parse error.

    Greg

  13. #13
    Member
    Real Name
    Sean OKelly
    Join Date
    Sep 2015
    Location
    Charleston, WV
    Posts
    205

    Default Re: JSON Error With Phonegap Build

    Hey David, you are right - but it worked fine. The new stable release fixes the issue though, so we only had a short period of time to worry about.

  14. #14
    "Certified" Alphaholic
    Real Name
    David Kates
    Join Date
    Apr 2008
    Location
    Unionville, ON
    Posts
    7,567

    Default Re: JSON Error With Phonegap Build

    No such thing as a new stable release... just a new official release. Check out the new pre-releases which fix the official release.

Similar Threads

  1. Phonegap build error
    By fcastillo in forum Mobile & Browser Applications
    Replies: 1
    Last Post: 11-21-2017, 02:56 PM
  2. Phonegap Build error
    By fatiha@pacific-orient.com in forum Mobile & Browser Applications
    Replies: 27
    Last Post: 11-16-2017, 11:52 PM
  3. Phonegap build not available and gives error
    By swest in forum Mobile & Browser Applications
    Replies: 1
    Last Post: 05-16-2017, 12:23 PM
  4. Phonegap Build Error
    By glenschild in forum Mobile & Browser Applications
    Replies: 2
    Last Post: 11-23-2016, 12:38 PM
  5. Phonegap Build Error
    By lutherhuffman in forum Mobile & Browser Applications
    Replies: 3
    Last Post: 04-25-2014, 10:25 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •