3c71
3c71

Reputation: 4531

Gradle 7.3.3 / Plugin 7.2.1 does not include native debug symbols in bundles

It was the same with Gradle 7.0.3 plugin 7.0.2 with Android Studio 2020.3.1 Patch 3.

Now with Android Studio 2021.2.1 Patch 1, gradle 7.3.3 plugin 7.2.1, still no debug symbols in app bundles.

If I revert to gradle 4.3.1 plugin 6.5.1, everything is working again.

Noticeably lib folder is also 4 times bigger with latest gradle than it was before!

The gradle builds are not changed in any ways between version of gradle's. One version works (6.5.1), the other does not (7.2.1).

See attached screenshot showing app bundles with plugin 7.2.1 on the left, 6.5.1 on the right.

The left one has no debug symbols included and lib folder is 2.8MB, the one on the right have debug symbols and lib folder is 714KB!

Any help would be much appreciated as it's been 6 months (if not a couple of years at it started after release 6.5.1) I've reported this to Google and received no reply or help whatsoever except 'the debug symbols are generated'. Note that they never said symbols are included in bundles.

Upvotes: 4

Views: 935

Answers (2)

molundb
molundb

Reputation: 639

How to debug this issue

I was stuck on this issue for several hours and finally figured out that it was caused by this bug with androidx.datastore:datastore-preferences:1.1.1 https://issuetracker.google.com/u/0/issues/342671895

How I figured it out

If native debug symbols don't get put in your bundle and you've tried everything, here are some tips of how to figure out why.

Here is how to check if the native debug symbols are in the bundle without needing to upload it to Play Console: https://stackoverflow.com/a/69417189/2225594.

As this amazing comment says, the first step is to figure out where the native code/libraries are coming from. In my case I hadn't added any native code (c-code) in my app so it wasn't because of #1. To check if it was #2 I checked the folder app/build/intermediates/merged_native_libs/release/out/lib. If this folder exists then the native code/libraries are coming from an android library that the app is depending on (in my case it was datastore-preferences but I didn't know this yet). In my case, the folder existed!

I used the following command to get information about the .so files:

nm -gD app/build/intermediates/merged_native_libs/release/mergeReleaseNativeLibs/out/lib/x86_64/libdatastore_shared_counter.so

The output was

0000000000000d10 T Java_androidx_datastore_core_NativeSharedCounter_nativeCreateSharedCounter
0000000000000db0 T Java_androidx_datastore_core_NativeSharedCounter_nativeGetCounterValue
0000000000000dc0 T Java_androidx_datastore_core_NativeSharedCounter_nativeIncrementAndGetCounterValue
0000000000000cb0 T Java_androidx_datastore_core_NativeSharedCounter_nativeTruncateFile
0000000000000c60 T _Z16ThrowIoExceptionP7_JNIEnvPKc
0000000000000dd0 T _ZN9datastore12TruncateFileEi
0000000000000e40 T _ZN9datastore15GetCounterValueEPNSt6__ndk16atomicIjEE
0000000000000df0 T _ZN9datastore19CreateSharedCounterEiPPv
0000000000000e50 T _ZN9datastore27IncrementAndGetCounterValueEPNSt6__ndk16atomicIjEE
                 U __cxa_atexit@LIBC
                 U __cxa_finalize@LIBC
                 U __errno@LIBC
                 U __stack_chk_fail@LIBC
                 U ftruncate@LIBC
                 U mmap@LIBC
                 U strerror@LIBC

That lead me to believe something was wrong with the datastore. I searched for "native debug symbols" in Google Issue Tracker and found the bug with datastore-preferences.

How to fix it

The problem is that the native debug symbols are not being generated/put in the bundle. To fix it you can manually create a .zip-file and upload it. Follow the steps here.

I haven't been able to make the native debug symbols be generated and put in the bundle automatically. I think google needs to fix their bug with datastore-preferences.

Other tip

The default ndkVersion is the version used by AGP during testing. Therefore, specifying the ndkVersion should not make a difference.

Upvotes: 0

3c71
3c71

Reputation: 4531

Generating NDK debug symbols in bundles is very messy no matter what version of Android Studio, gradle, gradle plugin and NDK you use.

Turns out there are many incompatibilities between versions, and each version of Android Studio requires specific versions of gradle/plugin/ndk to successfully generate debug symbols in bundles.

After opening many bug reports with Google, it turns out that specifying ndk version manually is a very bad idea in the first place and will often cause the issue.

If you check comment #7 and #8, it offers some insight into this issue: https://issuetracker.google.com/u/0/issues/234737605

As of now I'm using those versions (without specifying NDK version):

  • Android Studio Dolphin 2021.3.1 Patch 1
  • Gradle Plugin 7.3.1
  • Gradle 7.4

Upvotes: 0

Related Questions