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]: java.lang.NoClassDefFoundError encountered in OneSignal Flutter Plugin #779

Open
2 of 3 tasks
pawan-joshee opened this issue Oct 29, 2023 · 7 comments
Open
2 of 3 tasks

Comments

@pawan-joshee
Copy link

pawan-joshee commented Oct 29, 2023

What happened?

Description:

While using the OneSignal Flutter plugin, I encountered a java.lang.NoClassDefFoundError during runtime. This error wasn't observed during compile-time, and I believe it might be related to the plugin's implementation or a potential conflict with other plugins/dependencies.

Stack Trace:

Fatal Exception: java.lang.NoClassDefFoundError: pd.a
   at com.onesignal.flutter.OneSignalNotifications.q(SourceFile)
   at com.onesignal.flutter.OneSignalNotifications.onMethodCall(SourceFile)
   at ng.k$a.a(SourceFile)
   at bg.c.l(SourceFile)
   at bg.c.m(SourceFile)
   at bg.c.i(SourceFile)
   at bg.b.run(SourceFile)
   at android.os.Handler.handleCallback(Handler.java:739)
   at android.os.Handler.dispatchMessage(Handler.java:95)
   at android.os.Looper.loop(Looper.java:145)
   at android.app.ActivityThread.main(ActivityThread.java:6946)
   at java.lang.reflect.Method.invoke(Method.java)
   at java.lang.reflect.Method.invoke(Method.java:372)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)

flutter doctor

[!] Flutter (Channel stable, 3.13.6, on macOS 14.0 23A344 darwin-arm64, locale en-IN)
    ! Warning: `flutter` on your path resolves to /Users/taiyarikarlo/flutter/bin/flutter, which is not inside your current Flutter SDK checkout
      at /users/taiyarikarlo/flutter. Consider adding /users/taiyarikarlo/flutter/bin to the front of your path.
    ! Warning: `dart` on your path resolves to /Users/taiyarikarlo/flutter/bin/dart, which is not inside your current Flutter SDK checkout at
      /users/taiyarikarlo/flutter. Consider adding /users/taiyarikarlo/flutter/bin to the front of your path.
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 15.0)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2022.2)
[✓] VS Code (version 1.79.0)
[✓] Connected device (3 available)
[✓] Network resources

! Doctor found issues in 1 category.```


### Steps to reproduce?

```Markdown
1. onesignal_flutter:  ^5.0.3 previously I'm using ^3.0.0 

2. changes the code from this 
`OneSignal.shared.setAppId("");
  OneSignal.shared.promptUserForPushNotificationPermission().then((accepted) {
    print("Accepted permission: $accepted");
  });` 
to this at main() 
` OneSignal.initialize("");
  OneSignal.Notifications.requestPermission(true);`

3. flutter clean and flutter pub get completed.

Notification receiving properly, and no errors detected at emulator, but after releasing on production mode at Play Store it's throwing the fatal error and app crashing.

What did you expect to happen?

The plugin should operate without causing any runtime exceptions, especially NoClassDefFoundError

OneSignal Flutter SDK version

Release ^5.0.2

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
@nan-li
Copy link
Contributor

nan-li commented Nov 2, 2023

Hi @pawankumar-creator, thanks for reporting.

NoClassDefFoundError means "The searched-for class definition existed when the currently executing class was compiled, but the definition can no longer be found."

Are you able to reproduce this consistently? And is this with a debug or release build?

Additionally, do you use any code obfuscation tools like Proguard or Dexguard?

@nan-li
Copy link
Contributor

nan-li commented Nov 2, 2023

May or may not be related to OneSignal/OneSignal-Cordova-SDK#910

@sur2548
Copy link

sur2548 commented Nov 3, 2023

This might help

#713 (comment)

@pawan-joshee
Copy link
Author

pawan-joshee commented Nov 6, 2023

Hi @pawankumar-creator, thanks for reporting.

NoClassDefFoundError means "The searched-for class definition existed when the currently executing class was compiled, but the definition can no longer be found."

Are you able to reproduce this consistently? And is this with a debug or release build?

Additionally, do you use any code obfuscation tools like Proguard or Dexguard?

The issue occurs when I use the latest version. It happens with the release build, not in debug. I'm not using any obfuscation tools.

@tehKost
Copy link

tehKost commented Dec 26, 2023

same problem using onesignal_flutter: ^5.0.4 on Android 5.0, 5.1 and 6.0 devices

@edisonlsm
Copy link

I keep getting the same error reported here...

I tried @sur2548 solution linked from the other issue, but for some reason the proguard rule -keep class com.onesignal.** only keeps the classes from onesignal android sdk... The com.onesignal.flutter classes are getting minified.

I performed a build and confirmed through mapping.txt that the Android code from Flutter Plugin keeps getting minified and throwing errors.
Captura de Tela 2024-02-01 às 13 15 31

@dwirandyh
Copy link

any update or workaround about this issue? i still face same problem on production app, i use version 5.2.6

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

6 participants