However I’m getting this error (referring to the ("longitude")
Error:(56, 96) error: unreported exception VariableDoesNotExistException; must be caught or declared to be thrown
I don’t understand why this error would occur. Obviously the variable doesn’t exist yet because it is going to retrieve it from my photon, but it can’t until this code compiles!
yes my device is online and the variable exists within the code I flashed to the particle. I initialized it as double longitude = 0; just below my header declarations and above void setup { ... }.
It has nothing to do with the photon though as Android Studio won’t compile the code as the variable doesn’t exist within it. But that’s the whole idea of the getDoubleVariable() to fetch it.
If you get an unhandled exception error, you should actually catch that exception in a try ... catch block.
Or when a function is expected to (re)throw execptions (since it’s not going to handle them internally), it must do so too.
The same goes for functions that are meant to return a return-value, all code paths - including exceptions - must do so.
Since this is not really a Particle specific question, I’d just refer you to some more general answer to that question
BTW, the mere existance of the Particle.variable() in your code does not really prove it’s actually available on the device - e.g. when your code isn’t really the one that’s running on the device.
To actually know whether it exists or not can be checked via console.particle.io/devices or particle list
Not sure if it has anything to do with it or not, but I noticed in your title and your error that you write “Android” as “Andriod”. You might want to correct that.