subosito / flutter-action

Flutter environment for use in GitHub Actions. It works on Linux, Windows, and macOS.
MIT License
2.17k stars 193 forks source link

[Question] Generating debug symbols to upload to Google Play #106

Closed ManuLpz4 closed 2 years ago

ManuLpz4 commented 3 years ago

Hi guys! Hope you are doing well 😁

In @belo-app we are facing problems to generate debug symbols to upload to Google Play and we are getting the following warning:

This App Bundle contains native code, and you've not uploaded debug symbols. We recommend that you upload a symbol file to make your crashes and ANRs easier to analyse and debug.

Someone knows how to solve it for CD? All solutions aims to solve it locally :/

Please and thank you :)

connorads commented 2 years ago

I've just started to look into this for my own project @ManuLpz4, did you manage to solve it?

ManuLpz4 commented 2 years ago

@connorads Nope yet, but if you want we can work together to achieve it 👍🏻

connorads commented 2 years ago

So I got it working @ManuLpz4. Hopefully the explanation below makes sense, if not please feel free to ask questions.

Locally

First I started by working out how to do it locally. Take a read, it might help explain how this works.

Which version of Android Gradle Plugin (AGP) are you using @ManuLpz4?

CI

To get it working in CI there are two steps:

  1. Set android.defaultConfig.ndk.debugSymbolLevel = 'FULL'
  2. Ensure you have the appropriate NDK version installed in appropriate folder on CI

The NDK version I need installing 21.1.6352462 wasn't already there so I have to install it somehow. But it looks like 21.4.7075529 (which works with AGP 4.2 & 7.0), 22.1.7171670, 23.0.7599858 are already installed in /usr/local/lib/android/sdk/ndk/ which I'm guessing was done by this flutter-action 🤷

Simple way (UPDATE/EDIT)

I tried to install NDK using sdkmanager and it took 80 seconds. Simpler but slightly slower than previous way.

# your GitHub Action workflow yml
    - name: Install NDK 21.1.6352462
      run: $ANDROID_HOME/tools/bin/sdkmanager --install "ndk;21.1.6352462"

Previous way

Step 2. was actually quite pernickety at first ... So I looked for a GitHub action to install the NDK, but it wasn't really prepped for this use case ...

I've started with a bit of dirty approach which was to fork setup-ndk GitHub action to get it to extract in the Android SDK/NDK folder and then rename the folder it creates in my workflow:

# your GitHub Action workflow yml
    - uses: connorads/setup-ndk@hard-coded-extract-path
      with:
        ndk-version: r21b
    - name: Rename NDK folder from android-ndk-r21b to 21.1.6352462
      run: |
        mv /usr/local/lib/android/sdk/ndk/android-ndk-r21b /usr/local/lib/android/sdk/ndk/21.1.6352462

CI Future Improvements

To tidy this up a bit I might try and instead use sdkmanager to install the NDK version so I don't have to do all this forkery and renaming. I thought this might add a lot of time to the build but the ndk-setup action already takes around 60 seconds and sdkmanager took 90 seconds locally on a bad connection. Will let you know if I do it and get it working.

Would be nice to get this down from 80 seconds. Java install takes 6 seconds with actions/setup-java Flutter install takes 52 seconds with subosito/flutter-action Would it be possible to speed this up using some GitHub action caching?

Alternatively if I just update to AGP 4.2+ then this action would already have installed the correct version of the NDK.