Error building the androidEmptyExample [SOLVED]

I’m following this guide in order to run the androidEmptyExample. I’m using mac, Android Studio and the OF release 0.9 for android (of_v20150910). I’ve installed the sdk and downloaded the ndk, as explained in the tutorial. I’ve adjusted the adding the ndk path and I’ve solved some missing dependencies through the Android Studio dialogs. After finishing the whole installation I’ve tried to build the example and I’ve got the following error:

Error:(146, 1) Execution failed for task ':ofAndroidLib:compileReleaseOF'.
> make failed with exit status 2

In the log I’ve noticed that there is a file not found

/bin/sh: /Users/da1/Library/Android/android-ndk-r9d/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86/bin/arm-linux-androideabi-g++: No such file or directory

Actually the release r9d suggested in the wiki does not contain the folder arm-linux-androideabi-4.9. Maybe the wiki is not updated?

I will try now if the release r10b contains the missing folder

I’ve tried with the latest nightly build too (20150917) and it still fails.
With the ndk r9d I’ve the same problem as before.
Using the r10b ndk the folder arm-linux-androideabi-4.9 is present, but another file can not be found

Information:(2) (Unknown) In file included

Error:(9, 26) stdint.h: No such file or directory

The folder android-ndk-r10b/prebuilt/darwin-x86_64/lib does not contain the gcc folder.

Should I open an issue on github for this?

I had the same issue yesterday. Just use the latest NDK, the info in the is outdated.

thanks @Prof_Sparkles for your reply.
It looks like the tutorial is not up-to-date.
Even with the last ndk, I was not able to run the example, I’ve added the the error on this issue
Which version of OF and Android Studio are you using?
On which emulator are you testing the app?

I’m not using an Emulator.
Have a look at
arturoc just pushed my changes to it

Use the latest NDK r10e

Hello @Prof_Sparkles, I’ve just opened a pull request to correct the NDK version on the wiki.
It would be also helpful to add how to run the examples contained in the of_release/examples/android , these steps are not clear enough to me, could you explain it better?
Double clicking build.gradle does not open any pop-up window where I can press “Add now”

What I ended up doing is the suggested manual method if importing the build file doesnt work.
When you can successfully compile, go to examples/android/emptyExample and copy the build.gradle to the example you want to compile. Then open up the settings.gradle with any text editor or Android Studio, which you used to import the project in the first place (from …/project/android/).
At the bottom in that file you can see a line that includes the emptyExample project which you just compiled. You can just use the same scheme by just replacing emptyExample with touchExample f.e.
There is also a comment that explains how you import project folders from the myApps folder.

When you did that re-sync the project and you will have a new compile target in the top bar that has the name of the imported example.


It does not works for me, I’m not able to run the examples. Here a recap of what I’ve done:

  • I’ve downloaded the last release (18/9) and I’ve changed this file that is not already in the current nightly release.

  • I’ve followed the steps on the tutorial
    until “Build and Run”. It takes around 3 minutes to compile, the builds finishes and i can run the emulator. I do not see anything except the android desktop in the amulator, but the log looks good
    DEVICE SHELL COMMAND: pm install -r “/data/local/tmp/cc.openframeworks.androidEmptyExample”
    pkg: /data/local/tmp/cc.openframeworks.androidEmptyExample

    Launching application: cc.openframeworks.androidEmptyExample/cc.openframeworks.androidEmptyExample.OFActivity.
    DEVICE SHELL COMMAND: am start -n “cc.openframeworks.androidEmptyExample/cc.openframeworks.androidEmptyExample.OFActivity” -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
    Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=cc.openframeworks.androidEmptyExample/.OFActivity }

  • In order to try out the examples, i do the following, i copy “the generated android app”, that I assume is OF/apps/myApps/androidEmptyExample to “a subdirectory of apps, at the same level as the sample”, that I assume is OF/apps/myApps. And here the problem, double clicking on build.gradle opens the AndroidStudio dialog. I can not check the option “Use local gradle wrapper”, but I’ve to specify a local one, that I don’t have. Also, i do not have a settings.gradle file that I can edit on the copied project folder.

I think I will try Eclipse, Android Studio seems still too experimental.

No thats not the example that gets compiled, thats just the emptyExample that is always in apps/myApps/ for reference. Like I said in the last post, its in /examples/android/androidEmptyExample.
Take the build.gradle from there and copy it to any example. Then add a line to this file that includes the example you want to compile.

f.e.: include 'examples:android:androidVideoExample'

Then re-sync the project and you have a new compile target in the drop down menu in the toolbar next to the “play”/compile button.

Ok, I’ve done as you have said.

  • I’ve copied the build.gradle file from OF/examples/android/androidEmptyExample to OF/examples/android/androidPolygonExample.

  • I’ve edited the file OF/openFrameworks/blob/master/libs/openFrameworksCompiled/project/android/settings.gradle adding include 'examples:android:androidPolygonExample' . (I assume that everytime i want to try a different example i will have to edit the same file, right?)

  • I’ve resynced the project, but the sync fails with this error:
    Plugin with id ‘’ not found.

Probably because of some missing dependencies. I’ve added these lines to my

build.gradle file
buildscript {
    repositories {
        mavenCentral() // or jcenter()

    dependencies {
        classpath ''

as suggested here:

But the sync still fails because of this error
Project with path ‘:ofAndroidLib’ could not be found in root project ‘androidPolygonExample’.

I’ve changed the structure of the android studio projects a bit, it’s explained in the readme files, but mainly now you just need to open any project folder in the android examples instead of having to open the main OF project.

let me know if it has any problem.

the new structure is already in github and will be in tomorrow’s nightly build

1 Like

Oh thats great, was indeed a bit confusing.

@edapx I ran into the same issue when opening the build.gradle of the example without including it manually. Weird that it doesn’t work for you neither way but I guess arturo’s edit should help with this.

@Prof_Sparkles @arturo I’ve finally have the androidPolygonExample working using the current branch, and changing the settings.gradle file, adding include 'examples:android:androidPolygonExample'.

The part that I’ve found confusing is that the project that you have to open in Android Studio is OF/openFrameworks/blob/master/libs/openFrameworksCompiled/project/android/settings.gradle, and then you modify this project(editing its settings.gradle file to include other examples, like this one with polygon) and you build it.
The way i was used in OF is to open a project in the examples folder and use it.
@arturo is this the way we are supposed to test the android examples?, on which “readme files” are you referring it exaclty?

I can run it only on a physical device, the emulator still does not show nothing, but i think it is something related to the API version used, in the emulator I’ve a virtual device with a shiny new API, my physical one is older.

Anyway, thanks for the support, it’s working :wink:

oh, i forgot to push my changes yesterday to the main repo. i’ve just done it.

by readmes i mean the markdown files in the docs folder:

With this changes now you don’t need to change the main project file in OF/openFrameworks/blob/master/libs/openFrameworksCompiled/project/android anymore. just open the folder of the example you want to run. Check the docs again since there’s a couple of things that need to be change in terms of config but it’s almost the same as before

About the emulator, it seems the first time you run the example it won’t run but then if you press play again leaving the emulator open it’ll run the application fine.

i’ve tested a couple of examples and there’s some problems with the emulator so it’s probably easier to just test everything in the device by now. The new emulator with support for x86 seems much faster than before so in the future i’ll look into making that work better,

The new tutorial looks good!
Everything works, just some troubleshooting that happens to me:

  • clicking on the console error on Android Studio generally worked, but it was not able to resolve the dependencies of the Android API 22. Opening the sdk manager and install the API 22 solved the problem.

  • Sometimes the physical android device is not visible anymore by android studio. In this case:

    adb kill-server
    adb start-server

I can add the last one to the Troubleshooting part of the wiki.

yes, if you can send a PR with both that’d be great