bugsnag-unity icon indicating copy to clipboard operation
bugsnag-unity copied to clipboard

NDK Automatic Upload not working for Unity Android Build with Gradle

Open finalife opened this issue 4 years ago • 12 comments

I have followed the set up for getting Bugsnag to report any errors or crashes in Unity with the gameobject and behaviour addition into my game. I am now seeing crashes and errors, and have moved onto the NDK upload document found here: https://docs.bugsnag.com/build-integrations/gradle/ I have added the necessary items into both AndroidManifest.xml and build.gradle and haven't seen any NDK get uploaded into the bugsnag dashboard under settings. I have my API key inside AndroidManifest.xml and in the build.gradle I have added the following lines: apply plugin: 'com.android.application' apply plugin: 'com.bugsnag.android.gradle'

bugsnag {
    ndk true
    sharedObjectPath "app/build/jni/libs"
    overwrite true
    retryCount 5
    requestTimeoutMs 5000
    failOnUploadError true
    builderName "Chris"
}

I have also added the following into proguard rules: -keepattributes SourceFile,LineNumberTable -keep class com.bugsnag.android.NativeInterface { *; } -keep class com.bugsnag.android.Breadcrumb { *; } -keep class com.bugsnag.android.Breadcrumbs { *; } -keep class com.bugsnag.android.Breadcrumbs$Breadcrumb { *; } -keep class com.bugsnag.android.BreadcrumbType { *; } -keep class com.bugsnag.android.Severity { *; } -keep class com.bugsnag.android.ndk.BugsnagObserver { *; }

Any help with this is greatly appreciated and if any other lines of code or explanation is needed, I will make sure to add them.

Thanks in advance!

finalife avatar Mar 16 '20 20:03 finalife

Hi @finalife Although our gradle plugin supports upload of NDK symbols on a plain Android gradle project, it's not something the plugin yet supports for a Unity project. We have plans to address that and we'll let you know as soon as a new version is released to support this but for the time being you'd need to upload the NDK symbols by adding a build step to call the API directly: https://docs.bugsnag.com/api/ndk-symbol-mapping-upload/

We have an example of doing this via cURL here: https://docs.bugsnag.com/api/ndk-symbol-mapping-upload/#curl-example

abigailbramble avatar Mar 17 '20 12:03 abigailbramble

Thank you for letting me know about this. Would it be safe to assume the same process needs to be done with dSYM files then as well when it comes to a Unity build? Or can that be automated?

finalife avatar Mar 17 '20 13:03 finalife

Hi @finalife - I can see that you have raised https://github.com/bugsnag/bugsnag-unity/issues/193 for this question. If you encounter any issues with automatically uploading dSYMs then please do let us know on that thread. As far as we are aware this should work.

abigailbramble avatar Mar 30 '20 15:03 abigailbramble

@phillipsam i've managed to make bugsnag see the shared object by changing the folder, because in unity exported projects the path is "src/main/jniLibs", and bugsnag started seeing them, but there is another problem:

