Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: OneSignal.initWithContext() crashes on minified builds (5.0.0) #1811

Closed
1 task done
matejsemancik opened this issue Aug 23, 2023 · 6 comments
Closed
1 task done

Comments

@matejsemancik
Copy link

matejsemancik commented Aug 23, 2023

What happened?

The latest (5.0.0) version of SDK crashes during initialization using OneSignal.initWithContext(Context, String) method
when executed on application build minified by R8.

The attached crash log is extracted from my application's Crashlytics. (Android Gradle Plugin 8.1.0, Kotlin 1.8.22)
The same crash happens on OneSignalDemo example app. (Android Gradle Plugin 7.0.4, Kotlin 1.4.32)

This might be related to #1810

I temporarily worked around this issue by excluding entire OneSignal SDK from my proguard rules, but I see that as not very ideal solution.

Steps to reproduce?

1. Checkout the latest release `5.0.0` tag
2. Run the `gmsRelease` variant of sample `OneSignalDemo` app with R8 enabled -- `minifyEnabled true`:


buildTypes {
    release {
        minifyEnabled true
        signingConfig signingConfigs["debug"]
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    }
    ...

3. Observe crash during SDK initialization

What did you expect to happen?

I expected SDK to initialize without any issues and for the app to not crash during startup on obfuscated release build of application.

OneSignal Android SDK version

5.0.0

Android version

13

Specific Android models

No response

Relevant log output

Caused by: java.lang.Exception: Service interface jb.a could not be instantiated
    com.onesignal.common.services.ServiceProvider.getService(ServiceProvider.kt:70)
    com.onesignal.internal.OneSignalImp.initWithContext(OneSignalImp.kt:416)
    com.onesignal.OneSignal.initWithContext(OneSignal.java:126)
    dev.matsem.myapppackage.android.App.initializeOneSignal(App.kt:40)
    dev.matsem.myapppackage.android.App.onCreate(App.kt:17)

Code of Conduct

  • I agree to follow this project's Code of Conduct
@jennantilla
Copy link
Contributor

@matejsemancik Thank you for reaching out! We're looking into this and will get back to you as soon as possible.

@jdonlan
Copy link

jdonlan commented Aug 28, 2023

I can verify this same behavior in our application after updating to 5.0.0. The library works fine in a development environment without minification but fails on release builds due to minification.

@ShinyParadise
Copy link

If someone tries to fix this problem, here's more readable output of the same error. I got it by keeping all classes of com.onesignal.** package (excluded it in proguard file manually)

java.lang.Exception: Service class com.onesignal.core.internal.config.ConfigModelStore could not be instantiated
	at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6717)
	at android.app.ActivityThread.access$1300(ActivityThread.java:237)
	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1913)
	at android.os.Handler.dispatchMessage(Handler.java:106)
	at android.os.Looper.loop(Looper.java:223)
	at android.app.ActivityThread.main(ActivityThread.java:7656)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
Caused by: java.lang.Exception: Service class com.onesignal.core.internal.config.ConfigModelStore could not be instantiated
	at com.onesignal.common.services.ServiceProvider.f(Unknown Source:96)
	at com.onesignal.internal.OneSignalImp.c(Unknown Source:142)
	at com.makesure.ui.MakeSureApp.onCreate(Unknown Source:29)
	at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1192)
	at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6712)
	at android.app.ActivityThread.access$1300(ActivityThread.java:237) 
	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1913) 
	at android.os.Handler.dispatchMessage(Handler.java:106) 
	at android.os.Looper.loop(Looper.java:223) 
	at android.app.ActivityThread.main(ActivityThread.java:7656) 
	at java.lang.reflect.Method.invoke(Native Method) 
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592) 
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)

@michael-winkler
Copy link

I tried here #1810 (comment) to convert the old rules

@Petr-Kubista
Copy link

Still broken on 5.0.1

@emawby
Copy link
Contributor

emawby commented Sep 11, 2023

Closing as a Duplicate of #1810

@emawby emawby closed this as completed Sep 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants