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]: AndroidJavaException: java.lang.ClassNotFoundException: com.onesignal.OneSignal #562

Open
1 task done
GorkemSvn opened this issue Nov 25, 2022 · 7 comments
Open
1 task done

Comments

@GorkemSvn
Copy link

GorkemSvn commented Nov 25, 2022

What happened?

Update: I've figured out unity's proguard minify doesn't include some dependencies onesignal needs, resulting one signal initialization to fail. I can't disable minify because i can't build without it. So onesignal needs to patch itself to be compatible with proguard minify.

It looks like unity's single dex file is not enought to hold firebase firestore,auth and onesignal and using minify breaks things

I'm followed one signal unity sdk setup steps , no problems in editor. Wrote single line of code in my notificationsmanager c# script( OneSignal.Default.Initialize("xcvsdv");) But when i had built in my samsung phone a70, i didn't receive any notification ( i sent notification from dashbouard.) I noticed my phone haven't subscribed to audience. And got this message from autoconnected profiler

note: i did not do steps for amazon-store

AndroidJavaException: java.lang.ClassNotFoundException: com.onesignal.OneSignal
image

image

Steps to reproduce?

1. open empty project
2. import onesignal sdk
3. use unity's minify at publish settings to build
4. enable autoconnect profiler
5. classnotfound exception: com.onesignal.onesignal at mobile phone

What did you expect to happen?

App to subscribe to onesignal audience

Unity version

2020.3.42

OneSignal Unity SDK version

3.0.6

Platform

Android

Relevant log output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@GorkemSvn
Copy link
Author

Update
I've updated sdk to 3.0.7
Created an empty project(unity 2020.3.42), imported onesignal sdk. get a build while minify is off. Saw my phone succesfully register to audience of onesignal
enabled the minify, cleared the audience from onesignal site. got another build
no audience registered. fail

@ridwanfauzy
Copy link

ridwanfauzy commented Mar 7, 2023

Perbarui Saya telah memperbarui sdk ke 3.0.7 Membuat proyek kosong (unity 2020.3.42), mengimpor sdk satu sinyal. dapatkan build saat minify tidak aktif. Melihat ponsel saya berhasil mendaftar ke audiens onesignal mengaktifkan minify, menghapus audiens dari situs onesignal. mendapat build lain, tidak ada audiens yang terdaftar. gagal

Can we build now using minify?

@jkasten2
Copy link
Member

jkasten2 commented May 5, 2023

Can you try adding this line to your Proguard config:

-keep com.onesignal.** { *; }

This will ensure all OneSignal classes are kept when minifying. You can consider this as a work around for now.

We will look into designing a Proguard config that can still allow some minification to OneSignal and include it in a future update so a manual step won't alway be required.

@GorkemSvn
Copy link
Author

GorkemSvn commented May 7, 2023 via email

@pus2meong
Copy link

I have the same issue.
I test on editor, no error found.
I build the apk, and test it on my android phone, nothing happen. It should have asking to subscribe or something, right?
I check on onesignal dashboard, no entry at all.

I found out that the code went error when calling this line: OneSignal.Initialize("MY ONE SIGNAL ID");
Using try and catch in the build apk, I managed to print to text UI, the error message from exception variable: java.lang.ClassNotFoundException: com.onesignal.OneSignal

I don't use proguard, I just follow the step from onesignal unity sdk setup steps.
I don't use any other plugins, just this one.

@jacoposcala
Copy link

Same issue.
No proguard/minify active.
Using the last OneSignal version "5.0.5" and Unity 2022.3.2.
Getting_ java.lang.ClassNotFoundException: com.onesignal.OneSignal on android build

@jkasten2
Copy link
Member

jkasten2 commented Mar 7, 2024

On this ClassNotFoundException with OneSignal-Unity-SDK v5 versions, this should have been fixed when updating to OneSignal-Unity-SDK 5.0.3, however it is important you follow this step from the release notes if coming from an older SDK version:

You must run the "Copy Android plugin to Assets" step in Window > OneSignal SDK Setup.

Please let us know if following this step fixes the issue for you. If not please provide an example Unity project so we can produce the issue on our end.

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

5 participants