Symbolpath: /Users/sh3rawi/workspace/jawaker-unity/android-builds/jawaker-build/jawaker_unity/build/intermediates/symbols/release/R.txt
Checking dir: /Users/sh3rawi/workspace/jawaker-unity/android-builds/jawaker-build/jawaker_unity/src/main/jniLibs
Found shared object file (armeabi-v7a) /Users/sh3rawi/workspace/jawaker-unity/android-builds/jawaker-build/jawaker_unity/src/main/jniLibs/armeabi-v7a/libmain.so
Creating symbol file at /Users/sh3rawi/workspace/jawaker-unity/android-builds/jawaker-build/jawaker_unity/build/bugsnag/armeabi-v7a.gz
Skipping upload of empty/invalid mapping file: /Users/sh3rawi/workspace/jawaker-unity/android-builds/jawaker-build/jawaker_unity/build/bugsnag/armeabi-v7a.gz
Found shared object file (armeabi-v7a) /Users/sh3rawi/workspace/jawaker-unity/android-builds/jawaker-build/jawaker_unity/src/main/jniLibs/armeabi-v7a/libil2cpp.so
Creating symbol file at /Users/sh3rawi/workspace/jawaker-unity/android-builds/jawaker-build/jawaker_unity/build/bugsnag/armeabi-v7a.gz
Skipping upload of empty/invalid mapping file: /Users/sh3rawi/workspace/jawaker-unity/android-builds/jawaker-build/jawaker_unity/build/bugsnag/armeabi-v7a.gz
Found shared object file (armeabi-v7a) /Users/sh3rawi/workspace/jawaker-unity/android-builds/jawaker-build/jawaker_unity/src/main/jniLibs/armeabi-v7a/libunity.so
Creating symbol file at /Users/sh3rawi/workspace/jawaker-unity/android-builds/jawaker-build/jawaker_unity/build/bugsnag/armeabi-v7a.gz
Skipping upload of empty/invalid mapping file: /Users/sh3rawi/workspace/jawaker-unity/android-builds/jawaker-build/jawaker_unity/build/bugsnag/armeabi-v7a.gz
Found shared object file (arm64-v8a) /Users/sh3rawi/workspace/jawaker-unity/android-builds/jawaker-build/jawaker_unity/src/main/jniLibs/arm64-v8a/libmain.so
Creating symbol file at /Users/sh3rawi/workspace/jawaker-unity/android-builds/jawaker-build/jawaker_unity/build/bugsnag/arm64-v8a.gz
Skipping upload of empty/invalid mapping file: /Users/sh3rawi/workspace/jawaker-unity/android-builds/jawaker-build/jawaker_unity/build/bugsnag/arm64-v8a.gz
Found shared object file (arm64-v8a) /Users/sh3rawi/workspace/jawaker-unity/android-builds/jawaker-build/jawaker_unity/src/main/jniLibs/arm64-v8a/libil2cpp.so
Creating symbol file at /Users/sh3rawi/workspace/jawaker-unity/android-builds/jawaker-build/jawaker_unity/build/bugsnag/arm64-v8a.gz
Skipping upload of empty/invalid mapping file: /Users/sh3rawi/workspace/jawaker-unity/android-builds/jawaker-build/jawaker_unity/build/bugsnag/arm64-v8a.gz
Found shared object file (arm64-v8a) /Users/sh3rawi/workspace/jawaker-unity/android-builds/jawaker-build/jawaker_unity/src/main/jniLibs/arm64-v8a/libunity.so
Creating symbol file at /Users/sh3rawi/workspace/jawaker-unity/android-builds/jawaker-build/jawaker_unity/build/bugsnag/arm64-v8a.gz
Skipping upload of empty/invalid mapping file: /Users/sh3rawi/workspace/jawaker-unity/android-builds/jawaker-build/jawaker_unity/build/bugsnag/arm64-v8a.gz

I've made sure that find $ANDROID_HOME/ndk-bundle -iname "*objdump" returns the following:

/usr/local/Caskroom/android-sdk/3859397/ndk-bundle/toolchains/x86-4.9/prebuilt/darwin-x86_64/bin/i686-linux-android-objdump
/usr/local/Caskroom/android-sdk/3859397/ndk-bundle/toolchains/x86-4.9/prebuilt/darwin-x86_64/i686-linux-android/bin/objdump
/usr/local/Caskroom/android-sdk/3859397/ndk-bundle/toolchains/mips64el-linux-android-4.9/prebuilt/darwin-x86_64/bin/mips64el-linux-android-objdump
/usr/local/Caskroom/android-sdk/3859397/ndk-bundle/toolchains/mips64el-linux-android-4.9/prebuilt/darwin-x86_64/mips64el-linux-android/bin/objdump
/usr/local/Caskroom/android-sdk/3859397/ndk-bundle/toolchains/x86_64-4.9/prebuilt/darwin-x86_64/bin/x86_64-linux-android-objdump
/usr/local/Caskroom/android-sdk/3859397/ndk-bundle/toolchains/x86_64-4.9/prebuilt/darwin-x86_64/x86_64-linux-android/bin/objdump
/usr/local/Caskroom/android-sdk/3859397/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-objdump
/usr/local/Caskroom/android-sdk/3859397/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/arm-linux-androideabi/bin/objdump
/usr/local/Caskroom/android-sdk/3859397/ndk-bundle/toolchains/mipsel-linux-android-4.9/prebuilt/darwin-x86_64/bin/mipsel-linux-android-objdump
/usr/local/Caskroom/android-sdk/3859397/ndk-bundle/toolchains/mipsel-linux-android-4.9/prebuilt/darwin-x86_64/mipsel-linux-android/bin/objdump
/usr/local/Caskroom/android-sdk/3859397/ndk-bundle/toolchains/aarch64-linux-android-4.9/prebuilt/darwin-x86_64/aarch64-linux-android/bin/objdump
/usr/local/Caskroom/android-sdk/3859397/ndk-bundle/toolchains/aarch64-linux-android-4.9/prebuilt/darwin-x86_64/bin/aarch64-linux-android-objdump

Do you think this problem is related to it being a unity build, not a regular android project?

Sh3rawi avatar May 23 '20 14:05 Sh3rawi

Hi @Sh3rawi

The plugin attempts to find any debug information within a .so file and uploads that information. Those .so files (libmain.so, libil2cpp.so, libunity.so) are Unity libraries and don't actually contain debug information.

