Skip to content

How to build for Android

The unity3d docker project already creates docker images able to build for Android, but they are not tested yet:

https://gitlab.com/gableroux/unity3d/blob/7ec5008c/.gitlab-ci.yml#L3576

That part of the gitlab-ci.yml built and tagged gableroux/unity3d:2018.2.2f1-android image so you can use this image to build for android.

I did not try to build an android project using docker yet either, but Android is also a special case. I'm not sure what artifact it's going to produce and the docker image may need additional requirements such as Java, Android SDK, Android NDK, etc.

I know Unity can generate an android gradle project, but I'm not sure if it will need the same requirements. Maybe the solution here is similar to what can be done for iOS in #16 (closed)

We should provide an example in this project to do so, or at least document how we can do this.

.gitlab-ci.yml draft

build-android:
  <<: *build
  image: gableroux/unity3d:2018.2.2f1-android
  variables:
    BUILD_TARGET: Android

generate-android-apk
  image: some_android_gradle_flastlane_compatible_image
  stage: post-build
  script: |
    ls -la $BUILD_PATH
    [ -n "$(ls -A $BUILD_PATH)" ] # fail job if build folder is empty
    android-studio build .
    code-sign .
    etc.
    fastlane android
  artifacts:
    paths:
      - ./Builds/Android/$BUILD_NAME.apk
Edited by Gabriel Le Breton