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]: App Crashes on Android SDK 33 with java.util.ConcurrentModificationException (com.onesignal.common.events.EventProducer.fire) #216

Open
1 task done
opmat opened this issue Dec 25, 2023 · 1 comment

Comments

@opmat
Copy link
Contributor

opmat commented Dec 25, 2023

What happened?

My App Crashes on Android SDK 33 with java.util.ConcurrentModificationException (com.onesignal.common.events.EventProducer.fire). I am running on Expo. SDK 49 managed work flow. The app crashes immediately the OneSignal tries to initialize. However, if I removed Onesignal, the app runs successfully.
It also runs on lower Android SDK versions.
On Android 33, it gives the following errors;

java.util.ConcurrentModificationException (com.onesignal.common.events.EventProducer.fire)
java.lang.NullPointerException (com.onesignal.core.activities.PermissionsActivity.onRequestPermissionsResult)

My code is below

 const oneSignalAppId = Constants.expoConfig?.extra?.oneSignalAppId;

  OneSignal.initialize(oneSignalAppId);
  OneSignal.Debug.setLogLevel(LogLevel.Verbose);
  OneSignal.Notifications.requestPermission(true);
  OneSignal.setConsentRequired(true);

 OneSignal.setConsentGiven(true);

  let permission = OneSignal.Notifications.hasPermission();
  if (!permission) {
    OneSignal.Notifications.requestPermission(true);
  }

//Method for handling notifications received while app in foreground
  OneSignal.Notifications.addEventListener("foregroundWillDisplay", (event) => {
    event.preventDefault();
    // some async work
    let notification = event.getNotification();
    saveThisPushNotification(notification);
    // Use display() to display the notification after some async work
    event.getNotification().display();
  });


  // Method for listening for notification clicks
  
  OneSignal.Notifications.addEventListener("click", (event) => {
    console.log("OneSignal: notification clicked:", event);
    const { action, notification } = event;
    saveThisPushNotification(notification);
    notification.display();
    // Alert.alert(notification.title, notification.body);
  });

if (Object.keys(userData).length != 0) {
    OneSignal.User.addAlias("userd", userData.username);
    
    OneSignal.User.addTag("userid", userData.userid.toString());
    OneSignal.User.addTag("fullname", userData.fullname);
    OneSignal.User.addTag("username", userData.username);
    OneSignal.User.addTag("usertype", userData.usertype);


  }

Steps to reproduce?

1. Setup managed-flow Expo project
2. Install onesignal-expo-plugin version 2.0.2
3. Install react-native-onesignal versioon 5.0.4
4. Configure OneSignal in App.js
5. Run the Development Build of the app on Android SDK 33
6. App crashes at startup

What did you expect to happen?

I expected the application to run normally like in other lower Android SDK version and initialize OneSignal

OneSignal Expo SDK version

2.0.2

Platform

Android

Relevant log output

Your app just crashed. See the error below.
java.util.ConcurrentModificationException
  java.util.ArrayList$Itr.next(ArrayList.java:860)
  com.onesignal.common.events.EventProducer.fire(EventProducer.kt:49)
  com.onesignal.core.internal.application.impl.ApplicationService.setCurrent(ApplicationService.kt:50)
  com.onesignal.core.internal.application.impl.ApplicationService.onActivityStarted(ApplicationService.kt:150)
  android.app.Application.dispatchActivityStarted(Application.java:401)
  android.app.Activity.dispatchActivityStarted(Activity.java:1404)
  android.app.Activity.onStart(Activity.java:1922)
  android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1543)
  android.app.Activity.performStart(Activity.java:8330)
  android.app.ActivityThread.handleStartActivity(ActivityThread.java:3670)
  android.app.servertransaction.TransactionExecutor.performLifecycleSequence(TransactionExecutor.java:221)
  android.app.servertransaction.TransactionExecutor.cycleToPath(TransactionExecutor.java:201)
  android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:173)
  android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
  android.app.ActivityThread$H.handleMessage(ActivityThread.java:2307)
  android.os.Handler.dispatchMessage(Handler.java:106)
  android.os.Looper.loopOnce(Looper.java:201)
  android.os.Looper.loop(Looper.java:288)
  android.app.ActivityThread.main(ActivityThread.java:7872)
  java.lang.reflect.Method.invoke(Native Method)
  com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
  com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)

Code of Conduct

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

emawby commented Jan 5, 2024

@opmat Thank you for reporting this is an issue in our Android Native SDK that is being resolved and will be fixed in the next release. Thank you for your patience

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