This is a tutorial on how to setup openFrameworks for Android on Windows. The current tutorial only explains how to do this using Linux or Mac OS X.
My MinGW patches for openFrameworks 0071 are now merged into the develop branch of openFrameworks.
* update August 2012 * I’ve fixed openFrameworks 0071 for MinGW on my branch (which will hopefully merged into the develop branch soon): develop-0071-android-r8b-mingw
- Eclipse (with CDT plugin)
- Installed JDK (Java SE 7 Update 5) – I am using the x64 version but if you run into problems give x86 a try.
- Android SDK
- Installed ADT Plugin for Eclipse
- Android NDK (this tutorial uses r8b)
- Apache ANT
1. Install MinGW/MSYS
Install MinGW and MSYS according to this tutorial:
How to install MinGW, MSYS and Eclipse on windows
(Don’t forget to install the ADT plugin as well)
2. Setup SDKs and PATHS
After downloading the Android NDK, the Android SDK and Apache ANT, unzip them to the following locations:
note: The locations don’t need to match these, but it is best to put them in a similar location. If you used the SDK installer instead of the zip package, you might want to create a symbolic link to prevent issues with spaces in the path. Run cmd.exe as Admin:
cd\Development mklink /D android-sdk "C:\Program Files (x86)\Android\android-sdk"
3. Setup JDK
C:\Program Files\Java\jdk1.7.0_05\binto the PATH variable (if you are using a different version of the JDK, adjust the path accordingly)
- Set the JAVA_HOME system variable to the directory of your JDK installation:
4. Clone openFrameworks from Github
- Download openFrameworks (develop)
- I’ll be installing openFrameworks into:
git clone -b develop git://github.com/openframeworks/openFrameworks.git
5. Edit the paths.make file
paths.make.defaultin the folder
- Copy or rename it to paths.make
- Change the content to:
NDK_ROOT=C:/Development/android-ndk-r8b SDK_ROOT=C:/Development/android-sdk ANT_HOME=C:/Development/apache-ant-1.8.4 ANT_BIN=$(ANT_HOME)/bin/
If you use different versions, be sure to set the correct path!
6. Update the ofAndroidLib project
- Open up the commandline (start -> cmd.exe)
C:/Development/android-sdk/tools/android.bat update project --target android-8 --path C:\temp\OF\addons\ofxAndroid\ofAndroidLib
7. Open Eclipse
- Workspace location:
8. Set eclipse java compiler compliance to 1.5
- Window > Preferences > Java > Compiler
9. Set Android SDK Location **(optional)**
- Window > Preferences > Android
C:\Development\android-sdk(Or use the one in program files)
- It should list the Android 2.2 target, if not, use the Android SDK and AVD manager to install it.
Note: This step might not be required if your Android development environment is already set up.
10. Import openFrameworks into Eclipse
Import the following projects (existing projects option in the import dialog):
Note: You might want to turn off autobuild before adding these projects (Project > Build Automatically)
11. Switch to the C++ view
- Window > Open Perspective > Other > C++
- Select the openFrameworks project on the left
- Click the hammer icon (the triangle) to change the build target from Linux to Android
- Click the hammer icon to build the project (This might take a while to build).
When it is done, check the following location:
It should contain the following files:
Manage run configurations
- Select a project on the left (e.g. androidPolygonExample)
- Run > External Tools > External Tools Configuration
- The following dialog should now appear:
- Select program and press New, name the new configuration:
On the Main tab, use these settings:
- Working Directory:
On the Refresh tab, use these settings:
- Mark Refresh resources upon completion
- Select The selected resource
On the Build tab, use these settings:
- Mark Build before launch
- Select The project containing the selected resource
- Mark Include referenced projects
Press Apply and Close
Running an example
- Connect your device
- Make sure that the device is recognized. You can do this by typing “adb devices” in the commandline (terminal)
- Select an example on the left side
- Change the target to AndroidRelease
- Run > External Tools > Android Install
- Eclipse should start building the application and will transfer the apk file to your Android device (it will automatically launch the app).
- Question: I’m getting an error about pkg-config when I try to launch the app (but it works fine)
- Answer: http://www.mingw.org/wiki/FAQ
- “How do I get pkg-config installed? The difficulty in getting pkg-config installed is due its circular depency on glib. To install pkg-config, you should first install the GTK-runtime, the installer is found at www.gtk.org. The pkg-config binary can be obtained from pkg-config_0.23-3_win32.zip. Place pkg-config.exe in your MinGW bin directory.“
Awesome, thanks for this tutorial Laurence. Will try this today.
I tried this just now, everything works, except the App crashes on start. The error in the logs is an UnsatisfiedLinkError. So somehow the the resources for JNI seem not to be in the apk or something like that. Someone has a clue what the cause could be? Or what else should I check?
Not sure what is causing such error. Did you changed the project name?
Hey, thanks for posting this. I am a bit new to openframeworks and really excited to try it out. I am getting an error and was wondering if you might be able to help. When I am importing the projects I get this error - “make: *** No rule to make target ‘all’. Stop.” Thanks again.
Did that happen after you clicked the hammer icon and changed it to Android?
Thanks a lot for this tut. I made every step but get an error. Description Resource Path Location Type C:\msys\1.0\bin\make.exe: *** Couldn’t reserve space for cygwin’s heap, Win32 error 0 androidAssimpExample C/C++ Problem Can you tell me what I did wrong?
Do you have Cygwin installed as well?
I’m so grateful for this post! Thank you so much. You have made my life much easier. My version of eclipse seems to compile openFrameworks each time. Is there a setting I can change in the external tools configuration? I’ve tried unticking “include referenced projects” but that doesn’t help. Thank you so much again!
Glad to hear it has been a useful guide to you. It is indeed a bit annoying that it wants to compile OF every time you hit the build/install button. A way to speed things up (if you’re only working on the Java/UI side), is to modify the External Tools Configuration profile. Go to the External Tools Configuration window and choose the profile “Android Install”. On the “Refresh” tab untick “Refresh resources upon completion”, and on the “Build” tab, untick “Build before launch”. Whenever you click the play (Android Install) button to install your app, it won’t be compiling any C++ code but it will just use the one that has already been built. Just remember to click the Hammer icon if you modified any of the C++ code before clicking the green play button.
Cool thanks! Unfortunately I plan to do most of my app inside openFrameworks. Is there no way to edit a build.xml or variable to stop it doing so?
Hi, Actually you dont need to modify the build.xml (or anything from Eclipse). What you could try is to modify the Makefile of your project and the one that is in OF\libs\openFrameworksCompiled\project\android to make it stop doing this. Actually, the android OF libs (libopenFrameworks.a + arm7/neon/debug) are only build once, its just the check that is delaying your project build.
thanks for such a good tut on OF installation but i am running itno a problem i have done all that you have said so far but i am getting these two error
Description Resource Path Location Type make: ** [android] Error 2 openFrameworks C/C++ Problem Description Resource Path Location Type make: ** [../../lib/android/libopenFrameworksDebug.a] Error 127 openFrameworks C/C++ Problem please help ;)
Not sure what is going wrong in that stage, when do you get this error? When trying to compile one of the examples or only when building openFrameworks?
I’m getting a lot of weird errors: “** Build of configuration Android for project openFrameworks ** make android -C../openFrameworksCompiled/project/android /bin/sh: pkg-config: command not found /bin/sh: pkg-config: command not found FIND: Parameter format not correct File not found - *.cpp make: Entering directory
/d/Dev/ofdroid/libs/openFrameworksCompiled/project/android' make DebugAndroid FIND: Parameter format not correct File not found - *.cpp FIND: Parameter format not correct File not found - *.cpp FIND: Parameter format not correct File not found - *.cpp make: Entering directory/d/Dev/ofdroid/libs/openFrameworksCompiled/project/android’ echo “creating “ ../../lib/android/libopenFrameworksDebug.a creating ../../lib/android/libopenFrameworksDebug.a D:\Dev\android-ndk-r6b/toolchains/arm-linux-androideabi-4.4.3/prebuilt/windows/bin/arm-linux-androideabi-ar -r “../../lib/android/libopenFrameworksDebug.a” /bin/sh: D:Devandroid-ndk-r6b/toolchains/arm-linux-androideabi-4.4.3/prebuilt/windows/bin/arm-linux-androideabi-ar: No such file or directory make: Leaving directory
/d/Dev/ofdroid/libs/openFrameworksCompiled/project/android' make: *** [../../lib/android/libopenFrameworksDebug.a] Error 127 make: Leaving directory/d/Dev/ofdroid/libs/openFrameworksCompiled/project/android’ make: * [android] Error 2 ** Build Finished ** “
Thank you for the wonderful tutorial. After solving some issue following your guide I still unable to run any example. It seems the example complied ok but when installed in device or emulator its crashing. Here is my make log from console https://gist.github.com/2919907 I am using https://github.com/falcon4ever/openFrameworks with NDK6 (tried with 7 and 8 too). Any idea what can cause this problem? any suggestion will be really appreciated.
Thanks for your feedback, I’m not sure why it is failing for you but I will soon redo the patches for the official develop branch of openFrameworks (last time i tried ndk r6 worked…)
Man…… I feel like I’m ALMOST there. The ‘openFrameworks’ project in Eclipse is giving me this error:
make: *** [../../lib/android/armeabi/libopenFrameworksDebug.a] Error 127 openFrameworks line 0 C/C++ Problem ——————————————————– This seems to be the last hurdle before I can gloriously deploy to Android…. but what’s going on? How do I build libopenFrameworksDebug.a??
Did you followed all the instructions of the guide? I updated the guide this Sunday because I pushed a new branch (for compatibility with 0071) onto Github (develop-0071-android-r8b-mingw). It should work if you use the latest SDK/SDK Tools and NDK.
I had not followed your tutorial to the exact letter. I already had Java JRE1.7 and Ant 1.8.2 so figured I was fine. I downloaded JDK7 and Ant 1.8.4 and the .a files are being generated fine now. I did however have to clean > build all a number of times to get all necessary stuff generated (like the ‘gen’ folder in ofAndroidLib and the ofandroidlib.jar in ofAndroidLib/bin) but I can now finally generate an Android app and it’s being deployed to my device. I do however have instant crashes. This may be a stupid question, but if I’m running a Cyanogenmod 9 Android ICS (4.0.3), do I need to change the target to that, or should Android 2.2 be fine? Again, thanks for this tutorial! Superslim chance that I would’ve come this far otherwise.
It shouldn’t really matter that you use a custom rom, I’m running Cyanogenmod 7 myself. As long as you target Android 2.2 (target-8) it should be fine. I would check the DDMS/logcat to see what is going on when it crashes.
Thank you for the wonderful tutorial firstly. There are some issues “Project ‘XXX(ofAndroidLib…)’is missing required source folder:’gen’” when I import the addons\ofxAndroid\ofAndroidLib and examples\android . Any suggestion about it ?
When the “gen” directory is missing, I usually try to clean the project and do a full rebuild. It is suppose to be autogenerated by the ADT plugin but for some reason it fails some times. (Similar to the missing resource file R.*)
Finally got it to work :D THanks a lot . . . Some of the apps are running whereas some arent . .. any clue why?
Not sure Shantanu, if the examples are broken I recommend reporting them either on GitHub or on the official openFrameworks forums.
I got the same problem. Anyone can help me out? Thanks a lot for this tutorial.
Same problem here. Almost there, and i can’t quite figure out where to go from here.
Thank you for your great walkthrough Laurence! Anyone having problems, I know you’re eager to build but be sure to read through the last few parts as they clear up some issues you might have faced. I have added a couple of other solutions to things (‘FIND: parameter not correct’, makefile assuming you’re on linux with MinGW 6.2, etc.) to a post on the forum here: http://forum.openframeworks.cc/index.php/topic,8855.0.html Cheers! -Chris
Thanks for letting us know Chris, didn’t know Linux already had a newer version of MinGW.
@Veqtor: Seems like the path to your NDK install isn’t correct: D:Devandroid-ndk-r6b/toolchains/arm-linux-androideabi-4.4.3/prebuilt/windows/bin/arm-linux-androideabi-ar: No such file or directory @Anderw: I’d need more details to figure out why it isn’t working for you @Eva: Could you perhaps e-mail me your build log? It’s hard to guess why it isn’t working for you without it.
I finally solve this problem. This is because it use the windows default “find” command, so that the parameter will not work. Edit your PATH variable,and let “MinGW\msys\1.0\bin” have top priority . Just like “D:\MinGW\msys\1.0\bin;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;%SystemRoot%\system32;…….”. I am very happy now. Hope this tip can help you all.
Hi … When I try to build the openFrameworks project I get the following error ;- “Program “make” not found in PATH (C/C++ Problem)”. I have added the “C:\Development\android-sdk\tools” in the path of the environment variables. Please help.
Hey, thanks a lot for this tutorial! I have followed all the steps but still I cannot compile the OF library… I don’t get any error but it gets stuck somewhere while compiling… Here is the console output:
19:58:26 **** Build of configuration Android for project openFrameworks **** make -C ../openFrameworksCompiled/project/android -j4 -j2 android make: Entering directory `/c/openFrameworks/libs/openFrameworksCompiled/project/android' make DebugAndroid make: Entering directory `/c/openFrameworks/libs/openFrameworksCompiled/project/android' compiling object for ../../../openFrameworks/3d/of3dUtils.cpp mkdir -p obj/DebugAndroid/openFrameworks/3d [output removed] obj/DebugAndroid/openFrameworks/3d/ofCamera.o -c ../../../openFrameworks/3d/ofCamera.cpp In file included from ../../../openFrameworks/types/ofRectangle.h:14:0, from ../../../openFrameworks/graphics/ofGraphics.h:7, from ../../../openFrameworks/3d/of3dUtils.cpp:2: ../../../openFrameworks/utils/ofLog.h:150:15: note: the mangling of 'va_list' has changed in GCC 4.4 In file included from ../../../openFrameworks/types/ofRectangle.h:14:0, from ../../../openFrameworks/3d/ofCamera.h:20, from ../../../openFrameworks/3d/ofCamera.cpp:10: ../../../openFrameworks/utils/ofLog.h:150:15: note: the mangling of 'va_list' has changed in GCC 4.4 Eclipse also says: Build project 59%But it has been in 59% for hours. Any idea of how to solve this? Thank you again!
Hey Laurence, I tried your guide but no luck. I’m stuck when building. There is a person in openframeworks forum like me. Same output and same stuck at building. http://forum.openframeworks.cc/index.php/topic,11500.msg52766.html#msg52766 Do you know a solution for that? Thank you!
If oF build process stuck at “Build project (59%)”, this problem maybe fix by removing -j4 option at make. Edit this before import of_v0.7.4_android_release libs/openFrameworks/.cproject Line 62 <builder arguments="-C ../openFrameworksCompiled/project/android -j4" … to $ make -v >GNU Make 3.81 >This program built for i686-pc-msys
Oops, my comment of about several lines which contributed was not displayed. Line 62 arguments=”-C ../openFrameworksCompiled/project/android -j4” … to arguments=”-C ../openFrameworksCompiled/project/android “ … Windows 7 64bit SP1
You could also change it from the UI: http://forum.openframeworks.cc/index.php/topic,11500.msg53111.html#msg53111 I’m not sure why this is happening but it is def related to the latest MinGW/MSYS. If I use an older copy (laptop) of MinGW/MSYS, that -j4 switch works just fine.
Hello, I encouter a werid error : “openFrameworks/utils/ofConstants.h:172:21: fatal error: unistd.h: No such file or directory” I installed MinGW by following your tutorial. Do you have any idea of what’s my problem ? Thanks !
I followed the steps as well as I could. Once I get to the end and build the openFrameworks project I do not have the 4 files you say are created by building the project. When I continue, ignoring the missing files the project builds but when it tries to run it says the makefile does not support my operating system. HOST_OS=MINGW32_NT-6.1 HOST_ARCH=i686 ../../../libs/openFrameworksCompiled/project/makefileCommon/config.shared.mk:89: *** This makefile does not support your operating system MINGW32_NT-6.1. Stop. I haven’t been able to find anything that explains how to fix this.
Hi Thanks for the awesome tutorial. I have a problem with the external tool configuration: When I try to run it, eclipse says: This make file does not support your operating system. Any Idea?
Hey, thx a lot for your tutorial. Looking forward to using it to finally develop Android Apps. I’ve got a suggestion, though. I just spent three days trying to figure out why building oF stops without error - it was because of that “Use parallel build” checkbox. Seems I was too stupid to find the corresponding post in the oF forum and the one in the comments above. Maybe you could put that in the tutorial, I’m sure that would make life easier for people like me. ^^ Thx again, meht
Hi Meht, thanks for the suggestion. I’ll update the post. It’s still a weird bug though and I don’t know if Eclipse or MSys/MinGW is to blame.
Hi when I try to compile the openframeworks i get the following errors. Do yo have any idea of what could it be ?. 00:21:50 ** Incremental Build of configuration Android for project openFrameworks ** make -j4 -C ../openFrameworksCompiled/project PLATFORM_OS=Android all make: Entering directory
/d/of_android/libs/openFrameworksCompiled/project' Compiling ../../../libs/openFrameworks/3d/of3dPrimitives.cpp D:\android-ndk-r8d/toolchains/arm-linux-androideabi-4.8/prebuilt/windows/bin/arm-linux-androideabi-g++ -g3 -Wall -nostdlib --sysroot=D:\android-ndk-r8d/platforms/android-17/arch-arm/ -fno-short-enums -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -DANDROID -I"D:\android-ndk-r8d/platforms/android-17/arch-arm//usr/include/" -I"D:\android-ndk-r8d/sources/cxx-stl/gnu-libstdc++/include" -I"D:\android-ndk-r8d/sources/cxx-stl/gnu-libstdc++/4.8/include" -I"D:\android-ndk-r8d/sources/cxx-stl/gnu-libstdc++/libs/armeabi-v7a/include" -I"D:\android-ndk-r8d/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a/include" -I"D:\android-ndk-r8d/sources/crystax/include/" -I"../../../libs/glu/include_android" -I"../../../addons/ofxAndroid/src" -I../../../libs/FreeImage/include -I../../../libs/freetype/include -I../../../libs/freetype/include/freetype2 -I../../../libs/freetype/include/freetype2/freetype -I../../../libs/freetype/include/freetype2/freetype/config -I../../../libs/freetype/include/freetype2/freetype/internal -I../../../libs/freetype/include/freetype2/freetype/internal/services -I../../../libs/glfw/include -I../../../libs/glfw/include/GLFW -I../../../libs/openssl/include -I../../../libs/openssl/include/openssl -I../../../libs/poco/include -I../../../libs/tess2/include -I../../../libs/openFrameworks -I../../../libs/openFrameworks/3d -I../../../libs/openFrameworks/app -I../../../libs/openFrameworks/communication -I../../../libs/openFrameworks/events -I../../../libs/openFrameworks/gl -I../../../libs/openFrameworks/graphics -I../../../libs/openFrameworks/math -I../../../libs/openFrameworks/sound -I../../../libs/openFrameworks/types -I../../../libs/openFrameworks/utils -I../../../libs/openFrameworks/video -DDEBUG -MMD -MP -MF ../../../libs/openFrameworksCompiled/lib/android/obj/armv7/Debug/libs/openFrameworks/3d/of3dPrimitives.d -MT../../../libs/openFrameworksCompiled/lib/android/obj/armv7/Debug/libs/openFrameworks/3d/of3dPrimitives.o -o ../../../libs/openFrameworksCompiled/lib/android/obj/armv7/Debug/libs/openFrameworks/3d/of3dPrimitives.o -c ../../../libs/openFrameworks/3d/of3dPrimitives.cpp /bin/sh: D:android-ndk-r8d/toolchains/arm-linux-androideabi-4.8/prebuilt/windows/bin/arm-linux-androideabi-g++: No such file or directory Compiling ../../../libs/openFrameworks/3d/of3dUtils.cpp make: *** [../../../libs/openFrameworksCompiled/lib/android/obj/armv7/Debug/libs/openFrameworks/3d/of3dPrimitives.o] Error 127 make: *** Waiting for unfinished jobs.... D:\android-ndk-r8d/toolchains/arm-linux-androideabi-4.8/prebuilt/windows/bin/arm-linux-androideabi-g++ -g3 -Wall -nostdlib --sysroot=D:\android-ndk-r8d/platforms/android-17/arch-arm/ -fno-short-enums -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -DANDROID -I"D:\android-ndk-r8d/platforms/android-17/arch-arm//usr/include/" -I"D:\android-ndk-r8d/sources/cxx-stl/gnu-libstdc++/include" -I"D:\android-ndk-r8d/sources/cxx-stl/gnu-libstdc++/4.8/include" -I"D:\android-ndk-r8d/sources/cxx-stl/gnu-libstdc++/libs/armeabi-v7a/include" -I"D:\android-ndk-r8d/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a/include" -I"D:\android-ndk-r8d/sources/crystax/include/" -I"../../../libs/glu/include_android" -I"../../../addons/ofxAndroid/src" -I../../../libs/FreeImage/include -I../../../libs/freetype/include -I../../../libs/freetype/include/freetype2 -I../../../libs/freetype/include/freetype2/freetype -I../../../libs/freetype/include/freetype2/freetype/config -I../../../libs/freetype/include/freetype2/freetype/internal -I../../../libs/freetype/include/freetype2/freetype/internal/services -I../../../libs/glfw/include -I../../../libs/glfw/include/GLFW -I../../../libs/openssl/include -I../../../libs/openssl/include/openssl -I../../../libs/poco/include -I../../../libs/tess2/include -I../../../libs/openFrameworks -I../../../libs/openFrameworks/3d -I../../../libs/openFrameworks/app -I../../../libs/openFrameworks/communication -I../../../libs/openFrameworks/events -I../../../libs/openFrameworks/gl -I../../../libs/openFrameworks/graphics -I../../../libs/openFrameworks/math -I../../../libs/openFrameworks/sound -I../../../libs/openFrameworks/types -I../../../libs/openFrameworks/utils -I../../../libs/openFrameworks/video -DDEBUG -MMD -MP -MF ../../../libs/openFrameworksCompiled/lib/android/obj/armv7/Debug/libs/openFrameworks/3d/of3dUtils.d -MT../../../libs/openFrameworksCompiled/lib/android/obj/armv7/Debug/libs/openFrameworks/3d/of3dUtils.o -o ../../../libs/openFrameworksCompiled/lib/android/obj/armv7/Debug/libs/openFrameworks/3d/of3dUtils.o -c ../../../libs/openFrameworks/3d/of3dUtils.cpp /bin/sh: D:android-ndk-r8d/toolchains/arm-linux-androideabi-4.8/prebuilt/windows/bin/arm-linux-androideabi-g++: No such file or directory make: *** [../../../libs/openFrameworksCompiled/lib/android/obj/armv7/Debug/libs/openFrameworks/3d/of3dUtils.o] Error 127 make: *** wait: No children. Stop. make: *** [Debug] Error 2 make: *** [all] Error 2 make: Leaving directory/d/of_android/libs/openFrameworksCompiled/project’ 00:23:27 Build Finished (took 1m:37s.300ms)
hey dose it work for Serial IO Communication With Hardware Device ? write and read char from Hardware to android ?
Not sure, you should probably ask on the OF forums as there are more experts that have used Serial IO. (I haven’t used that part on Android)