This didn't start as a blog entry. I originally typed it up as an E-mail to Anit Kumar, Adobe's rockstar support guy who offered to help me on Twitter. See, I'm trying to build a mobile app using ColdFusion 11 mobile technology to have a chance at winning the $1,000 prize from Adobe's little contest. If you didn't know about it, please forget about it-- I don't want any more competition :)
So after several hours of fiddling yesterday, I got a lot of the workflow understood and working but still have some major hang ups and questions. After I finished typing this E-mail to Anit, I thought to myself, "Self, why not make this conversation public so everyone can benifit from it?" There's precious little information about CFClient out there already and some people like Adam C has already expressed interest in hearing my experiences-- not that I expect to sell him on CFClient or anything :)
This is a little rambly and I apologize for that. I'll try to blog some more organized thoughts after I get this all working. So, without further ado... Anit, please reply here if you can just so everyone can benefit from the answers-- even if it means I'm a numbskull and did it all wrong.
Hi Anit, thanks for the reply on Twitter. I have been having a heck of a time just getting the expense tracker sample app to work on my Samsung Galaxy S4. I have read all the articles and docs, I could find that Ram put out and watched his getting started videos on YouTube.
I have run into a number of issues, but to keep things simple, I'll start at the beginning.
I have installed the PhoneGap shell app that is linked to from here:
I can access the application in a browser on http://localhost:8511/ but of course, the device APIs aren't available so it errors out.
I can load that URL in the PhoneGap shell application, but the application never runs. The initial HTML loads, but the "no expenses found" never shows. Connecting the built-in Weinre server by adding "?inspect" to the URL shows only the following console message:
deviceready has not fired after 5 seconds.
Channel not fired: onFileSystemPathsReady
There are lots of hits on the internet for that error, but nothing related to CFClient. The advice is usually to upgrade to a newer version of the Phonegap libraries but I don't know how to do that or if it is possible with the PhoneGap shell application.
My next attempt was to create an "inspect build" in builder via the remote phonegap service. I also added the Wienre inspection information to the project properties as Ram showed. This generated an APK file that I installed to my device.
Occasionally, when I open the app nothing will happen. The HTML loads, but the expense list never appears and the Weinre server connects, but the console shows nothing. I'm unclear on if I can debug an actually apk app.
Most of the time, the app will run. However, I get errors trying to get a picture from the camera API. I have placed console.log() calls all throughout the code, and the error happens when trying to copy the image to persistent storage. even though cfclient.file.exists() says the temporary file exists, and cfclient.file.directoryExists says the target directory exists, the copy operation always fails with the following message:
message: "File/Directory specified was not found"
Another question is why Ram didn't use the built-in cfclient.file.exists() functions, but instead put in try/catches everywhere. Is that necessary or just a coding preference?
Also, if i don't try/catch errors myself (like the cfclient.file.copy() one), the actual error that is put in the Weinre console is totally unhelpful. I just get errors like these:
processMessage failed: Message: F09 File1365576477 n12
processMessage failed: Error: [object Object]
processMessage failed: Stack: undefined
Are those errors expected with CFClient? Is it a requirement for me to try/catch all my code to be able to see the real error? Is there a way to get a stack trace at all?
Also, the throwerror param to cfclient.file.createDirectory() doesn't seem to work. The entire contents of the createApplicationFolder() method should be able to just be replaced with this:
var persistentfileSystem = cfclient.file.setFileSystem("persistent");
var appFolderPath = persistentfileSystem.root.fullPath + "/" + variables.appFolderName;
But it still throws an error every time even though I'm passing in false for the throwError parameter.
I probably spent 5 hours trying to debug this yesterday just to get the expense tracker sample app working, but it is almost impossible to figure out what is going on. There is virtually no information on the Internet about the cfclient specific wrappers for the Phonegap APIs so all the many PhoneGap references I can find aren't of help.
Thanks for your help with all of this. Also, let me know if there is a forum I should be asking this on. Unfortunately, when I put feelers out on Twitter there appears to be little to no people out there with any experience in CFClient outside of the Adobe team.
Want to read more in this series? Pick one of the links below: