User Tools

Site Tools


en:tutorials:setup_android

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
en:tutorials:setup_android [2019/02/11 12:28 (14 months ago)]
sausage
en:tutorials:setup_android [2019/03/04 01:57 (13 months ago)]
sausage
Line 1: Line 1:
    This guide is based on Android Studio 3.1.3 and NDK version r17b.    This guide is based on Android Studio 3.1.3 and NDK version r17b.
  
-====== Compiling Orx and the Android Demo Project ======+====== Compiling ​the Orx Library ​and the Android Demo Project ======
  
 To follow this guide, you must first ensure you have completed the [[:​getting_android_tools_and_orx|Getting Android Studio, NDK and Orx]] step. To follow this guide, you must first ensure you have completed the [[:​getting_android_tools_and_orx|Getting Android Studio, NDK and Orx]] step.
  
 +<WRAP center round box 90%>
 +To decide on which Android port to use, see: [[en:​tutorials:​which_android|Which Android Port should you use?]]
 +</​WRAP>​
  
-**1. Compile orx**+ 
 +**1. Compiling the Orx library for Android**
  
    cd <​DEV_FOLDER>/​orx/​code/​build/​android    cd <​DEV_FOLDER>/​orx/​code/​build/​android
Line 14: Line 18:
    For windows, use install.bat instead.    For windows, use install.bat instead.
        
-<hidden Notes about ndk-build: what'​s ​it for?>\\ +<hidden Notes about ndk-build: what'​s ​going on here?>\\ 
-ndk-build ​compiles ​all of the orx c source code and links them into usable libraries. It compiles three Orx library configurations:​ Debug, Profile and Release. And compiles these four [[https://​developer.android.com/​ndk/​guides/​abis|ABIs]],​ ''​arm64-v8a''​''​arm64-v8a''​''​x86'' ​and ''​x86_64''​ for differing CPU types+ndk-build ​will compile for all four cpu architectures (arm64-v8a, arm64-v8a, x86 and x86_64) into android/​obj/​local
-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.</​hidden>​\\+ 
 +Each folder will contain the three versions of the Orx static library: liborx.a, liborxd.a and liborxp.a (release, debug and profile). 
 + 
 +There is an install.bat (for windows) and install.sh (for mac and linux) to copy the libraries into place in the orx project structure at: orx/code/lib/static 
 + 
 +Holding the android ​versions of the Orx libraries at this location will make things more convenient when building ​your own projects. 
 + 
 +A good guide to ndk-build can be found at: https://​developer.android.com/​ndk/​guides/​ndk-build</​hidden>​\\
  
        
  
-**2. Compile orxTest sample**+**2. Compiling the Android Demo Native Code** 
 + 
 +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    cd <​DEV_FOLDER>/​orx/​code/​demo/​android/​app/​src/​main
-   ​export NDK_MODULE_PATH=<​DEV_FOLDER>/​orx/​code 
    ​ndk-build    ​ndk-build
-    
-   For windows, substitute the export command above as: 
-   set NDK_MODULE_PATH=<​DEV_FOLDER>​\orx\code 
  
-**3Import Orx Library project into Android Studio.**+This step creates the native library for the demo.
  
-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.+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.
  
-    1. Load Android Studio ​ +That's what Android Studio (and Gradle: it's build systemare used for.
-    2. Choose "​Import project ​(Eclipse ADT, Gradle, etc)+
-    3Browse to <​DEV_FOLDER>/​orx/​extern/​android+
  
-<hidden 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 applicationIdapplicationId is set to '​org.orx.lib' ​in default config. +**3Building the Android Demo in Android Studio**
-    +
-   If so, remove the line: +
-   ​applicationId "​org.orxproject.orxtest"​+
  
-   4. If you only receive a debug buildand 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+Now that we have the shard library of the demowe need to build it in Android StudioWhat 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.
  
 +  - Open Android Studio
 +  - Load in the demo by selecting the orx/​code/​demo/​android folder.
 +  - Gradle inside Android Studio will begin building automatically.
 +  - If there are no setup issues, the build will complete.
 +  - You can test the build on a real Android device or the emulator by selecting the Run / Run '​app'​ menu.
 +  - When running this step, an APK file be created and deployed to your device.
  
-For any fix, close project. Reopen project.+You can also create an APK at any time and copy this to your Android device as well. 
 +\\
  
-</​hidden>​\\+===== General Troubleshooting =====
  
- +**Tip:** If you receive the following error: 
 +//[OrxTest] Unable to resolve target '​android-19'//​
  
-  
-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 +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 SDKIn the build.gradle, you can also set the SDK you want to targetThis is an excellent resource to [[https://​developer.android.com/​guide/​topics/​manifest/​uses-sdk-element|help you choose]].
-   ​Browse to <​DEV_FOLDER>/​orx/​code/​demo/​android +
-  +
-  +
-<hidden 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 youClick "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. 
  
-</hidden>​\\+**Tip:** 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
  
-After a successful ​project ​load, it will build files automatically at: <​DEV_FOLDER>/​orx/​code/​demo/​android/​app/​build +**Tip:** Android NDK: Could not find application ​project ​directory ! 
-  +Android NDK: Please define the NDK_PROJECT_PATH variable to point to it.
-Then finally, turn those files into a working APK by selecting Run AppCancel 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. +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.
-    +
-<​hidden ​ 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.+
  
-</​hidden>​ 
  
  
 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|Using the Android demo as a template for your own projects]]. 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|Using the Android demo as a template for your own projects]].
        
en/tutorials/setup_android.txt · Last modified: 2020/03/29 11:26 (4 days ago) by sausage