game-ci / unity-builder

Build Unity projects for different platforms
https://github.com/marketplace/actions/unity-builder
MIT License
822 stars 231 forks source link

Android build failing on windows due to missing NDK installation #605

Closed Lokhandwalah closed 6 months ago

Lokhandwalah commented 7 months ago

Bug description

When I am trying to build unity for android platform. It involves two phases. First I try to export the android code and then I build the android APK. During the second phase I get the error regarding the ndk.

This is my workflow:

      - name: Build Unity
        uses: game-ci/unity-builder@v4.1.1
        env:
          UNITY_EMAIL: ${{ secrets.UNITY_USERNAME }}
          UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
          UNITY_SERIAL: ${{ secrets.UNITY_PRO_SERIAL_KEY }}
        with:
          unityVersion: 2020.3.42f1
          targetPlatform: Android
          projectPath: andromeda
          buildName: myracle
          buildsPath: andromeda/Builds
          buildMethod: UnityBuilderAction.Build.DoBuildAndroidLibrary
          customImage: unityci/editor:windows-2020.3.42f1-android-3.0.0

      - name: Get current time
        uses: josStorer/get-current-time@v2.0.1
        id: current-time
        with:
          format: YYYYWd

      - name: Build the Staging apk for Distribution
        working-directory: ./myracle
        run: flutter build apk --target=lib/main_staging.dart --flavor=staging --release --build-number=${{ steps.current-time.outputs.formattedTime }}
        env:
          ANDROID_KEYSTORE_PASSWORD_MYRACLE_STAGING: ${{ secrets.ANDROID_KEYSTORE_PASSPHRASE_STAGING }}

It fails during the Build the Staging apk for Distribution steps with this error

WARNING: [Processor] Library 'C:\a\myracle-andromeda\myracle-andromeda\myracle\android\unityLibrary\libs\androidx_core_1.3.0.jar' contains references to both AndroidX and old support library. This seems like the library is partially migrated. Jetifier will try to rewrite the library anyway.
 Example of androidX reference: 'androidx/versionedparcelable/VersionedParcel'
 Example of support library reference: 'android/support/v4/app/RemoteActionCompatParcelizer'
Note: C:\a\myracle-andromeda\myracle-andromeda\myracle\android\unityLibrary\src\main\java\com\unity3d\player\UnityPlayerActivity.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
[CXX1102] Location specified by ndk.dir (C:/UnityEditor/2020.3.42f1/Editor/Data/PlaybackEngines/AndroidPlayer/NDK) did not contain a valid NDK and couldn't be used

FAILURE: Build failed with an exception.

* Where:
Build file 'C:\a\myracle-andromeda\myracle-andromeda\myracle\android\unityLibrary\build.gradle' line: 87

* What went wrong:
Execution failed for task ':unityLibrary:BuildIl2CppTask'.
> NDK is not installed

You can see the full logs here

Expected behavior

I should be able to build the android APK

Additional details

Building on Windows 8 core for android with unity version 2020.3.42lf. 
I am also using flutter for android and iOS development
Lokhandwalah commented 7 months ago

I think I am facing the same issue as what @danyow was facing #300

AndrewKahr commented 6 months ago

This is happening because the unity builder step runs inside of a container. The step afterwards is running on the host which doesn't have the tooling installed. Looking at the issue you referenced it seems to be the same issue. You'd need to find a way to point it to the host's NDK or somehow run the build inside the container with the build tools installed (likely a custom container). As such this isn't a bug with the action, it just inherently runs this way.

Lokhandwalah commented 6 months ago

@AndrewKahr can please help me with running my other steps in the same container, any info is really appreciated.