Getting example app running in Android SDK

I am trying to pull up the example_app in Android SDK. I just downloaded the latest version (1.5.1), and have been trying to follow along with the guide at:

I have added the statement:

compile ‘io.particle:cloudsdk0.3.1’

to the build.gradle file. I downloaded the SDK .zip folder from, placed that folder on my C: drive. The Android SDK was giving me a “SDK location not found” error, and added the following statement to the file:


Then it gives me an error that the SDK at that location does not contain any platforms.

The guide isn’t very descriptive, and obviously assumes you have prior knowledge of app development. It says simply to “play with the example_app module included in the git repository”. I’m trying to get to the point where I can “play with the example_app”. I’ve looked through the forum, but can’t find any sort of descriptive “getting started” type of tutorial. Does anyone know of such a tutorial, or can you point me in the right direction on how to get the example app up and running?

If you’re not familiar with Android dev’t generally, you’ll definitely want to at least do a “Hello World” Android app before trying to do much with the SDK. (The SDK and setup lib don’t assume a lot of Android dev knowledge, but some basics are required.)

Fortunately, the Android dev’t site has some great starter tutorials to work from:

Hope this helps!

1 Like

Ok, I’ve worked through the first block of tutorials on:

…as suggested. That’s not helping me get the example app open. I did change the to:


and instead of saying it can’t find the SDK, it gives me the error:

Error:FAILURE: Build failed with an exception.

  • What went wrong:
    Task ‘generateDebugSources’ not found in root project ‘spark-sdk-android-master’.
  • Try:
    Run gradle tasks to get a list of available tasks. Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

So I guess that is progress. I’m just trying to open the example app…shouldn’t it be a tested out, compilable project? If it’s an example, shouldn’t you just be able to open it and not have to add a bunch of stuff just to get it to open? I can’t even view any of the files under the example_app folder…it just gives me an android frowny face and tells me “gradle project sync failed”.

The example app needs no special setup beyond a working Android Studio install, and it definitely compiles and functions – I use it all the time for testing changes to the Particle SDK. : )

Looks like the first thing to do is to fix your That “sdk.dir” property is supposed to point to the Android SDK, not to the Particle one. The easiest way to repair that is probably to just delete and see if Android Studio regenerates it (I think it will). If not, try creating a new sample project and copy over the from there.


First, thanks for the help. I have set the sdk.dir property exactly the same (cut and paste) as in the tutoral examples. I’ll explain what I’m doing, step by step…I’m sure I’m doing something wrong:

Download the from:

That gives me the folder “spark-sdk-android-master”

I put that folder under c:\android, then from the “Welcome to Android Studio” front page, I “open an existing project”, navigate to “example_app”, and it gives me:

Gradle settings for this project are not configured yet.
Would you like the project to use the Gradle wrapper?
(The wrapper will automatically download the latest supported Gradle version).
Click ‘OK’ to use the Gradle wrapper, or ‘Cancel’ to manually set the path of a local Gradle distribution.

I click ‘OK’, and right off the bat it gives me:

Error:SDK location not found. Define location with sdk.dir in the file or with an ANDROID_HOME environment variable.

Then I make the project, and it gives me:

Error:FAILURE: Build failed with an exception.

  • What went wrong:
    Task ‘generateDebugSources’ not found in root project ‘spark-sdk-android-master’.
  • Try:
    Run gradle tasks to get a list of available tasks. Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

I have the sdk.dir set to:

Which is exactly the same as my tutorial apps, and everything works fine with those. Can you tell what I’m doing wrong?

Thanks for the very thorough description, it’s really helpful. Just one other question: what version of Android Studio are you using? 1.5, 2.0-preview, something earlier…? EDIT: whoops, you already told me that in the first post. :wink:

Anyway, it looks like your is set up correctly now, so that’s not the issue. I’m going to try to repro with the steps you’ve listed and see what happens.

Awesome, thanks. I’m googling, and it appears that people get this when a project is imported from Eclipse. But I don’t think that is a factor here.

