OneSignal-Android-SDK icon indicating copy to clipboard operation
OneSignal-Android-SDK copied to clipboard

[Bug]: INotificationServiceExtension not call in release apk, but work in debug mode

Open welcome14 opened this issue 1 year ago • 3 comments
trafficstars

What happened?

the service INotificationServiceExtension is called when i use a debug mode, but when i create a build in release mode, the service not work.

minSdkVersion 21 targetSdkVersion 34 compileSdk 34 buildToolsVersion '35.0.0 rc2'

implementation 'com.onesignal:OneSignal:5.1.7'

Gradle 8.7

write in java language

Steps to reproduce?

send notification with app in background.

What did you expect to happen?

null

OneSignal Android SDK version

34

Android version

13

Specific Android models

No response

Relevant log output

null

Code of Conduct

  • [X] I agree to follow this project's Code of Conduct

welcome14 avatar Apr 05 '24 17:04 welcome14

@welcome14 we need a bit more information to investigate:

  1. Can you add @Keep to your class the implements INotificationServiceExtension?
    • This will make sure your class is not renamed or removed due to minification setting you may have on release
  2. Do you get any errors in the logcat?
    • Enable OneSignal Verbose logging if you are not seeing any errors.
  3. Can you try disabling all minification in your release build?
    • Progurd, R8, etc.

jkasten2 avatar Apr 05 '24 17:04 jkasten2

i have disable the minification, and it works!

buildTypes { release { minifyEnabled true } }

welcome14 avatar Apr 06 '24 08:04 welcome14

@welcome14 does adding @Keep to your class also solve the problem? As it is recommended to use minification in release builds.

jkasten2 avatar Apr 08 '24 17:04 jkasten2

Same problem here, but solved with @Keep.

Setting minifyEnabled false worked for release app, so as @jkasten2 said I added @Keep to my implementation of OneSignal.OSRemoteNotificationReceivedHandler (I'm still in OneSignal 4.8) and it worked!

I think the problem is related to the upgrade of AGP from v7 to v8, this will make that the minify goes too far away...

AroundPixels avatar Jun 12 '24 16:06 AroundPixels