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]: Random crashes on android #494

Closed
1 task done
joaquingrech opened this issue Apr 27, 2022 · 4 comments
Closed
1 task done

[Bug]: Random crashes on android #494

joaquingrech opened this issue Apr 27, 2022 · 4 comments

Comments

@joaquingrech
Copy link

joaquingrech commented Apr 27, 2022

What happened?

I'm getting crashes on android when I get a notification. It complains about missing classes.
I did the integration of 3.0.1 as told by the official guide. But I realize something is missing in the androidmanifest compared with the demo project in your github from here https://github.com/OneSignalDevelopers/OneSignal-Unity-Sample/blob/main/Assets/Plugins/Android/OneSignalConfig.plugin/AndroidManifest.xml

The lines:

<permission android:name="com.onesignal.unityosdemo.permission.C2D_MESSAGE" android:protectionLevel="signature" />
    <uses-permission android:name="com.onesignal.unityosdemo.permission.C2D_MESSAGE" />
    <application>
      <receiver
            android:name="com.onesignal.GcmBroadcastReceiver"
            android:permission="com.google.android.c2dm.permission.SEND" >
            <intent-filter>
                <action android:name="com.google.android.c2dm.intent.RECEIVE" />
                <category android:name="com.onesignal.unityosdemo" />
            </intent-filter>
        </receiver>
    </application>

they are nowhere to be found. My Onesignal android manifest in full is like this:

<!--
   WARNING: Do NOT Modify! Changes will be overwritten by the OneSignal plugin.
            Make your changes to Assets/Plugins/Android/AndroidManifest.xml instead.
-->

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.onesignal.onesignalsdk"
    android:versionCode="1"
    android:versionName="1.0" >
</manifest>

so is it missing the whole GCM system? Is this by design?

I'm just trying to figure out what's causing the crashes. So far 3.0 upgrade has been horrible.

Steps to reproduce?

just import the android package

What did you expect to happen?

random crashes

Unity version

2021.3.1

OneSignal Unity SDK version

3.0.1

Platform

Android

Relevant log output

No response

Code of Conduct

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

@joaquingrech

2.x.x to 3.x.x migration

If you upgraded from a 2.x.x version of the OneSignal Unity SDK make sure you have deleted the Assets/OneSignal folder from your project to ensure the old versions files doesn't create issues. See the full guide for more details:
https://github.com/OneSignal/OneSignal-Unity-SDK/blob/main/MIGRATION.md

Still an issue?

If after removing the folder you still see a crash please report the full stack trace so we can help find the root cause of your issue.

Background details

GCM was switched to FCM (this was actually done in a 2.x.x version but the com.onesignal.GcmBroadcastReceiver java class name wasn't changed until 3.0.0). More importantly on the AndroidManifest.xml topic, the <receiver> tag you noted above from 2.x.x no longer lives directly in your project in 3.x.x. It is now part of the com.onesignal:OneSignal Gradle .aar package this SDK depends on, with it's source is found in the OneSignal-Android-SDK repo.

@joaquingrech
Copy link
Author

I did a clean installation several times. There is nothing from 2.x version in the project. Not a single folder. The OneSignal folder now only contains the generated link.xml file

As for stacktrace. The moment I add OneSignal intro my project I begin getting hundreths for crash reports on the google console with these.

java.lang.RuntimeException: 
  at android.app.ActivityThread.handleReceiver (ActivityThread.java:4469)
  at android.app.ActivityThread.access$1700 (ActivityThread.java:301)
  at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2188)
  at android.os.Handler.dispatchMessage (Handler.java:106)
  at android.os.Looper.loop (Looper.java:247)
  at android.app.ActivityThread.main (ActivityThread.java:8676)
  at java.lang.reflect.Method.invoke (Native Method)
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:602)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1130)
Caused by: java.lang.ClassNotFoundException: 
  at dalvik.system.BaseDexClassLoader.findClass (BaseDexClassLoader.java:207)
  at java.lang.ClassLoader.loadClass (ClassLoader.java:379)
  at java.lang.ClassLoader.loadClass (ClassLoader.java:312)
  at android.app.AppComponentFactory.instantiateReceiver (AppComponentFactory.java:110)
  at androidx.core.app.CoreComponentFactory.instantiateReceiver (CoreComponentFactory.java:60)
  at android.app.ActivityThread.handleReceiver (ActivityThread.java:4462)

I remove OneSignal and I get zero crashes. None whatsoever.

I'll give it a couple more hours and I've decided this package is just wasting days of my work already. It's not working on Amazon, Google and won't compile on iOS. No matter what we do or try. Version 2.x was working just fine. 3.0 and 3.0.1 is a total disaster.

@jkasten2
Copy link
Member

@joaquingrech

Android Crash reports

Thanks for the stacktrace, however I don't see OneSignal in it. The only non Android AOSP class I see in the stack is androidx.core.app.CoreComponentFactory.instantiateReceiver but that doesn't narrow things down much.

Caused by: java.lang.ClassNotFoundException:

This line normally has the class name specifically that was not found. Can you check some other crash reports and try exporting them in a different way to get this piece of information? Any other details such as Android version crashing will be helpful too.

Is this a crash you can reproduce on any of your devices?

Won't compile on iOS

The 3.x.x switched to Cocoapods to install the native part of the OneSignal SDK. If this is related to that you can check out #468 (comment) on some setting you will need to confirm are on.

If the above isn't what you are seeing please create a new issue for iOS with the full build error and we can take a look.

@joaquingrech
Copy link
Author

joaquingrech commented Apr 27, 2022

That's the whole stack trace. I wish it had more information. I removed OneSignal sdk from my game. Zero crashes now. Thanks for the help, I gave up on 3.0.1 and I'm so mad at wasting time with this that I don't even want to roll back to 2.x.
I hope you figure out what's going on. I honestly don't have the time to be beta testing this product.

@jkasten2 jkasten2 closed this as completed Mar 7, 2024
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