Onesignal crash on boot with Android O - android

With Android 0 (DP4 in my case) and the 3.5.8 version of SDK, I have a crash on every boot of the device.
The crash is the following :
Caused by:
java.lang.IllegalStateException: Not allowed to start service Intent { cmp=com.frandroid.app/com.onesignal.NotificationRestoreService (has extras) }: app is in background uid UidRecord{c74919a u0a125 RCVR idle procs:1 seq(0,0,0)}
at android.app.ContextImpl.startServiceCommon(ContextImpl.java:1505)
at android.app.ContextImpl.startService(ContextImpl.java:1461)
at android.content.ContextWrapper.startService(ContextWrapper.java:644)
at android.content.ContextWrapper.startService(ContextWrapper.java:644)
at android.support.v4.content.WakefulBroadcastReceiver.startWakefulService(WakefulBroadcastReceiver.java:100)
at com.onesignal.BootUpReceiver.onReceive(BootUpReceiver.java:42)
at android.app.ActivityThread.handleReceiver(ActivityThread.java:3252)
at android.app.ActivityThread.-wrap17(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1677)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
This crash is related to Android O / 8.0.

This has been asked at the One signal issues
#jkasten2 answers:
// Add snapshots repo if you don't have it already
repositories {
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
}
compile 'com.onesignal:OneSignal:4.0.0-SNAPSHOT'
He has also mentioned:
From feedback from others and our own testing the beta has been stable. We are finishing our final testing and we are shooting for a release sometime next week.
Although the core issue is addressed by #Swati.
Update:
The ticket has been closed by OneSignal team, following is the fix (as updated in the one signal documentation):
dependencies {
compile 'com.onesignal:OneSignal:[3.6.0, 3.99.99]'
}

WakefulBroadcastReceiver is deprecated in Android O -
"It is generally not safe to start a service from the receipt of a broadcast, because you don't have any guarantees that your app is in the foreground at this point and thus allowed to do so."
You might need to check https://developer.android.com/preview/behavior-changes.html#back-all

Related

Kotlin Multiplatform + Sentry

I want to use Sentry for my Multiplatform Kotlin project.
Sentry for Kotlin Multiplatform
So I was trying to prepare the setup of Sentry with Kotlin Multiplatform.
I was following the guide, made a mavenLocal() build etc.
Now I wanted to add it to the project.
However, when starting my (Android) project, even before starting the onCreate() of the Application I get a crash stating:
Unable to get provider io.sentry.android.core.SentryInitProvider:
java.lang.IllegalArgumentException: DSN is required. Use empty string to disable SDK.
So to be clear this happens already when adding api("io.sentry:sentry-kotlin-multiplatform:0.0.1") to the dependencies. Long before the init call.
All I did was:
Configure shared build.gradle.kts and add
val commonMain by getting {
dependencies {
api("io.sentry:sentry-kotlin-multiplatform:0.0.1")
Adding the sample configuration
fun initializeSentry(context: Context) {
Sentry.init(context) { sentryOptions -> setDsnHere... }
}
and in the Android Application:
initializeSentry(this)
Then tried to run it. But I don't even get to the init call.
The configuration should be reached and the initializeSentry(this) block executed. (I can accept if it fails there but I don't even get that far.)
Instead the app fails stating
E/AndroidRuntime: FATAL EXCEPTION: main
Process: xyz, PID: 23056
java.lang.RuntimeException: Unable to get provider io.sentry.android.core.SentryInitProvider: java.lang.IllegalArgumentException: DSN is required. Use empty string to disable SDK.
at android.app.ActivityThread.installProvider(ActivityThread.java:7467)
...
even before anything else.
So the mere adding to the gradle file causes the crash already (even if the other code is commented out).
-------- Full Stack trace-------
java.lang.RuntimeException: Unable to get provider io.sentry.android.core.SentryInitProvider: java.lang.IllegalArgumentException: DSN is required. Use empty string to disable SDK.
at android.app.ActivityThread.installProvider(ActivityThread.java:7467)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:6973)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6744)
at android.app.ActivityThread.-$$Nest$mhandleBindApplication(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2133)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.app.ActivityThread.main(ActivityThread.java:7872)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
Caused by: java.lang.IllegalArgumentException: DSN is required. Use empty string to disable SDK.
at io.sentry.Sentry.initConfigurations(Sentry.java:201)
at io.sentry.Sentry.init(Sentry.java:170)
at io.sentry.Sentry.init(Sentry.java:118)
at io.sentry.android.core.SentryAndroid.init(SentryAndroid.java:87)
at io.sentry.android.core.SentryAndroid.init(SentryAndroid.java:56)
at io.sentry.android.core.SentryInitProvider.onCreate(SentryInitProvider.java:27)
at android.content.ContentProvider.attachInfo(ContentProvider.java:2451)
at android.content.ContentProvider.attachInfo(ContentProvider.java:2421)
at io.sentry.android.core.SentryInitProvider.attachInfo(SentryInitProvider.java:44)
at android.app.ActivityThread.installProvider(ActivityThread.java:7462)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:6973) 
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6744) 
at android.app.ActivityThread.-$$Nest$mhandleBindApplication(Unknown Source:0) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2133) 
at android.os.Handler.dispatchMessage(Handler.java:106) 
at android.os.Looper.loopOnce(Looper.java:201) 
at android.os.Looper.loop(Looper.java:288) 
at android.app.ActivityThread.main(ActivityThread.java:7872) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936) 
Turns out the manual had forgotten to mention the auto configuration.
Add this line to your Manifest:
<meta-data android:name="io.sentry.auto-init" android:value="false" />
and proceed with the tutorial.
For Reference:
https://github.com/getsentry/sentry-kotlin-multiplatform/issues/45

java.lang.RuntimeException:Illegal meta data value: the child service doesn't exist

The crash occurs on Samsung Galaxy J6+, S7, S8+ and Note9. Android 8 and 9.
implementation 'androidx.appcompat:appcompat:1.1.0-rc01'
implementation 'com.google.android.gms:play-services-ads:18.1.0'
Stack trace
Fatal Exception: java.lang.RuntimeException: Illegal meta data value: the child service doesn't exist
at nF0.a(nF0.java:3)
at nF0.a(nF0.java:8)
at org.chromium.content.browser.ChildProcessLauncherHelperImpl.a(ChildProcessLauncherHelperImpl.java:37)
at mq2.run(mq2.java:5)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:164)
at android.os.HandlerThread.run(HandlerThread.java:65)
Are you using CSJ_AD SDK? it comes from ByteDance. I encountered a similar problem when the device was reboot, i modified the CSJ_AD initialization timing to avoid this problem.

Android libraries not exact version?

so i'm making an app which can upload an image to the server, the web service is good and running and tested with postman.
on The application side, when i tried to add the implementation of the upload service 3.4.2 it's showing me an error, and the app is crashing at the moment of the upload.
here is a screenshot i'm new and not allowed to add pictures,https://i.stack.imgur.com/s3s8x.png
i need fast help please.
here is the run error:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.simou.myapplication, PID: 5205
java.lang.RuntimeException: Unable to start service net.gotev.uploadservice.UploadService#c425f01 with Intent { act=net.gotev.uploadservice.action.upload cmp=com.simou.myapplication/net.gotev.uploadservice.UploadService (has extras) }: java.lang.IllegalArgumentException: Hey dude, please set the namespace for your app by following the setup instructions: https://github.com/gotev/android-upload-service/wiki/Setup
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3314)
at android.app.ActivityThread.-wrap21(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1565)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
Caused by: java.lang.IllegalArgumentException: Hey dude, please set the namespace for your app by following the setup instructions: https://github.com/gotev/android-upload-service/wiki/Setup
at net.gotev.uploadservice.UploadService.onStartCommand(UploadService.java:257)
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3297)
As mentioned in the error you need to set the namespace for your application as privided the library's wiki
public class Initializer extends Application {
#Override
public void onCreate() {
super.onCreate();
// setup the broadcast action namespace string which will
// be used to notify upload status.
// Gradle automatically generates proper variable as below.
UploadService.NAMESPACE = BuildConfig.APPLICATION_ID;
// Or, you can define it manually.
UploadService.NAMESPACE = "com.yourcompany.yourapp";
}
}
and register it to your manifest
<application
android:name=".Initializer"
...
>

how to solve this firebase IllegalStateException when use goolge analytics

Projects
dependencies {
classpath 'com.google.gms:google-services:3.0.0'
}
Module
dependencies {
compile 'com.google.android.gms:play-services-analytics:10.0.0'
}
It just happened in 8.0 system, but i haven't used any firebase code in my project
Fatal Exception: java.lang.IllegalStateException: Not allowed to start service Intent { act=com.google.android.c2dm.intent.REGISTER pkg=com.google.android.gsf (has extras) }: app is in background uid UidRecord{e2ab7c6 u0a30 CEM idle procs:1 seq(0,0,0)}
at android.app.ContextImpl.startServiceCommon(ContextImpl.java:1538)
at android.app.ContextImpl.startService(ContextImpl.java:1484)
at android.content.ContextWrapper.startService(ContextWrapper.java:663)
at com.google.firebase.iid.zzf.zzbi(Unknown Source:149)
at com.google.firebase.iid.zzf.zzbi(Unknown Source:235)
at com.google.firebase.iid.zzf.zzt(Unknown Source:20)
at com.google.firebase.iid.zzf.zzbi(Unknown Source)
at com.google.firebase.iid.zzd.zzGu(Unknown Source:57)
at com.google.firebase.iid.zzd.getCreationTime(Unknown Source:49)
at com.google.firebase.iid.FirebaseInstanceId.getInstance(Unknown Source:3)
at com.google.firebase.iid.FirebaseInstanceId.zzaae(Unknown Source:4)
at com.google.firebase.iid.FirebaseInstanceIdService.zzH(Unknown Source:37)
at com.google.firebase.iid.FirebaseInstanceIdService.zzm(Unknown Source:35)
at com.google.firebase.iid.zzb$2.run(Unknown Source:4)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
at java.lang.Thread.run(Thread.java:764)
I can't remove firebase from my project, is there other ways to solve this problem?
Fabric report
You should first try on the main menu, choose File | Invalidate Caches/Restart. this can happen if Android studio gets in a bad state.
It should also be noted that firebase is probably in play-services-analytics. Ever since google bought them out they have put firebase in many of their google play services libraries.

Application crashing on some devices because "Default FirebaseApp is not initialized in this process"

I am using Firebase Crash Reporting and Firebase Remote Config. Version of both is 9.8.0.
On most devices setup works perfectly (I followed Set up crash reporting). But on small percentage of devices (it is actually crash with the highest occurrence) it crashes when I try to initialize Remote Config in Application onCreate method.
java.lang.RuntimeException: Unable to create application com.company.application.AppApplication: java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process com.company.application. Make sure to call FirebaseApp.initializeApp(Context) first.
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6429)
at android.app.ActivityThread.access$1800(ActivityThread.java:229)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1887)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:7329)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Caused by: java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process com.company.application. Make sure to call FirebaseApp.initializeApp(Context) first.
at com.google.firebase.a.d(Unknown Source)
at com.google.firebase.b.a.a(Unknown Source)
at com.company.application.d.a.a(SourceFile:21)
at com.company.application.AppApplication.onCreate(SourceFile:76)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1037)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6426)
... 8 more
Prior to version 10.0.0, Firebase Crash created an additional process in your app named background_crash. An instance of your AppApplication class is created and executed for each process in your app, including background_crash.
If you want to perform initialization of Firebase services in your application class, you need to add a guard to prevent the initialization from being performed in background_crash. On way to do that is:
if (!FirebaseApp.getApps(this).isEmpty()) {
// Not in crash process. Do your Remote Config init here.
}
Another solution is to upgrade to the latest version of Firebase, 10.0.1.
Assuming this answer is valid, I can't explain why the failure only occurs on some devices, unless the version of Google Play Services installed on the device is a factor, and the failing devices have an older version.
set classpath 'com.google.gms:google-services:4.0.1' in dependencies.
Implement the androidTestImplementation dependencies :
androidTestImplementation('com.android.support.test.espresso:espresso-core:.2.2',
{
exclude group: 'com.android.support', module: 'support-annotations'
})

Categories

Resources