User Tools

Site Tools


This guide is based on Android Studio Electric Eel (which ships with SDK 33) and NDK version 23.2.8568313. If you need to set up a development environment for Android, you must first ensure you have completed the Getting Android Studio, NDK and Orx step first.

Setting up the NDK version inside the Orx library Project

You need to specify what version of NDK you have. Version 23.2.8568313 is the required version.

Confirm your version by visiting your drive at: Locate NDK version at C:\Users\YOU\AppData\Local\Android\Sdk\ndk

Add this version to your orx\code\build\android\orx\build.gradle file, as line 9, for example:

ndkVersion "23.2.8568313"

Compiling the Orx Library and the Android Demo Project

1. Compiling the Orx library for Android

 cd orx/code/build/android

For Linux or Mac use instead.

The compiled libraries will be located under orx\code\build\android\orx\build\outputs\aar

  1. orx-debug.aar
  2. orx-profile.aar
  3. orx-release.aar

2. Compiling the Android Demo Native Code

This section is still in the process of being re-written.

Let's compile the native code portion of the Demo which links in the static Orx library that we prepared in step 1:

 cd <DEV_FOLDER>/orx/code/demo/android/app/src/main/jni

This step creates the native library for the demo.

Creating a native library is only half the story, and will provide only a shared library (.so). This library and assets still need to be packaged for use on a device.

That's what Android Studio (and Gradle: it's build system) are used for.

3. Building the Android Demo in Android Studio

Now that we have the shared library of the demo, we need to build it in Android Studio. What really happens at the step?

Android Studio (using Gradle) will take the shared library and wrap some java code around it so that the application can be executed. Everything will be packaged up.

  1. Open Android Studio
  2. Load in the demo by selecting the orx/code/demo/android folder.
  3. Gradle inside Android Studio will begin building automatically.
  4. If there are no setup issues, the build will complete.
  5. You can test the build on a real Android device or the emulator by selecting the Run / Run 'app' menu.
  6. When running this step, an APK file be created and deployed to your device.

You can also create an APK at any time and copy this to your Android device as well.

General Troubleshooting

Tip: If you receive the following error: [OrxTest] Unable to resolve target 'android-19'

You don't have the minimum required android SDK (API 19) that the orx Demo is set to. Use the SDK Manager (Tools/Android/SDK Manager) to check and download the latest SDK. In the build.gradle, you can also set the SDK you want to target. This is an excellent resource to help you choose.

Tip: If you only receive a debug build, and no release build, there is an excellent workaround detailed here:

Tip: Android NDK: Could not find application project directory ! Android NDK: Please define the NDK_PROJECT_PATH variable to point to it.

If you get this when running ndk-build, then you are not in the correct folder. Check the instructions to ensure you are at the correct path. There should be a jni folder present. ndk-build operates on the contents of a jni folder.

If you have completed this tutorial and would like to try it with your own project, continue to Using the Android demo as a template for your own projects.

en/tutorials/android/setup_android.txt · Last modified: 2023/03/19 03:23 (6 days ago) by sausage