Skip to content

Overview

Tommy Brosman edited this page Apr 7, 2019 · 6 revisions

This is an overview of everything I've encountered so far attempting to get a (Haxe) Heaps app built/running on Android.

Summary

  • Clone the "shell" app.
  • Build your Heaps app targeting HashLink with C output and copy the generated C source into the app subdirectory of the shell app (e.g. /out).

From here, there are two possibilities depending on whether you are building /out or the /heaps-android-app sub-module. heaps-android-app is a native library with a single function and a wrapper Java Activity that loads it. This is basically a mock of what you would see in a real Heaps app (where in a real app the native library would contain your compiled Heaps code).

Building /out (not working in Android Studio yet):

  • From Android Studio, open the top-level folder (heaps-android). This contains a CMakeLists.txt targeting sources in /out. Make the project (Build -> Make Project).

Building /heaps-android-app:

  • From Android Studio, open /heaps-android-app. This contains a CMakeLists.txt that pulls in dependencies from the top-level directory. Make the project (Build -> Make Project).

Steps

Cloning the Shell App

To clone my branch and all the submodules:

git clone --recurse-submodules https://github.com/tbrosman/heaps-android/ heaps-android --branch heaps-android-app-2

Targeting C

(See https://heaps.io/documentation/hello-hashlink.html for the most up-to-date documentation.)

If you are building for HashLink, your build probably looks something like this:

-cp src
-D resourcesPath=res
-lib heaps
-lib hlsdl
-main pong.PongApp
-hl bin/pong_app.hl

To generate C code instead of HashLink bytecode, change the suffix of your output file and add hashlink as a lib dependency:

-cp src
-D resourcesPath=res
-lib hashlink
-lib heaps
-lib hlsdl
-main pong.PongApp
-hl bin/pong_app/c/main.c

Copy the contents of bin/pong_app/c to the /out directory in the shell app.

Building with Android Studio

(Note: As-is, it is not possible to build the /out directory without either running CMake directly or putting in the necessary gradle plumbing to do the native build. The instructions below are sufficient to build @rtissera's heaps-android-app sub-module. See https://github.com/tbrosman/heaps-android/issues/2)

  • Open the heaps-android directory with Android Studio.
  • Make sure you have an up-to-date NDK (see the section on Tool Versions). Android Studio should prompt you to install an up-to-date SDK if it is missing.
  • Build -> Make Project

Known Working Tool Versions

(Note: The following set of tools/libraries builds, but the app crashes at startup. See https://github.com/tbrosman/heaps-android/issues/1)

  • Android Studio 3.3.1 (on Windows)
  • NDK 19.2.5345600
  • gradle 3.2.0
  • CMake 3.10.2.4988404

References

Clone this wiki locally