使用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有关。
答案 0 :(得分:2)
在Android O中弃用WakefulBroadcastReceiver -
“通过接收广播来启动服务通常是不安全的,因为您无法保证您的应用在此时处于前台,因此可以这样做。”
您可能需要查看https://developer.android.com/preview/behavior-changes.html#back-all
答案 1 :(得分:2)
@ 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'
他还提到:
根据其他人的反馈和我们自己的测试,测试版一直保持稳定。我们正在完成最后的测试,我们将在下周的某个时间拍摄。
虽然核心问题由@Swati解决。
<强>更新强>
OneSignal团队已关闭该票证,以下是修复(在one signal documentation中更新):
dependencies {
compile 'com.onesignal:OneSignal:[3.6.0, 3.99.99]'
}