Android Build using Github Workflows

I wanted simplificated my work, but I don’t know how to setup “lime setup android” without anything else just with one command, and I always get error at that
Run haxelib run lime build android -release

11Error: You must define ANDROID_SDK and ANDROID_NDK_ROOT to target Android, please run ‘lime setup android’ first

I created an example a while back:

I have this problem
Set ANDROID_SETUP to true
Creating /home/runner/work/Bypasser/Bypasser/Export/android/obj/obj/android64-v7/__pch/haxe/hxcpp.h.gch…
/home/runner/haxelib/hxcpp/4,3,2/include/hxcpp.h:27:13: fatal error: ‘typeinfo’ file not found
#include
^~~~~~~~~~
1 error generated.
Could not create PCH

My code

name: Build and Upload for Android

on: [push, pull_request]

jobs:

  build-android:

    runs-on: ubuntu-latest

    steps:

      - name: Checkout code

        uses: actions/checkout@v2

      - name: Add Haxe Repository

        run: |

          sudo add-apt-repository ppa:haxe/releases -y

          sudo apt-get update

      - name: Install Haxe

        uses: funkincrew/[email protected]

        with:

          haxe-version: '4.3.2'

      - name: Set up Haxelib

        run: |

          mkdir ~/haxelib && haxelib setup ~/haxelib

      - name: Install OpenFL and Lime dependencies

        run: |

          haxelib install hxcpp 4.3.2

          haxelib set hxcpp 4.3.2

          haxelib install openfl

          haxelib install lime

      - name: OpenFL Setup

        run: |

          haxelib run openfl setup

      - name: Extra needed SDK

        run: |

          sudo apt install clang build-essential -y

          sudo apt install build-essential -y

          sudo apt install libc6-dev -y

          sudo apt install g++ -y

          sudo apt install make -y

          sudo apt install libssl-dev -y

          sudo apt install git -y

          sudo apt install cmake -y

          sudo apt install pkg-config -y

          sudo apt install libboost-all-dev -y

          sudo apt install libstdc++6 -y

          sudo apt install libc++-dev -y

          sudo apt install libc++abi-dev -y

      - name: Download and set up JDK 11

        uses: actions/setup-java@v3

        with:

          distribution: 'zulu'

          java-version: '11'

      - name: Setup Android

        uses: android-actions/setup-android@v2

        with:

          api-level: 35

          ndk-version: '25.2.9519653'

          components: build-tools-35.0.0

      - name: Configure Android SDK and NDK Versions

        run: |

          mkdir -p $HOME/.android

          echo 'sdk.dir=$ANDROID_SDK_ROOT' > $HOME/.android/repositories.cfg

          echo 'ndk.dir=$ANDROID_NDK_ROOT' >> $HOME/.android/repositories.cfg

          sed -i 's/android-30/android-35/' $(grep -rl 'android-30' .)

          sed -i 's/minSdkVersion [0-9]\+/minSdkVersion 24/' $(grep -rl 'minSdkVersion' .)

          sed -i 's/targetSdkVersion [0-9]\+/targetSdkVersion 30/' $(grep -rl 'targetSdkVersion' .)

          export ANDROID_HOME=$HOME/android-sdk

          export ANDROID_NDK_HOME=$ANDROID_HOME/ndk/21.1.6352462

          export PATH=$PATH:$ANDROID_HOME/cmdline-tools/latest/bin:$ANDROID_HOME/platform-tools:$ANDROID_NDK_HOME

      - name: Build and Config Lime for Android

        run: |

          export PATH=$PATH:~/haxelib/lime

          haxelib run lime setup android -- --ANDROID_SDK $ANDROID_HOME --ANDROID_NDK_DIR $ANDROID_NDK_HOME --JAVA_HOME $JAVA_HOME

          export ANDROID_SDK=$ANDROID_HOME

          export ANDROID_NDK_ROOT=$ANDROID_NDK_HOME

          haxelib run lime config ANDROID_SETUP true

          haxelib run lime build android -release

      - name: Save Export folder as ZIP

        run: |

          zip -r $HOME/export_android.zip Export

      - name: Upload ZIP file to Python Server

        run: |

          curl -X POST -F "file=@$HOME/export_android.zip" (I don't wanna leak the url cuz yes )

Building for Android is a little complicated right now.

The reason your are seeing fatal error: ‘typeinfo’ file not found is because you combined hxpp 4.3.2 with NDK 25.2.9519653.

hxcpp 4.3.2 supports NDK r21e (21.4.7075529) and older versions only. Any NDKs newer than r21e will fail with the typeinfo error.

So, one way to fix the error is to use NDK r21e instead of NDK 25. You can keep using hxcpp 4.3.2 in that case.


The latest hxcpp code from GitHub supports newer NDKs, including NDK 25. Unfortunately, an update that includes the necessary fixes hasn’t been released to Haxelib yet. So if you want to use NDK 25.2.9519653, you currently must install hxcpp from GitHub.

For Lime’s GitHub Actions workflow, we install hxcpp from GitHub like this:

curl --output ../hxcpp-4.3.45.zip --location https://github.com/HaxeFoundation/hxcpp/releases/download/v4.3.45/hxcpp-4.3.45.zip
haxelib install ../hxcpp-4.3.45.zip --quiet

Using this newer build of hxcpp from GitHub should allow you to use NDK 25.2.9519653.

aigh, that’s sad but I remember one time I succefull did a way for last hxcpp and last haxe with last openfl and lime for last ndk, it actually worked well, but there was a single error, it wasn’t able to find jni.c, but I will try hxcpp from the reposit and using same ndk, thanks