Beginners Tutorial : From Introjucer to APK using Windows

It took me a little while to figure this out, so I thought I’d share.

You’ll need:

Once you have everything installed:

  • Run ADT’s SDK Manager to install the Android API for your device and the Google USB driver
  • Make sure that all environment variables are set for everything (ANDROID_HOME, ANDROID_NDK_ROOT, ANT_HOME, JAVA_HOME, and PATH to ndk-build)
  • Run Introjucer, choose a project name, then a target folder, and choose “create a main.cpp file and a basic window”
  • Click “Add a new exporter”, choose “Create a new Android Project”
  • Don’t change any settings and click File->Save Project
  • Start a console (cmd), go into your project folder, then into “Builds/Android”
  • from there, start ndk-build (it should run if you set the PATH correctly)
  • if for some reason ndk-build give you some compiling errors, check all the include paths, and make sure you delete all .o and .so files before compiling again (to do this you can type “del *.o *.so /q /f /s”)
  • Once it’s built with NDK, launch ADT
  • in ADT, click File->Import->Android->Existing Android Code Into Workspace
  • As a root directly, choose “yourprojectfolder/Builds/Android”, and click Finish
  • Now make sure your Android device is plugged in (and unlocked, if needed), and click Run

I hope this helps :slight_smile: and don’t blame me if it doesn’t!

(Note: I you have troubles compiling with NDK you should try disabling some Juce modules before saving the project in Introjucer)

Cool, thanks for posting!

Thanks for the post shini - really helpful. Some other gotchas I encountered on the way (disclaimer: from a total beginner also, there may be ways to totally avoid these problems):

If you don’t install both SDK and NDK into ${user.home}/SDKs you’ll need to edit Builds/Android/local.properties to point at your installation directories.

As has been mentioned in other posts on Windows you need to edit the generated Builds/Android/build.xml to read executable="${ndk.dir}/ndk-build.cmd" in both places to avoid the “not a runnable Win32” program error.

If you don’t download all API versions of the Android SDK you may encounter “unable to resolve target ‘android-8’”. I’d only downloaded the 4.2.2 SDK (API 17) so had to amend project.properties to read “target=android-17”. (FWIW I also amended AndroidManifest.xml thus, but don’t (yet) know whether it’s correct or important: )

Finally, to fix the error: “Error: No resource found that matches the given name (at ‘icon’ with value ‘@drawable/icon’).” change AndroidManifest.xml to remove the reference to android:icon="@drawable/icon".

Hi all,

I’m having trouble with the ndk build on Windows for the Juce Demo. I can build the .apk from the Introjucer, and have a successful ndk build, from a blank basic window project. However for the Juce Demo, the compiler is unable to find some header files included in other header files.

I’ve tried deactivating some plugins as mentioned above but usually this resulted in the project not building due to missing objects. I’ve also not found any .so or .o files that I must delete. I’ve checked the paths specified in the error console and in all cases the files are actually there. shini mentions to ‘check all include paths’ and at the end of the forum topic Juce Demo Android build errors on Windows someone else asks about ‘the juce include paths being too long’. I feel this could be my problem but I don’t know what it is I need to fix. Is there anyone that may have built the Juce Demo .apk on Windows or who could offer any guidance?

[EDIT]
I have figured out the includes paths problem, but there must be an easier way of resolving it than moving all header files and changing the include paths in each of them? Just finished doing this in the juce_graphics folder and can’t go on… For anyone else, includes resulting in the error mentioned above need to be shortened to just “juce_Justification.h” and then one must place that header file in same location as the file that includes it. For the juce_graphics folder at JuceDemo\JuceLibraryCode\modules\juce_graphics it was best to just take everything out of the subfolders and place directly into the juce_graphics folder, then open every header file and cut the paths down. Can anyone offer a more convenient way of doing this before I go on editing the entire Juce Library code?