firebase-android-sdk: Firebase Internal Foreign key constraint error
When enable foreign key constraint in our app using :
//https://stackoverflow.com/a/12531927/693752
db.setForeignKeyConstraintsEnabled(true);
we see an internal error in the logcat coming from an internal database schema definition from firebase:
04-16 21:34:57.852 6738 8269 E SQLiteDatabase: Error inserting period=0 target_class=com.firebase.jobdispatcher.GooglePlayReceiver required_network_type=0 runtime=1555450497848 extras={"com.firebase.jobdispatcher.tag":{"com.company.REGISTER":4},"com.firebase.jobdispatcher.trigger_type":{"1":0},"com.firebase.jobdispatcher.replace_current":{"true":3},"com.firebase.jobdispatcher.persistent":{"2":0},"registration_id":{"dIu14E5WNzw:APA91bEheSYPxZM5T_wHaiFcP_EZTHqEuVU0GWT58D-1wlrjUhMzmbrmyeWTjUfLy3zBCqJrf7mwASZlBFqkqdlNMs7hsRh2WPJwa4I4eLrJeAkzZMYZGIZ-fccj4C8zLRbSEDbuMlvu":4},"com.firebase.jobdispatcher.maximum_backoff_seconds":{"3600":0},"com.firebase.jobdispatcher.initial_backoff_seconds":{"30":0},"com.firebase.jobdispatcher.retry_policy":{"1":0},"com.firebase.jobdispatcher.window_end":{"0":0},"com.firebase.jobdispatcher.service":{"com.company.SomeService":4},"com.firebase.jobdispatcher.recurring":{"false":3},"com.firebase.jobdispatcher.constraints":{"2":0},"com.firebase.jobdispatcher.window_start":{"0":0}} source=8 target_package=com.company.dev source_version=1 last_runtime=0 user_id=0 job_id=-1 requires_charging=0 tag=com.company.REGISTER flex_time=0 task_type=0 retry_strategy={"maximum_backoff_seconds":{"3600":0},"initial_backoff_seconds":{"30":0},"retry_policy":{"0":0}}
04-16 21:34:57.852 6738 8269 E SQLiteDatabase: android.database.sqlite.SQLiteConstraintException: UNIQUE constraint failed: pending_ops.tag, pending_ops.target_class, pending_ops.target_package, pending_ops.user_id (code 2067)
04-16 21:34:57.852 6738 8269 E SQLiteDatabase: at android.database.sqlite.SQLiteConnection.nativeExecuteForLastInsertedRowId(Native Method)
04-16 21:34:57.852 6738 8269 E SQLiteDatabase: at android.database.sqlite.SQLiteConnection.executeForLastInsertedRowId(SQLiteConnection.java:782)
04-16 21:34:57.852 6738 8269 E SQLiteDatabase: at android.database.sqlite.SQLiteSession.executeForLastInsertedRowId(SQLiteSession.java:788)
04-16 21:34:57.852 6738 8269 E SQLiteDatabase: at android.database.sqlite.SQLiteStatement.executeInsert(SQLiteStatement.java:86)
04-16 21:34:57.852 6738 8269 E SQLiteDatabase: at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1474)
04-16 21:34:57.852 6738 8269 E SQLiteDatabase: at android.database.sqlite.SQLiteDatabase.insert(SQLiteDatabase.java:1343)
04-16 21:34:57.852 6738 8269 E SQLiteDatabase: at zxx.a(:com.google.android.gms@16089022@16.0.89 (040700-239467275):148)
04-16 21:34:57.852 6738 8269 E SQLiteDatabase: at aaat.a(:com.google.android.gms@16089022@16.0.89 (040700-239467275):166)
04-16 21:34:57.852 6738 8269 E SQLiteDatabase: at aaat.a(:com.google.android.gms@16089022@16.0.89 (040700-239467275):8)
04-16 21:34:57.852 6738 8269 E SQLiteDatabase: at aaat.a(:com.google.android.gms@16089022@16.0.89 (040700-239467275):157)
04-16 21:34:57.852 6738 8269 E SQLiteDatabase: at zxu.run(:com.google.android.gms@16089022@16.0.89 (040700-239467275):2)
04-16 21:34:57.852 6738 8269 E SQLiteDatabase: at rrt.b(:com.google.android.gms@16089022@16.0.89 (040700-239467275):32)
04-16 21:34:57.852 6738 8269 E SQLiteDatabase: at rrt.run(:com.google.android.gms@16089022@16.0.89 (040700-239467275):21)
04-16 21:34:57.852 6738 8269 E SQLiteDatabase: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
04-16 21:34:57.852 6738 8269 E SQLiteDatabase: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
04-16 21:34:57.852 6738 8269 E SQLiteDatabase: at rxx.run(Unknown Source:7)
04-16 21:34:57.852 6738 8269 E SQLiteDatabase: at java.lang.Thread.run(Thread.java:764)
About this issue
- Original URL
- State: open
- Created 5 years ago
- Reactions: 41
- Comments: 114 (17 by maintainers)
2021 any clue on how to solve this problem?
Folks, Just wanted to leave an update here that we’ve fixed this issue internally. Thanks for your patience. Since it requires an update to play services, I’m holding off from giving you a timeline for when this will roll out. But, this would require no action/SDK upgrades from developers and should get fixed on your customer devices automatically. Thanks again for your patience. 🙇♂️
I have the same issue:
android.database.sqlite.SQLiteConstraintException: UNIQUE constraint failed: pending_ops.tag, pending_ops.target_class, pending_ops.target_package, pending_ops.user_id (code 2067 SQLITE_CONSTRAINT_UNIQUE)
not calling any db methods or even using SqlLite ourselves. Probably another package enabling constraints…which kind of points to poor DB design IMPO.
which, after searching led me here because of “pending_ops” schema hit on this search result.
relevant stack line:
at sob.run(:com.google.android.gms@201516037@20.15.16 (120400-309763488):7)
other info:
is it firebase? /shrug
UPDATE:
here’s the whole stack trace
2023 any clue on how to solve this problem?
Hello @schmidt-sebastian, it’s been a while since this bug’s been active. We’ve got a productive application which we cannot obfuscate while using Firebase because of it. Has there been any advances on releasing a new Play Services version which fixes it? Thanks.
Joke: we need a crash repost app(mother of the crashes) for Crashlytics crashes
Still seeing this. Has this been resolved somehow?
I use only Firebase Messaging and Analytics:
Same error when I get notification from Firebase Messaging
I have the same problem, but after adding the following setting to AndroidManifest.xml to prevent firebase-analytics and cloud-message for auto initialization, it seems to resolve the problem
It seems the problem is related with the firebase-analytics automatically generate the instance ID things. Although I am not 100% sure for the root cause.
Firebase Prevent auto initialization
It doesn’t seem like this was ever fixed in a Play Services update. Since we need to be migrated from Fabric to Firebase for the Crashlytics plugin by the 15th, I looked into this again today. The problem still persists; the SQL exceptions occur AND a native crash occurs if Crashlytics is present in the app. This occurs on on first app boot both for new installs and existing upgrades.
I was able to get around the crash by upgrading the Crashlytics plugin from
17.1.0
to17.2.2
.how to fix?
Same problem
android.database.sqlite.SQLiteConstraintException: UNIQUE constraint failed: pending_ops.tag, pending_ops.target_class, pending_ops.target_package, pending_ops.user_id (code 2067 SQLITE_CONSTRAINT_UNIQUE) 09-01 10:19:29.885 2431 13904 E SQLiteDatabase: at android.database.sqlite.SQLiteConnection.nativeExecuteForLastInsertedRowId(Native Method) 09-01 10:19:29.885 2431 13904 E SQLiteDatabase: at android.database.sqlite.SQLiteConnection.executeForLastInsertedRowId(SQLiteConnection.java:879) 09-01 10:19:29.885 2431 13904 E SQLiteDatabase: at android.database.sqlite.SQLiteSession.executeForLastInsertedRowId(SQLiteSession.java:790) 09-01 10:19:29.885 2431 13904 E SQLiteDatabase: at android.database.sqlite.SQLiteStatement.executeInsert(SQLiteStatement.java:88) 09-01 10:19:29.885 2431 13904 E SQLiteDatabase: at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1599) 09-01 10:19:29.885 2431 13904 E SQLiteDatabase: at android.database.sqlite.SQLiteDatabase.insert(SQLiteDatabase.java:1468) 09-01 10:19:29.885 2431 13904 E SQLiteDatabase: at arlu.a(:com.google.android.gms@203019037@20.30.19 (120400-326531024):122) 09-01 10:19:29.885 2431 13904 E SQLiteDatabase: at arkr.a(:com.google.android.gms@203019037@20.30.19 (120400-326531024):183) 09-01 10:19:29.885 2431 13904 E SQLiteDatabase: at arkr.a(:com.google.android.gms@203019037@20.30.19 (120400-326531024):22) 09-01 10:19:29.885 2431 13904 E SQLiteDatabase: at arkr.a(:com.google.android.gms@203019037@20.30.19 (120400-326531024):178) 09-01 10:19:29.885 2431 13904 E SQLiteDatabase: at argu.run(:com.google.android.gms@203019037@20.30.19 (120400-326531024):9) 09-01 10:19:29.885 2431 13904 E SQLiteDatabase: at stf.b(:com.google.android.gms@203019037@20.30.19 (120400-326531024):12) 09-01 10:19:29.885 2431 13904 E SQLiteDatabase: at stf.run(:com.google.android.gms@203019037@20.30.19 (120400-326531024):7) 09-01 10:19:29.885 2431 13904 E SQLiteDatabase: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) 09-01 10:19:29.885 2431 13904 E SQLiteDatabase: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) 09-01 10:19:29.885 2431 13904 E SQLiteDatabase: at szg.run(:com.google.android.gms@203019037@20.30.19 (120400-326531024):0)
We were having a similar error:
But realised the
play-services-ads-identifier
lib wasn’t being packaged, when we ensured that dependency was included the errors have disappeared.We are seeing this error too. Here’s our logs:
It happens everytime our app sends an Analytic or Crashlytics (through Firebase Analytics or Crashlytics). The app does not crash, however. Analytics dashboard works fine (every thing seems work fine) but we get an Exception everytime we send an Analytic.
I tried deleting our old SQL dependencies on our project, and didn’t care, error stills there. We are using Unity and these are our dependencies:
implementation ‘com.android.support:appcompat-v7:25.3.1’ implementation ‘com.android.support:cardview-v7:25.3.1’ implementation ‘com.android.support:customtabs:25.3.1’ implementation ‘com.android.support:support-v4:25.3.1’ implementation ‘com.crashlytics.sdk.android:crashlytics:2.9.9’ implementation ‘com.facebook.android:facebook-applinks:[5,6)’ implementation ‘com.facebook.android:facebook-core:[5,6)’ implementation ‘com.facebook.android:facebook-login:[5,6)’ implementation ‘com.facebook.android:facebook-share:[5,6)’ implementation ‘com.google.ads.mediation:applovin:9.9.1.0’ implementation ‘com.google.ads.mediation:facebook:5.6.0.0’ implementation ‘com.google.ads.mediation:ironsource:6.10.0.0’ implementation ‘com.google.ads.mediation:unity:3.3.0.0’ implementation ‘com.google.android.gms:play-services-ads:18.3.0’ implementation ‘com.google.firebase:firebase-analytics:17.2.1’ implementation ‘com.google.firebase:firebase-analytics-unity:6.8.1’ implementation ‘com.google.firebase:firebase-app-unity:6.8.1’ implementation ‘com.google.firebase:firebase-common:19.3.0’ implementation ‘com.google.firebase:firebase-config:19.0.3’ implementation ‘com.google.firebase:firebase-config-unity:6.8.1’ implementation ‘com.google.firebase:firebase-crashlytics-unity:6.8.1’ implementation ‘com.parse.bolts:bolts-android:1.4.0’
Confirmed that the SQLIte version being used is from API 29. Only get this error on a device, not in emulators. Also, it happens on every transition to a new intent/activity.
The error “Package unavailable for task: com.google.android.apps.plus/com.firebase.jobdispatcher.GooglePlayReceiver…” also appears right before the crash. JobDispatcher is deprecated, and not used by anything in our code or dependencies from what I can find. All of our dependencies are the latest version, but something is still puling it in.
Any ideas are appreciated, I’m not sure what else to try.
I am also facing this crash issue:
E/SQLiteDatabase: Error inserting flex_time=3340000 job_id=-1 period=6682000 source=16 requires_charging=0 preferred_network_type=1 target_class=com.google.android.gms.measurement.PackageMeasurementTaskService user_id=0 target_package=com.google.android.gms tag=Measurement.PackageMeasurementTaskService.UPLOAD_TASK_TAG task_type=0 required_idleness_state=0 service_kind=0 source_version=201817000 persistence_level=1 preferred_charging_state=1 required_network_type=0 runtime=1590520619376 retry_strategy={“maximum_backoff_seconds”:{“3600”:0},“initial_backoff_seconds”:{“30”:0},“retry_policy”:{“0”:0}} last_runtime=0 from {P:25120;U:10021} android.database.sqlite.SQLiteConstraintException: UNIQUE constraint failed: pending_ops.tag, pending_ops.target_class, pending_ops.target_package, pending_ops.user_id (code 2067 SQLITE_CONSTRAINT_UNIQUE) at android.database.sqlite.SQLiteConnection.nativeExecuteForLastInsertedRowId(Native Method) at android.database.sqlite.SQLiteConnection.executeForLastInsertedRowId(SQLiteConnection.java:879) at android.database.sqlite.SQLiteSession.executeForLastInsertedRowId(SQLiteSession.java:790) at android.database.sqlite.SQLiteStatement.executeInsert(SQLiteStatement.java:88) at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1639) at android.database.sqlite.SQLiteDatabase.insert(SQLiteDatabase.java:1494) at apiz.a(:com.google.android.gms@201817037@20.18.17 (120400-311416286):78) at apio.a(:com.google.android.gms@201817037@20.18.17 (120400-311416286):196) at apio.a(:com.google.android.gms@201817037@20.18.17 (120400-311416286):20) at apio.a(:com.google.android.gms@201817037@20.18.17 (120400-311416286):190) at apex.run(:com.google.android.gms@201817037@20.18.17 (120400-311416286):8) at sfd.b(:com.google.android.gms@201817037@20.18.17 (120400-311416286):12) at sfd.run(:com.google.android.gms@201817037@20.18.17 (120400-311416286):7) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) at sld.run(:com.google.android.gms@201817037@20.18.17 (120400-311416286):0) at java.lang.Thread.run(Thread.java:919)
Also getting this crash multiple times : https://github.com/firebase/firebase-android-sdk/issues/1593
I am having the same error, and it does not allow me to start the app.
If I remove the Crashlytics depedency, then it stops crashing and everything seems to work as normal, but of course I will not get crash reporting.
My dependencies:
UPDATE: If I remove crashlytics, the log error is still there, but the application does not crash. So, somehow I think the error itself is not triggered by crashlytics, but the crash is. Maybe incorrectly handling the exception?
Same error with my Unity-based App. Seems to happen every time we switch to another Android activity:
in my case: the bug has fixed by put
<uses-permission android:name="android.permission.GET_TASKS" />
in manifestHave anyone solved this issue?
Same error
10-23 17:37:11.096 1244 8320 E SQLiteDatabase: Error inserting flex_time=3442000 job_id=-1 period=6885000 source=16 requires_charging=0 preferred_network_type=1 target_class=com.google.android.gms.measurement.PackageMeasurementTaskService user_id=0 target_package=com.google.android.gms tag=Measurement.PackageMeasurementTaskService.UPLOAD_TASK_TAG task_type=0 required_idleness_state=0 service_kind=0 source_version=201817000 preferred_charging_state=1 required_network_type=0 runtime=1603449431063 retry_strategy={“maximum_backoff_seconds”:{“3600”:0},“initial_backoff_seconds”:{“30”:0},“retry_policy”:{“0”:0}} last_runtime=0 10-23 17:37:11.096 1244 8320 E SQLiteDatabase: android.database.sqlite.SQLiteConstraintException: UNIQUE constraint failed: pending_ops.tag, pending_ops.target_class, pending_ops.target_package, pending_ops.user_id (code 2067 SQLITE_CONSTRAINT_UNIQUE) 10-23 17:37:11.096 1244 8320 E SQLiteDatabase: at android.database.sqlite.SQLiteConnection.nativeExecuteForLastInsertedRowId(Native Method) 10-23 17:37:11.096 1244 8320 E SQLiteDatabase: at android.database.sqlite.SQLiteConnection.executeForLastInsertedRowId(SQLiteConnection.java:938) 10-23 17:37:11.096 1244 8320 E SQLiteDatabase: at android.database.sqlite.SQLiteSession.executeForLastInsertedRowId(SQLiteSession.java:790) 10-23 17:37:11.096 1244 8320 E SQLiteDatabase: at android.database.sqlite.SQLiteStatement.executeInsert(SQLiteStatement.java:88) 10-23 17:37:11.096 1244 8320 E SQLiteDatabase: at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1701) 10-23 17:37:11.096 1244 8320 E SQLiteDatabase: at android.database.sqlite.SQLiteDatabase.insert(SQLiteDatabase.java:1570) 10-23 17:37:11.096 1244 8320 E SQLiteDatabase: at apla.a(:com.google.android.gms@201817022@20.18.17 (040700-311416286):78) 10-23 17:37:11.096 1244 8320 E SQLiteDatabase: at apkp.a(:com.google.android.gms@201817022@20.18.17 (040700-311416286):196) 10-23 17:37:11.096 1244 8320 E SQLiteDatabase: at apkp.a(:com.google.android.gms@201817022@20.18.17 (040700-311416286):20) 10-23 17:37:11.096 1244 8320 E SQLiteDatabase: at apkp.a(:com.google.android.gms@201817022@20.18.17 (040700-311416286):190) 10-23 17:37:11.096 1244 8320 E SQLiteDatabase: at apgy.run(:com.google.android.gms@201817022@20.18.17 (040700-311416286):8) 10-23 17:37:11.096 1244 8320 E SQLiteDatabase: at sji.b(:com.google.android.gms@201817022@20.18.17 (040700-311416286):12) 10-23 17:37:11.096 1244 8320 E SQLiteDatabase: at sji.run(:com.google.android.gms@201817022@20.18.17 (040700-311416286):7) 10-23 17:37:11.096 1244 8320 E SQLiteDatabase: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) 10-23 17:37:11.096 1244 8320 E SQLiteDatabase: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) 10-23 17:37:11.096 1244 8320 E SQLiteDatabase: at spj.run(:com.google.android.gms@201817022@20.18.17 (040700-311416286):0) 10-23 17:37:11.096 1244 8320 E SQLiteDatabase: at java.lang.Thread.run(Thread.java:923) 10-23 17:37:11.096 311 311 D goldfish-address-space: allocate: Ask for block of size 0xfa0000
Subscribing to updates
Same issue here:
i think if fix pro guard rules might fix https://developer.android.com/studio/build/shrink-code#native-crash-support, thats in my case , i will try an post result
Subscribing to updates Having same issue.
Facing the same error
Similar reported issue: https://github.com/firebase/quickstart-unity/issues/676
The origin might not be related to crashlytics directly, but it is the fact that crashlytics is added to the project what makes it crash, so there is some wrong handling within the lib. If I get rid of Crashlytics dependency, then the crash disappear.
In my case it’s not a “real crash”. App still works, but I can see the same stack trace in the adb logs.
Ok there’s some crash going on that looks similar to some old GitHub issues I’ve found: https://github.com/googlearchive/firebase-jobdispatcher-android/issues/94 https://github.com/evernote/android-job/issues/87
Some internal bugs which may be related (for Googlers); https://b.corp.google.com/issues/156170585 https://b.corp.google.com/issues/149327697 https://b.corp.google.com/issues/146422649
I can’t find the pattern here except that is has something to do with concurrency and job scheduling. Here’s a random guess: I assume Crashlytics uses a second process to report crashes (otherwise it would be taken down by them) and maybe that process is not acquiring the right locks before trying to schedule the upload jobs?
Would need someone from the Crashlytics team to comment on what sort of Job scheduling it uses.