java.lang.RuntimeException: An error occured while executing doInBackground()

tip

activity.OnCreate is executed every time the app launches or the screen is rotated, so, putting your DB initialization inside it will cause the DB to be called too many times causing the exception. Try to use the MyDatabase.onCreate method for this.

You have a different solution? A short tip here would help you and many other users who saw this issue last week.

  • bug on push
    via GitHub by idelcano
    ,
  • Create daily crashes the app
    via GitHub by franzejr
    ,
  • Crash - Saving Daily
    via GitHub by negue
    ,
  • GitHub comment 57#157201848
    via GitHub by franzejr
    ,
    • java.lang.RuntimeException: An error occured while executing doInBackground() at android.os.AsyncTask$3.done(AsyncTask.java:299) at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:352) at java.util.concurrent.FutureTask.setException(FutureTask.java:219) at java.util.concurrent.FutureTask.run(FutureTask.java:239) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573) at java.lang.Thread.run(Thread.java:856) Caused by: android.database.sqlite.SQLiteConstraintException: column event is not unique (code 19) at android.database.sqlite.SQLiteConnection.nativeExecuteForLastInsertedRowId(Native Method) at android.database.sqlite.SQLiteConnection.executeForLastInsertedRowId(SQLiteConnection.java:775) at android.database.sqlite.SQLiteSession.executeForLastInsertedRowId(SQLiteSession.java:788) at android.database.sqlite.SQLiteStatement.executeInsert(SQLiteStatement.java:86) at com.raizlabs.android.dbflow.sql.SqlUtils.insert(SqlUtils.java:314) at com.raizlabs.android.dbflow.sql.SqlUtils.save(SqlUtils.java:268) at com.raizlabs.android.dbflow.structure.ModelAdapter.save(ModelAdapter.java:54) at com.raizlabs.android.dbflow.structure.BaseModel.save(BaseModel.java:50) at org.hisp.dhis.android.sdk.persistence.models.Event.save(Event.java:184) at org.hisp.dhis.android.sdk.controllers.tracker.TrackerDataSender.postEvent(TrackerDataSender.java:140) at org.hisp.dhis.android.sdk.controllers.tracker.TrackerDataSender.sendEventChanges(TrackerDataSender.java:119) at org.hisp.dhis.android.sdk.controllers.tracker.TrackerDataSender.sendEventChanges(TrackerDataSender.java:104) at org.hisp.dhis.android.sdk.controllers.tracker.TrackerDataSender.sendEventChanges(TrackerDataSender.java:84) at org.hisp.dhis.android.sdk.controllers.tracker.TrackerController.sendEventChanges(TrackerController.java:445) at org.hisp.dhis.android.sdk.controllers.DhisController.sendEventChanges(DhisController.java:136) at org.hisp.dhis.android.sdk.controllers.DhisService$13.execute(DhisService.java:238) at org.hisp.dhis.android.sdk.controllers.DhisService$13.execute(DhisService.java:235) at org.hisp.dhis.android.sdk.job.NetworkJob.inBackground(NetworkJob.java:51) at org.hisp.dhis.android.sdk.job.NetworkJob.inBackground(NetworkJob.java:38) at org.hisp.dhis.android.sdk.job.Job.doInBackground(Job.java:60) at org.hisp.dhis.android.sdk.job.Job.doInBackground(Job.java:36)

    Users with the same issue

    Hiren Amaliyar
    Hiren Amaliyar1 times, last one,
    dealloc
    dealloc4 times, last one,
    bayukresno
    bayukresno617 times, last one,
    xavilo
    xavilo1 times, last one,
    jk
    jk2 times, last one,
    68 more bugmates