I’m pulling my hair out here…
i cannot get any smartapps to work from my iPhone (IOS 8). The live log reports java.lang.reflect.UndeclaredThrowableException @ line 104 (the line number seems to change, but randomly and does not seem to actually reference where the problem is from what I can tell)…
I can execute the apps in the IDE and they work correctly, and the code I’m using is either cut/pasted from posts here or blog posts, or from a template (no changes, just straight up).
I’m holding back on posting code here since it does not seem to matter what I run–the first app was trying to httpput to the grove streams site, and I’ve tried basic switch on-off and the “energy alert” code from the templates list.
I’m at my wits end–it makes no sense, and the error doesn’t point me at what to look at…
What am I missing here? Let me know what you need to see and I can post it.
I uninstalled and reinstalled the iOS app and things got slightly better, but for no apparent reason.
reinstalling the app fixed the “energy alert” app (which sends an sms message when energy crosses a threshold)…and now some data from the grove streams app is getting through…sometimes it gets the error, sometimes it doesn’t…and the error seems unrelated to wether the data gets through or not.
The app works PERFECTLY in the IDE – I can even select my real devices and have them trigger logging events every time from the IDE…but from the IOS side the app generates the error and only sometimes passes data through. Makes no sense to me at all.
Here’s the code:
When I run this code in the IDE, and subscribe to my real power monitoring switch, and toggle the switch on and off, I get this in the live log:
and the data shows up on my grove streams dashboard…looks great!
BUT, I publish this exact same code, and install with the exact same subscriptions on my phone, I get this in the live log:
*sometimes I’ll see a success posting message (but the data might not actually make it), but most of the time the app seems to stop with the error…also strange that it’s erroring now on the debug line…but after executing it.
I suspect the error has nothing to do with this line, since as I’ve tried different things to try to fix this, I’ve had the error report line number change to point at various other lines in the code even when all I changed was some formatting…but I’m new to groovy, so I’m not sure how to tell what this message is even telling me…
Hopefully this is enough information for someone to point me in the right direction? I’ve read the documentation and searched here (and google) for anything on this error and found nothing. If I need to keep reading, let me know and I’ll do what I have to, but I’m lost right now…
One more odd thing…I’m not sure why, on the log from the iOS app it tries 3 times to send the message (note, three “false” messages in the sample log in my last post. those three message attempts were from one actuation of the switch.
It seems the app runs fine if I leave i running in the ide. I didn’t realize I could do that… It was actually runnung in 2 places at once. The iOS one still doesn’t work if the other is stopped. The one running on the web was where the data getting through to grovestreams was coming from.
Is this what I’m supposed to do? At least it’s working now
It appears that when I cut and past the API key from gmail, it’s adding an additional space to the end of the key. the smart things iPhone app wasn’t showing the space, but if I hit backspace after pasting it clearly was there.
after I remove the space from the api key the app no longer throws the UndeclaredThrowableException message!
Followup question: Can the folks at smart things fix this java message so that we get something meaningful instead of “undeclared?” I was very close to just boxing all this up and sending it back because the only way I had to troubleshoot this was trial and error.
WRT to this specific case, I can follow up to see if there’s a better exception that could be thrown.
BUT, these types of exceptions may and likely will arise due to a variety of different errors. We’re looking at adding some sort of troubleshooting/debugging tips documentation to at least give people some strategies and tools for diagnosing problems.
But there will remain cases when an exception arises from some underlying API call, and the best we can do is simply report it.