User Tools

Site Tools


en:tutorials:setup_android
 This guide is based on Android 1.2.1.1 and NDK version r10e.
 The Android builds require GCC 4.9 which is in NDK r10e.

Compiling Orx and the Android Demo Project

To follow this guide, you must first ensure you have completed the Getting Android Studio and Orx step. repository step.

1. Compile orx

 cd <DEV_FOLDER>/orx/code/build/android
 ndk-build
 ./install.sh
 
 For windows, use install.bat instead.
 

Notes about ndk-build: what's it for?

Notes about ndk-build: what's it for?


ndk-build compiles all of the orx c source code and links them into usable libraries. It compiles three versions: debug, profile and release. And compiles these three for two CPU types: ARM and x86. The install batch copies the compiled libraries from the obj folder into the orx\code\lib\static\android folder ready for use by the demo project, or your own projects.


2. Compile orxTest sample

 cd <DEV_FOLDER>/orx/code/demo/android/app/src
 export NDK_MODULE_PATH=<DEV_FOLDER>/orx/code
 ndk-build
 
 For windows, substitute the export command above as:
 set NDK_MODULE_PATH=<DEV_FOLDER>\orx\code

3. Import Orx Library project into Android Studio.

The purpose of this step is to optionally create an updated version of the Orx Library to be used by Demo Project, or your own project.

  1. Load Android Studio 
  2. Choose "Import project (Eclipse ADT, Gradle, etc)"
  3. Browse to <DEV_FOLDER>/orx/extern/android

Errors and Troubleshooting

Errors and Troubleshooting


 1. Android Studio may complain that the demo project is set to Gradle 0.14.0 in the build.gradle file. 
 Android Studio 1.2.1.1 doesn't like this old version and will ask if you want it to update this for you. Click "Fix plug-in version and sync project". 
 2. It may also complain about "Error:(16, 0) Gradle DSL method not found: 'runProguard()'"
 
 If so, change the line in <DEV_FOLDER>/orx/extern/android/orx-lib/build.gradle
 
 From:
 runProguard false
 
 to:
 minifyEnabled false
 3. You could receive an error: 
 
 Error: Library projects cannot set applicationId. applicationId is set to 'org.orx.lib' in default config.
 
 If so, remove the line:
 applicationId "org.orxproject.orxtest"
 4. If you only receive a debug build, and no release build, there is an excellent workaround detailed here: http://stackoverflow.com/questions/27646262/how-to-create-a-release-android-library-package-aar-in-android-studio-not-deb

For any fix, close project. Reopen project.


If no issues, the library will build automatically and can be found at: <DEV_FOLDER>/orx/extern/android/orx-lib/build/outputs/aar

A precompiled orx-lib is included with the Demo Project. However, you can always take this one above you compiled yourself, and copy it over the existing one in the demo project at: <DEV_FOLDER>/orx/code/demo/android/app/aars

4. Import the Demo Project into Android Studio

 Click "Import an existing project" with Android Studio
 Browse to <DEV_FOLDER>/orx/code/demo/android

Errors and Troubleshooting

Errors and Troubleshooting


 1. Android Studio may complain that the demo project is set to Gradle 0.14.0 in the build.gradle file. 
 Android Studio 1.2.1.1 doesn't like this old version and will ask if you want it to update this for you. Click "Fix plug-in version and sync project". 
 2. It may also complain about "Error:(16, 0) Gradle DSL method not found: 'runProguard()'"
 
 If so, change the line in <DEV_FOLDER>/orx/code/demo/android/app/build.gradle
 
 From:
 runProguard false
 
 to:
 minifyEnabled false

For any fix, close project. Reopen project.


After a successful project load, it will build files automatically at: <DEV_FOLDER>/orx/code/demo/android/app/build

Then finally, turn those files into a working APK by selecting Run App. Cancel any Emulator window that opens. An APK or two will be generated at: <DEV_FOLDER>/orx/code/demo/android/app/build/outputs/apk

Now you can copy this APK to your Android device and run the demo.

Tips for SDK errors

Tips for SDK errors

 If you receive the following error:
   * [OrxTest] Unable to resolve target 'android-19'
 
 You don't have the required android SDK (API 19) that the orx Demo is set to. Use the SDK Manager (Tools/Android/SDK Manager) to check and download API 19.

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/setup_android.txt · Last modified: 2018/02/14 04:46 (5 months ago) by iarwain