OneSignal-Android-SDK
OneSignal-Android-SDK copied to clipboard
[Bug]: INotificationServiceExtension not call in release apk, but work in debug mode
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 we need a bit more information to investigate:
- Can you add
@Keepto your class the implementsINotificationServiceExtension?- This will make sure your class is not renamed or removed due to minification setting you may have on release
- Do you get any errors in the logcat?
- Enable OneSignal Verbose logging if you are not seeing any errors.
- Can you try disabling all minification in your release build?
- Progurd, R8, etc.
i have disable the minification, and it works!
buildTypes { release { minifyEnabled true } }
@welcome14 does adding @Keep to your class also solve the problem? As it is recommended to use minification in release builds.
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...