Exploring alternative ways of extracting that information, to be able to de-symbolicate stacktraces from those libraries, is something we have on our roadmap but currently we don't have any estimates as to when that might happen.

johnkiely1 avatar May 27 '20 16:05 johnkiely1

Good morning, what is the state of the issue?

Following this guide: "https://docs.bugsnag.com/platforms/unity/showing-full-stacktraces/#uploading-ndk-symbols" it doesn't work.

adriancorbalan avatar Aug 04 '20 06:08 adriancorbalan

Hi @adriencorbalan,

We are still looking at alternative ways to get the debug information from Unity libraries.

I assume you are talking more generally about using the plugin with Unity. We have recently discovered that the current docs for integrating the plugin will only apply to Unity versions 2019.3.x and newer. Prior to that the gradle build system used by unity, created a different module structure. We are in the process of updating the docs accordingly and are still investigating the usage of the plugin in older versions.

Assuming you are using an older version, you can still export the project to be an Android project and integrate the plugin there. Alternatively you can use the upload endpoint to upload the .so files manually.

If you are using a version for which the documentation should apply what issues are you encountering?

johnkiely1 avatar Aug 05 '20 13:08 johnkiely1

Hi @johnkiely1 sorry for the late answer. I'm using the Unity 2019.4.5f1 and after several attempts, the upload it doesn't work. I try upload the .so using curl but the doc doesn't tell nothing about the files to upload. I upload the same .so to Google Play and it works. I don't know how to continue and it's so important to search for ANRs at the platform. Thank's!

adriancorbalan avatar Aug 22 '20 11:08 adriancorbalan

Good morning, what is the state of the issue?

Following this guide: "https://docs.bugsnag.com/platforms/unity/showing-full-stacktraces/#uploading-ndk-symbols" it doesn't work.

@adriencorbalan what are you seeing when you say it doesn't work? are you able to show me what your LauncherTemplate and LauncherManifest files look like? (you can either post here or write into [email protected])

Thanks!

abigailbramble avatar Sep 09 '20 10:09 abigailbramble

Hi! @phillipsam I'm also having problems uploading the Android NDK symbols from a Unity project (Unity 2019.4.8f1).

I started by following the aforementioned Unity guide for the plugin, but noticed it was not updated for newer Unity or Gradle versions.

I gave up on that and I'm attempting to upload the NDK mapping files directly. I understand there is no official Bugsnag path for SO files for Unity, but I found some interesting SO files with debug info here (in my Unity version):

ProjectFolder\Temp\StagingArea\symbols\arch\

Where the files inside are:

  • libil2cpp.dbg.so
  • libil2cpp.sym.so
  • libunity.sym.so

All of them seem to have debug info (their size and objdump --syms confirm that) and when I run objdump --dwarf=info --dwarf=rawline on libil2cpp.dbg.so I get debug info consistent with the structure specified in your NDK symbols upload guide.

I pushed the generated content after zipping it with gzip and I can see they got processed without errors: image

I, however still see no change (after the gzip was uploaded and processed) in the stacktrace of some errors, like this one (that specifically has some undisclosed line from the SO I uploaded): image

Is there a step I missed, or a way to debug or make sure the mapping files are being applied? Could libil2cpp.dbg.so be the mapping file we need on newer Unity versions to map libil2cpp.so? Is there a way for you guys to check if the uploaded mapping files are being used by the build while processing bugsnag errors?

DominatorDuck avatar Oct 13 '20 20:10 DominatorDuck

Hi @DominatorDuck - Support for uploading Unity symbol mappings was added in v5.3.0, however as we discussed on your support tcket, there was a bug with using the Bugsnag Gradle Plugin when building Unity projects on Windows only.

We have released a new version of the Bugsnag Gradle Plugin which no longer crashes on Windows. This fix was released in v5.7.0.

Unfortunately, our symbol table mappings upload API does not currently support Windows yet and therefore the Bugsnag Gradle Plugin will not upload Unity symbol mappings for you and you will not be able to generate and upload these manually.

We will be sure to write back here when support is added for this.

We have also updated our docs on Adding the Bugsnag Gradle Plugin to Unity. This is now up to date and provides guidance depending on the version of Unity you are using.

abigailbramble avatar Jan 28 '21 10:01 abigailbramble

Just a quick update to let you know that that our API endpoint can now accept symbol table mapping uploads from Windows machines.

This means it's now possible to upload the, Windows generated, files manually. The instructions on how to do that are located in our documentation, here

johnkiely1 avatar Feb 23 '21 11:02 johnkiely1

Hi, As there has been no update on this issue in some time I am going to close this out. Please feel free to reopen this issue if you are still experiencing problems with uploading your unity mapping files.

clr182 avatar Dec 07 '23 10:12 clr182