Skip to content

[Bug]: SDK Crashes on release/app bundle build when not all onesignal modules are included: Service interface i6.a could not be instantiated #1969

@CarlBarks

Description

@CarlBarks

What happened?

The application crashes on startup with the following error. It happens only on release/app bundle builds with proguard enabled and works as expected on debug builds.

FATAL EXCEPTION: main
                                                                                                                Process: xxxx, PID: 13210
                                                                                                                java.lang.RuntimeException: Unable to create application xxxx: java.lang.Exception: Service interface i6.a could not be instantiated
                                                                                                                	at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6764)
                                                                                                                	at android.app.ActivityThread.-$$Nest$mhandleBindApplication(Unknown Source:0)
                                                                                                                	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2133)
                                                                                                                	at android.os.Handler.dispatchMessage(Handler.java:106)
                                                                                                                	at android.os.Looper.loopOnce(Looper.java:201)
                                                                                                                	at android.os.Looper.loop(Looper.java:288)
                                                                                                                	at android.app.ActivityThread.main(ActivityThread.java:7872)
                                                                                                                	at java.lang.reflect.Method.invoke(Native Method)
                                                                                                                	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
                                                                                                                	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
                                                                                                                Caused by: java.lang.Exception: Service interface i6.a could not be instantiated
                                                                                                                	at l5.d.getService(Unknown Source:58)
                                                                                                                	at com.onesignal.internal.a.initWithContext(Unknown Source:257)
                                                                                                                	at j5.b.e(Unknown Source:16)
                                                                                                                	at xxx.onCreate(Unknown Source:80)
                                                                                                                	at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1277)
                                                                                                                	at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6759)
                                                                                                                	at android.app.ActivityThread.-$$Nest$mhandleBindApplication(Unknown Source:0) 
                                                                                                                	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2133) 
                                                                                                                	at android.os.Handler.dispatchMessage(Handler.java:106) 
                                                                                                                	at android.os.Looper.loopOnce(Looper.java:201) 
                                                                                                                	at android.os.Looper.loop(Looper.java:288) 
                                                                                                                	at android.app.ActivityThread.main(ActivityThread.java:7872) 
                                                                                                                	at java.lang.reflect.Method.invoke(Native Method) 
                                                                                                                	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548) 
                                                                                                                	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936) 

OneSignal SDK Version is at 5.1.1 but also happens on 5.1.0.

Similar issues that were studied are #1810 and #1857 but no proguard rules helped fix the issue.

OneSignal is initiated as
OneSignal.initWithContext(this, one_signal_app_id)

Steps to reproduce?

Include only the partial onesignal module dependencies

dependencies {
  implementation 'com.onesignal:core:5.0.0'
  implementation 'com.onesignal:notifications:5.0.0'
}

Build a release build / app bundle with proguard enabled

  1. Application crashes with error
    Service interface i6.a could not be instantiated

  2. App works as expected in debug mode

  3. Error disappears when all module dependencies are included

dependencies {
  implementation 'com.onesignal:core:5.0.0'
  implementation 'com.onesignal:in-app-messages:5.0.0'
  implementation 'com.onesignal:notifications:5.0.0'
  implementation 'com.onesignal:location:5.0.0'
}

or the full sdk package

dependencies {
  implementation 'com.onesignal:OneSignal:5.0.0'
}

What did you expect to happen?

As explained in the Migration Guide and since the modules In App and Location are not used by the app, I expected that a partial declaration of dependencies would be sufficient.

The issue resolves after depending on the whole OneSIgnal SDK, so I suspect something related to proguard rules or internal dependencies of the modules causes the inability to depend on the partial sdk.

OneSignal Android SDK version

5.1.1

Android version

13

Specific Android models

No response

Relevant log output

Two warnings before the crash helped pinpoint the issue to the missing modules:


 java.lang.ClassNotFoundException: com.onesignal.inAppMessages.InAppMessagesModule
