Notes
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.
* update October 2011 *
Instead of patching the files manually, you can now do a checkout from: https://github.com/falcon4ever/openFrameworks (Make sure you select the Development Branch)
After downloading the source code, you can skip step 4, 5 and 6.
Last update: 26-10-2011
Requirements
- Eclipse (with CDT plugin)
- Installed JDK (Java SE 6 Update 26) – I recommend downloading the x86 version. Please note that Java SE 7 won’t work.
- Android SDK
- Installed ADT Plugin for Eclipse
- Android NDK (this tutorial uses r6)
- Apache ANT
Quick fix
If you don’t want to patch every file manually, you can just unzip this file in your to the directory in which you’ve placed OF (e.g. C:\temp): openFrameworks Makefiles for windows (149)
I do recommend checking the steps below in order to setup your programming environment. Of course you can skip the parts where I tell you to replace certain parts in the Makefiles. If you’ve installed the SDK, NDK or ANT in a different folder, you will need to edit the file paths.make.
Setup environment
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:
C:\Development\android-ndk-r6C:\Development\android-sdkC:\Development\apache-ant-1.8.2
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
- Add
C:\Program Files (x86)\Java\jdk1.6.0_26\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. Download openFrameworks from Github
- Download the latest zippackage: openFrameworks GIT *
- Unzip the content to
C:\temp\OF\
*don’t use the 007 package from the download page, it is missing some files which will prevent you from importing the projects into Eclipse.
5. Edit the paths.make file
Use a text editor to open up this file:
C:\temp\OF\libs\openFrameworksCompiled\project\android\paths.make
Change the content to:
NDK_ROOT=C:/Development/android-ndk-r6 SDK_ROOT=C:/Development/android-sdk ANT_HOME=C:/Development/apache-ant-1.8.2 ANT_BIN=$(ANT_HOME)/bin/
If you use different versions, be sure to set the correct path!
5. Fixing the openFrameworks Makefile
Use a text editor to open up this file:
C:\temp\OF\libs\openFrameworksCompiled\project\android\makefile
Since the current Makefile does not check if the platform is Windows, we slightly modify the if else statement.
Find this:
ifeq ($(findstring Android,$(MAKECMDGOALS)),Android) include paths.make ARCH = android ifeq ($(shell uname),Darwin) HOST_PLATFORM = darwin-x86 else HOST_PLATFORM = linux-x86 endif endif
Replace with this:
ifeq ($(findstring Android,$(MAKECMDGOALS)),Android) include paths.make ARCH = android ifeq ($(shell uname),Darwin) HOST_PLATFORM = darwin-x86 else ifeq ($(shell uname),MINGW32_NT-6.1) HOST_PLATFORM = windows else HOST_PLATFORM = linux-x86 endif endif
6. Fixing makefiles of the example projects
In the previous step we only fixed the makefile for the openFrameworks library. We will also need to apply the same fix to all of the example projects.
Open up these files:
- C:\temp\OF\apps\androidExamples\androidAssimpExample\Makefile
- C:\temp\OF\apps\androidExamples\androidAudioExample\Makefile
- C:\temp\OF\apps\androidExamples\androidCameraExample\Makefile
- C:\temp\OF\apps\androidExamples\androidEmptyExample\Makefile
- C:\temp\OF\apps\androidExamples\androidFontExample\Makefile
- C:\temp\OF\apps\androidExamples\androidImageExample\Makefile
- C:\temp\OF\apps\androidExamples\androidOpenCVExample\Makefile
- C:\temp\OF\apps\androidExamples\androidPolygonExample\Makefile
- C:\temp\OF\apps\androidExamples\androidTouchExample\Makefile
- C:\temp\OF\apps\androidExamples\androidVBOExample\Makefile
Find this:
ifeq ($(findstring Android,$(MAKECMDGOALS)),Android) include $(OF_ROOT)/libs/openFrameworksCompiled/project/android/paths.make ARCH = android ifeq ($(shell uname),Darwin) HOST_PLATFORM = darwin-x86 else HOST_PLATFORM = linux-x86 endif endif
Replace with this:
ifeq ($(findstring Android,$(MAKECMDGOALS)),Android) include $(OF_ROOT)/libs/openFrameworksCompiled/project/android/paths.make ARCH = android ifeq ($(shell uname),Darwin) HOST_PLATFORM = darwin-x86 else ifeq ($(shell uname),MINGW32_NT-6.1) HOST_PLATFORM = windows else HOST_PLATFORM = linux-x86 endif endif
In addition to the fix above, we will need to add another fix:
Find this (Section AndroidInstall, somewhere at the bottom of the file):
$(SDK_ROOT)/tools/android update project --target $(NDK_PLATFORM) --path $(PROJECT_PATH) ant debug
Replace with this:
if [ "$(shell uname)" = "MINGW32_NT-6.1" ]; then \ cmd //c $(SDK_ROOT)/tools/android.bat update project --target $(NDK_PLATFORM) --path $(PROJECT_PATH); \ $(ANT_BIN)/ant debug; \ else \ $(SDK_ROOT)/tools/android update project --target $(NDK_PLATFORM) --path $(PROJECT_PATH); \ ant debug; \ fi
The Makefiles should be working on all supported platforms.
7. Open Eclipse
- Workspace location:
C:\temp\OF\apps\androidExamples
8. Set eclipse java compiler compliance to 1.5
- Window > Preferences > Java > Compiler
9. Set Android SDK Location
- Window > Preferences > Android
- Enter:
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.
10. Import openFrameworks into Eclipse
Import the following projects (existing projects option in the import dialog):
C:\temp\OF\libsC:\temp\OF\libs\openFrameworksC:\temp\OF\addons\ofxAndroid\ofAndroidLibC:\temp\OF\apps\androidExamples
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).
C:\temp\OF\libs\openFrameworksCompiled\lib\androidIt should contain the following files:
- libopenFrameworks.a
- libopenFrameworksDebug.a
- libopenFrameworks_arm7.a
- libopenFrameworks_neon.a
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: Android Install
- Location:
C:\msys\1.0\bin\make.exe(or C:\MinGW\msys\1.0\bin\make.exe when using the new MinGW installer) - Working Directory:
${project_loc} - Arguments:
AndroidInstall PROJECT_PATH=/c/temp/OF/apps/androidExamples/${project_name}
- Mark Refresh resources upon completion
- Select The selected resource
- 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)
(C:\Development\android-sdk-windows\platform-tools>C:\Development\android-sdk-windows\platform-tools\adb.exe devices) - 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).
- Done!
- 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 http://www.gtk.org/download/win32.php. The pkg-config binary can be obtained from pkg-config_0.23-3_win32.zip. Place pkg-config.exe in your MinGW bin directory.“
Hints
Depending on your SDK version, you might need to update the project files:
C:\Development\android-sdk\tools\android.bat update project --target android-8 --path C:\temp\OF\addons\ofxAndroid\ofAndroidLib C:\Development\android-sdk\tools\android.bat update project --target android-8 --path C:\temp\OF\apps\androidExamples\androidAssimpExample C:\Development\android-sdk\tools\android.bat update project --target android-8 --path C:\temp\OF\apps\androidExamples\androidAudioExample C:\Development\android-sdk\tools\android.bat update project --target android-8 --path C:\temp\OF\apps\androidExamples\androidCameraExample C:\Development\android-sdk\tools\android.bat update project --target android-8 --path C:\temp\OF\apps\androidExamples\androidEmptyExample C:\Development\android-sdk\tools\android.bat update project --target android-8 --path C:\temp\OF\apps\androidExamples\androidFontExample C:\Development\android-sdk\tools\android.bat update project --target android-8 --path C:\temp\OF\apps\androidExamples\androidImageExample C:\Development\android-sdk\tools\android.bat update project --target android-8 --path C:\temp\OF\apps\androidExamples\androidOpenCVExample C:\Development\android-sdk\tools\android.bat update project --target android-8 --path C:\temp\OF\apps\androidExamples\androidPolygonExample C:\Development\android-sdk\tools\android.bat update project --target android-8 --path C:\temp\OF\apps\androidExamples\androidSoundPlayerExample C:\Development\android-sdk\tools\android.bat update project --target android-8 --path C:\temp\OF\apps\androidExamples\androidTouchExample C:\Development\android-sdk\tools\android.bat update project --target android-8 --path C:\temp\OF\apps\androidExamples\androidVBOExample
There might be some issues when using NDK r7, if it fails building or linking (e.g. if Logcat says UnsatisfiedLinkError), try using the previous NDK (r6b): android-ndk-r6b-windows.zip



Awesome, thanks for this tutorial Laurence. Will try this today.
12 Aug 2011 |
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?
22 Sep 2011 |
Not sure what is causing such error. Did you changed the project name?
12 Oct 2011 |
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.
27 Nov 2011 |
Did that happen after you clicked the hammer icon and changed it to Android?
02 Dec 2011 |
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?
13 Dec 2011 |
Do you have Cygwin installed as well?
15 Dec 2011 |