Same issue here. Checked everything. Does not make much sense.

Error:SDK location not found. Define location with sdk.dir in the file or with an ANDROID_HOME environment variable.

Ohhh. The file has to be in the root directory. For some reason Studio put the file in the example_app folder and not the root folder spark-sdk-android-master.

But the larger issue seems to be trying to build just the example_app does not work. You have to open the entire spark-sdk-android-master project. I also ran the gradlew.bat (not sure if that’s necessary). The project now builds just fine.


Good to hear it’s not just me. I moved the file to the spark-sdk-android-master folder, and it gave me error:

Error:(40, 15) error: cannot find symbol method isThisTheMainThread()
Note: Some input files use unchecked or unsafe operations.

So, you’re saying open the spark-sdk-android-master folder? Then the example_app pulls up from that? Edit: I opened the folder from the “welcome to android studio” screen, and it gave me the same error. Then I ran gradlew.bat, and tried it again, and it gave me the same error.

Obviously something has changed somewhere…does anyone know of a link to a working version of the example_app?

And if it helps, after giving the error, it pulls up the file, and it highlights the following line in red as the error:

if (EZ.isThisTheMainThread()) {

in this chunk of code:

private static void showToast(final Activity activity, @Nullable final String msg, final int length) {
    Runnable toastRunnable = new Runnable() {
        public void run() {
            Toast.makeText(activity, msg, length).show();

    if (EZ.isThisTheMainThread()) {;
    } else {

I commented the whole if/then out, it compiled, and I was able to download it to my phone. I try the login screen, and it just tells me “permission denied”. Shouldn’t you be able to log into your particle account from the example app?

Yea, I’m still trying to get up and running myself.Glad you were able to compile as well.

I got the same “permission denied” message at first as well. I updated my device id in line 71. You can get it from the web tool.

I wish there were documentation for this example app. I’m not sure what the hardware code should be. I keep getting errors when I run the app. I’ll post when I get it running. Best of luck.


Great, any info you can share would be greatly appreciated.

Particle folks,

It would be very helpful to have a tutorial on writing a basic app, with corresponding Particle code. For instance, the tinker app! Can us mere end-users get our hands on a working version of that project, or is it proprietary? That would be an outstanding starting point

Ultimately, I just want to make an app, where I can turn on and off a bunch of stuff. Like 10 buttons to send 10 different strings, which would correspond to controlling 10 outputs on the Particle. The IFTTT and DO button is nifty and all, but it’s only 1 thing at a time. If I want to control 10 things, I don’t want to sit there and open 10 recipes.

Isn’t that a lot of people’s goal with this whole IOT thing? Use an app to control stuff?? There doesn’t seem to be a bunch of info on how to reach that end.


Anybody? Does anybody have a compile-able app example? Maybe with corresponding device code? Even a simple button on an app to toggle an I/O?

Why is the source code to the particle app not available if this is all open source?

Also, I changed the file and put in my particle device ID. Now, instead of giving me “permission denied”, it just crashes on my phone and tells me that the app has stopped running.

Isn’t it :confused: ?

Hey! Awesome, thanks! My questions are:

How would I have found that, had I not been posting on forums for 16 days now?

Why does the guide at:

…make no reference to that, and it just directs you to see the “example_app” found at


If you look, it actually does

This is because the actual topic of this docs section is The SDK and not the Particle App.

By properly reading all the info in the respective section and not just the first few paragraphs :wink:

1 Like

I’m trying to build the tinker app for android using android studio. I managed to resolve the gradle errors but now i’m having an error with locating this resource. Can anyone help?

Replaced abc_ic_menu_moreoverflow_mtrl_alpha with ic_menu_moreoverflow_material
to build the project

This is because I directly accessed a resource reference from the support library. I’m working on an update this evening which fixes this, among other issues. Thanks for the detailed error report!

1 Like

Update: I’ve had to de-prioritize this a bit, so it may be 2-3 weeks before I get around to fixing these resource issues.