2024-01-22 13:33:40.909 13210-13210 System.err                                               W  	at java.lang.Class.classForName(Native Method)
2024-01-22 13:33:40.909 13210-13210 System.err                                               W  	at java.lang.Class.forName(Class.java:454)
2024-01-22 13:33:40.909 13210-13210 System.err                                                W  	at java.lang.Class.forName(Class.java:379)
2024-01-22 13:33:40.909 13210-13210 System.err                                                W  	at com.onesignal.internal.a.<init>(Unknown Source:94)
2024-01-22 13:33:40.909 13210-13210 System.err                                                W  	at j5.b$a.a(Unknown Source:2)
2024-01-22 13:33:40.909 13210-13210 System.err                                                W  	at j5.b$a.invoke(Unknown Source:0)
2024-01-22 13:33:40.909 13210-13210 System.err                                                W  	at kotlin.SynchronizedLazyImpl.getValue(Unknown Source:20)
2024-01-22 13:33:40.909 13210-13210 System.err                                               W  	at j5.b.b(Unknown Source:2)
2024-01-22 13:33:40.909 13210-13210 System.err                                                W  	at j5.b.e(Unknown Source:12)
2024-01-22 13:33:40.909 13210-13210 System.err                                               W  	at xxx.onCreate(Unknown Source:80)
2024-01-22 13:33:40.909 13210-13210 System.err                                                W  	at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1277)
2024-01-22 13:33:40.909 13210-13210 System.err                                                W  	at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6759)
2024-01-22 13:33:40.909 13210-13210 System.err                                                W  	at android.app.ActivityThread.-$$Nest$mhandleBindApplication(Unknown Source:0)
2024-01-22 13:33:40.909 13210-13210 System.err                                                W  	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2133)
2024-01-22 13:33:40.909 13210-13210 System.err                                                W  	at android.os.Handler.dispatchMessage(Handler.java:106)
2024-01-22 13:33:40.909 13210-13210 System.err                                                W  	at android.os.Looper.loopOnce(Looper.java:201)
2024-01-22 13:33:40.909 13210-13210 System.err                                                W  	at android.os.Looper.loop(Looper.java:288)
2024-01-22 13:33:40.909 13210-13210 System.err                                                W  	at android.app.ActivityThread.main(ActivityThread.java:7872)
2024-01-22 13:33:40.909 13210-13210 System.err                                                W  	at java.lang.reflect.Method.invoke(Native Method)
2024-01-22 13:33:40.909 13210-13210 System.err                                                W  	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
2024-01-22 13:33:40.909 13210-13210 System.err                                                W  	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
2024-01-22 13:33:40.909 13210-13210 System.err                                                W  Caused by: java.lang.ClassNotFoundException: com.onesignal.inAppMessages.InAppMessagesModule
2024-01-22 13:33:40.909 13210-13210 System.err                                                W  	... 21 more
2024-01-22 13:33:40.909 13210-13210 System.err                                                W  java.lang.ClassNotFoundException: com.onesignal.location.LocationModule
2024-01-22 13:33:40.909 13210-13210 System.err                                                W  	at java.lang.Class.classForName(Native Method)
2024-01-22 13:33:40.909 13210-13210 System.err                                                W  	at java.lang.Class.forName(Class.java:454)
2024-01-22 13:33:40.909 13210-13210 System.err                                                W  	at java.lang.Class.forName(Class.java:379)
2024-01-22 13:33:40.909 13210-13210 System.err                                                W  	at com.onesignal.internal.a.<init>(Unknown Source:94)
2024-01-22 13:33:40.909 13210-13210 System.err                                                W  	at j5.b$a.a(Unknown Source:2)
2024-01-22 13:33:40.909 13210-13210 System.err                                                W  	at j5.b$a.invoke(Unknown Source:0)
2024-01-22 13:33:40.909 13210-13210 System.err                                                W  	at kotlin.SynchronizedLazyImpl.getValue(Unknown Source:20)
2024-01-22 13:33:40.909 13210-13210 System.err                                                W  	at j5.b.b(Unknown Source:2)
2024-01-22 13:33:40.909 13210-13210 System.err                                                W  	at j5.b.e(Unknown Source:12)
2024-01-22 13:33:40.909 13210-13210 System.err                                                W  	at xxx.onCreate(Unknown Source:80)
2024-01-22 13:33:40.909 13210-13210 System.err                                                W  	at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1277)
2024-01-22 13:33:40.909 13210-13210 System.err                                                W  	at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6759)
2024-01-22 13:33:40.909 13210-13210 System.err                                                W  	at android.app.ActivityThread.-$$Nest$mhandleBindApplication(Unknown Source:0)
2024-01-22 13:33:40.909 13210-13210 System.err                                                W  	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2133)
2024-01-22 13:33:40.909 13210-13210 System.err                                                W  	at android.os.Handler.dispatchMessage(Handler.java:106)
2024-01-22 13:33:40.909 13210-13210 System.err                                                W  	at android.os.Looper.loopOnce(Looper.java:201)
2024-01-22 13:33:40.909 13210-13210 System.err                                                W  	at android.os.Looper.loop(Looper.java:288)
2024-01-22 13:33:40.909 13210-13210 System.err                                                W  	at android.app.ActivityThread.main(ActivityThread.java:7872)
2024-01-22 13:33:40.909 13210-13210 System.err                                                W  	at java.lang.reflect.Method.invoke(Native Method)
2024-01-22 13:33:40.909 13210-13210 System.err                                                W  	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
2024-01-22 13:33:40.909 13210-13210 System.err                                                W  	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
2024-01-22 13:33:40.909 13210-13210 System.err                                                W  Caused by: java.lang.ClassNotFoundException: com.onesignal.location.LocationModule
2024-01-22 13:33:40.909 13210-13210 System.err                                                W  	... 21 more
2024-01-22 13:33:40.913 13210-13210 OneSignal                                                 W  [main] Service not found: interface i6.a

Code of Conduct

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions