使用 Android O 启动时 Onesignal 崩溃
Onesignal crash on boot with Android O
使用 Android 0(在我的例子中是 DP4)和 3.5.8 版本的 SDK,我在每次启动设备时都会崩溃。
崩溃如下:
原因:
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)
此崩溃与 Android O / 8.0 有关。
WakefulBroadcastReceiver 在 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."
您可能需要检查 https://developer.android.com/preview/behavior-changes.html#back-all
中被问到
@jkasten2 回答:
// 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'
他还提到:
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.
尽管@Swati 解决了核心问题。
更新:
OneSignal 团队已关闭票证,以下是修复(在 one signal documentation 中更新):
dependencies {
compile 'com.onesignal:OneSignal:[3.6.0, 3.99.99]'
}
使用 Android 0(在我的例子中是 DP4)和 3.5.8 版本的 SDK,我在每次启动设备时都会崩溃。
崩溃如下:
原因:
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)
此崩溃与 Android O / 8.0 有关。
WakefulBroadcastReceiver 在 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."
您可能需要检查 https://developer.android.com/preview/behavior-changes.html#back-all
@jkasten2 回答:
// 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'
他还提到:
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.
尽管@Swati 解决了核心问题。
更新:
OneSignal 团队已关闭票证,以下是修复(在 one signal documentation 中更新):
dependencies {
compile 'com.onesignal:OneSignal:[3.6.0, 3.99.99]'
}