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]: Android: Displaying push messages fails with "InvocationTargetException" #1010

Open
2 of 3 tasks
timmkuehle opened this issue Jul 8, 2024 · 3 comments
Open
2 of 3 tasks

Comments

@timmkuehle
Copy link

timmkuehle commented Jul 8, 2024

What happened?

Since updating from an older onesignal-cordova-plugin version to the current 5.2.3, push notifications are no longer displayed on android devices. Instead Logcat shows the following error:

Could not instantiate com.onesignal.notifications.internal.generation.impl.NotificationGenerationWorkManager$NotificationGenerationWorker
java.lang.reflect.InvocationTargetException
	at java.lang.reflect.Constructor.newInstance0(Native Method)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
        at androidx.work.WorkerFactory.createWorkerWithDefaultFallback(WorkerFactory.java:96)
	at androidx.work.impl.WorkerWrapper.runWorker(WorkerWrapper.java:245)
	at androidx.work.impl.WorkerWrapper.run(WorkerWrapper.java:137)
        at androidx.work.impl.utils.SerialExecutor$Task.run(SerialExecutor.java:91)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
	at java.lang.Thread.run(Thread.java:1012)
Caused by: java.lang.NoSuchMethodError: No interface method getSerialTaskExecutor()Landroidx/work/impl/utils/taskexecutor/SerialExecutor; in class Landroidx/work/impl/utils/taskexecutor/TaskExecutor; or its super classes (declaration of 'androidx.work.impl.utils.taskexecutor.TaskExecutor' appears in /data/app/~~kp65UmQUcKw9QPj-jSu6NA==/de.sirum.tme-qtmr_Cl-N6WkbphU_Ygdpw==/base.apk)
	at androidx.work.CoroutineWorker.<init>(CoroutineWorker.kt:53)
	at com.onesignal.notifications.internal.generation.impl.NotificationGenerationWorkManager$NotificationGenerationWorker.<init>(NotificationGenerationWorkManager.kt:64)
	at java.lang.reflect.Constructor.newInstance0(Native Method)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
        at androidx.work.WorkerFactory.createWorkerWithDefaultFallback(WorkerFactory.java:96)
        at androidx.work.impl.WorkerWrapper.runWorker(WorkerWrapper.java:245)
        at androidx.work.impl.WorkerWrapper.run(WorkerWrapper.java:137)
        at androidx.work.impl.utils.SerialExecutor$Task.run(SerialExecutor.java:91)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
        at java.lang.Thread.run(Thread.java:1012)

Sadly, I'm barely deep enough into native Android coding in Java, to tell that there seems to be an issue with a missing method.

Similar issues were reported in #1677 and #1998 in the OneSignal React Native repo, but I couldn't find any resolution.

The release notes of Release 5.2.3 even mention a fix for a "could not be instantiated" exception, but I couldn't figure out if this was related to the error I'm seeing. However Release 5.2.3 doesn't fix the exception that I ran into.

Steps to reproduce?

1. Install plugin and SDK via Capacitor
2. Launch the App on on any Android device
3. Send a test push from the OneSignal Dashboard
4. Monitor the Logcat console
5. See the error mentioned above

What did you expect to happen?

A push notification should have been displayed.

OneSignal Cordova SDK version

Release 5.2.3

Which platform(s) are affected?

  • iOS
  • Android

Relevant log output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@jkasten2
Copy link
Member

jkasten2 commented Jul 17, 2024

@timmkuehle thanks for reporting, this looks similar to issue OneSignal/react-native-onesignal#1677 but is different than OneSignal/OneSignal-Android-SDK#1998.

Questions

Since updating from an older onesignal-cordova-plugin version to the current 5.2.3

  1. What version did you upgrade from? Did you upgrade anything else at the same time?

push notifications are no longer displayed on android devices

  1. Does the crash happen every time? What versions of Android and devices did you reproduce the crash on? Any devices work correctly that you tested?

  2. Does the issue happen with development builds or if you disable minification?

  3. What version of the Android work-runtime and work-runtime-ktx is being built into your app?

    • You can get this by running ./gradlew app:dependencies or ./gradlew build --scan from the android folder of your project. (where your build.gradle or gradlew files are located)
  4. Can you share a project reproducing the issue?

  5. Can you list the other libraries and SDKs used in your project? (If you can't provide a sample project)

Investigation

The crash is coming from within Google's work-runtime library used by OneSignal. It is an internal error to Google's library so unfortunately it's hard to know what the root cause is. But if I had to guess it might be that the versions of work-runtime-ktx and work-runtime might be different enough versions to cause this issue. These should always match, but if Gradle may decide to update one and not the other if other libraries use only work-runtime.

@jkasten2
Copy link
Member

jkasten2 commented Jul 18, 2024

I am able to reproduce the issue if work-runtime-ktx:2.8.1 is used with androidx.work:work-runtime:2.7.0 in a forceful way, such as:

    implementation('androidx.work:work-runtime-ktx:2.8.1')
    api('androidx.work:work-runtime') {
        version {
            strictly '2.7.0'
        }
    }

However it isn't clear what's downgrading the version in your scenario, but finding that is the key to solving this.

Can you run ./gradlew app:dependencies or ./gradlew build --scan from the android folder of your project. (where your build.gradle or gradlew files are located) and share the output? This should point to what library is defining a force downgrade.

Another way to find the breaking library is if you remove libraries from your project, or make a new project and build them up and share the project reproducing the issue.

@timmkuehle
Copy link
Author

@jkasten2 Thanks for your reply and a big sorry for my very late answer. Due to a few other issues in our project, I lost track on this issue.
These other issues also caused us to rework our push notification setup altogether, so we won't use OneSignal any longer.

I think in our case, we had to force androidx.work:work-runtime:2.7.0 for some other plugin we used, so we actually did this manually. Sadly I can't really reproduce this in the current state of our project.

As far as we are concerned, this issue could be closed, if it's not relevant for any of your other users. Thanks again for your effort and sorry, I couldn't shed more light on the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants