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

Proguard: threadId not found

Open peterdk opened this issue 2 months ago • 7 comments

Describe the bug

I updated to bugsnag 6.19.0, and now proguard won't allow my app to build.

It complains about:

Warning: com.bugsnag.android.ThreadState: can't find referenced method 'long threadId()' in library class java.lang.Thread

This seems indeed valid, since Android added it in API level 36. https://developer.android.com/reference/java/lang/Thread#threadId()

Am I supposed to build my project with target SDK 36?

Seeing it in active use in ThreadState in bugsnag sdk, I am wondering if this won't lead to crashes on older Android versions?

peterdk avatar Oct 26 '25 13:10 peterdk

I see that the change is backwards compatible.

@Suppress("DEPRECATION")
    private val JavaThread.threadId: Long
        get() =
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.BAKLAVA) {
                threadId()
            } else {
                id
            }

Maybe good to add a ignore to the proguard rules?

peterdk avatar Oct 26 '25 15:10 peterdk

Hi @peterdk,

I’m not seeing the same warning when using compileSdk 35 and v6.19.0 of the bugsnag-android notifier. Please can you let us know:

  • Your AGP and R8 versions

  • Your compileSdk version

  • How you are building your app

  • Confirm that adding -dontwarn com.bugsnag.android.ThreadState to your Proguard rules suppresses the warning

hannah-smartbear avatar Nov 06 '25 11:11 hannah-smartbear

Hi,

I am using it in quite a old project, so might be to do with that.

compileSDK 35 AGP 7.4.2 Proguard 9.1.7 (not R8)

And indeed, adding -dontwarn fixes my CI build

peterdk avatar Nov 07 '25 20:11 peterdk

Hi @peterdk

Thanks for sharing those details.

We have a PR open with a possible fix for the Proguard warning you are seeing. Please can you confirm whether the PR uses the same -dontwarn rule that you are using to fix the issue?

hannah-smartbear avatar Nov 11 '25 17:11 hannah-smartbear

Hi,

Ah great.

I used a different dontwarn rule:

-dontwarn com.bugsnag.android.ThreadState

But I will try the one from the PR to see if that has same effect.

Peter

Op 11 nov 2025, om 18:33 heeft Hannah Syed @.***> het volgende geschreven:

hannah-smartbear left a comment (bugsnag/bugsnag-android#2319)

Hi @.***(https://github.com/peterdk)

Thanks for sharing those details.

We have a PR open with a possible fix for the Proguard warning you are seeing. Please can you confirm whether the PR uses the same -dontwarn rule that you are using to fix the issue?

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>

peterdk avatar Nov 11 '25 20:11 peterdk

The change in the PR indeed fixes it for me.

peterdk avatar Nov 13 '25 18:11 peterdk

Hi @peterdk

Thanks for confirming. We’ll let you know when we release a new version of bugsnag-android containing the fix for that warning.

hannah-smartbear avatar Nov 20 '25 09:11 hannah-smartbear

Hi @peterdk,

Just wanted to let you know that v6.20.0 of bugsnag-android contains the fix for the Proguard warning you were seeing.

Please do let us know if you have any further questions.

hannah-smartbear avatar Dec 12 '25 09:12 hannah-smartbear