2016-11-02 6 views
-3

Мне недавно пришлось приступить к проекту и исправить сбои. Катастрофа происходит на doInBackground и AsyncTask инициируется вызовом:Ошибка выполнения doInBackground(), вызванного sqlite.SQLiteException

public static void getCurrentUser(final UserDBInterface listener) { 
     new GetCurrentUserAsyncTask(listener).execute(); 
    } 

который вызывает AsyncTask.

public class GetCurrentUserAsyncTask extends AsyncTask<String, Void, User> { 
    private UserDBInterface listener; 

    public GetCurrentUserAsyncTask(final UserDBInterface listener) { 
     this.listener = listener; 
    } 

    protected User doInBackground(final String... strings) { 
     return DatabaseHelper.getCurrentUser(); 
    } 

    protected void onPostExecute(final User result) { 
     listener.onCurrentUserReady(result); 
    } 
} 

метод GetCurrentUser: Класс

public static User getCurrentUser() { 
    final TotemSharedPreferences totemSharedPreferences = new TotemSharedPreferences(); 
    final List<User> users = Select.from(User.class).where(DatabaseHelper.REMOTE_ID_LABEL + " = " + totemSharedPreferences.getUserId()).list(); 
    if (!users.isEmpty()) { 
     final User mUser = users.get(0); 
     mUser.setUserBadge(DatabaseHelper.getAllUserBadges(mUser.getUserId())); 
     mUser.setKudosReceived(DatabaseHelper.getAllUserReceivedKudos(mUser.getUserId())); 
     mUser.setTeam(DatabaseHelper.getTeam(mUser.getTeamId())); 
     mUser.setCompany(DatabaseHelper.getCompany()); 
     mUser.setStartedOn(new DateTime(mUser.getStartedOnString())); 
     mUser.setUserTeams(getAllUserTeams(mUser.getUserId())); 

     for (final UserTeam mUserTeam : mUser.getUserTeams()) 
      if (mUserTeam.getRemoteId() == mUser.getActiveUserTeamId()) 
       mUser.setKudosFund(mUserTeam.getKudosFund()); 

     return mUser; 
    } else 
     return totemSharedPreferences.getUser(); 
} 

Пользователя:

public class User extends SugarRecord { 

    @Column(name = "username") 
    @Expose 
    @SerializedName("username") 
    String mUsername; 

    @Column(name = "position") 
    @Expose 
    @SerializedName("position") 
    String mPosition; 

    @Column(name = "image_url") 
    @Expose 
    @SerializedName("image_url") 
    String mImageUrl; 

    @Column(name = "name") 
    @Expose 
    @SerializedName("name") 
    String mName; 

    @Ignore 
    String mPassword; 

    @Column(name = "remote_id", unique = true) 
    @Expose 
    @SerializedName("id") 
    int mUserId; 

    @Ignore 
    @Expose 
    @SerializedName("started_on") 
    DateTime mStartedOn; 

    @Column(name = "started_on") 
    private String startedOnString; 

    @Column(name = "company") 
    @Expose 
    @SerializedName("company") 
    Company mCompany; 

    @Column(name = "company_id") 
    @Expose 
    @SerializedName("company_id") 
    int mCompanyId; 

    @Column(name = "profile_id") 
    @Expose 
    @SerializedName("profile_id") 
    int mProfileId; 

    @Column(name = "team_id") 
    @Expose 
    @SerializedName("team_id") 
    int mTeamId; 

    @Column(name = "approved") 
    @Expose 
    @SerializedName("approved") 
    boolean mApproved; 

    @Column(name = "disabled") 
    @Expose 
    @SerializedName("disabled") 
    boolean mDisabled; 

    @Ignore 
    @Expose 
    @SerializedName("team") 
    Team mTeam; 

    @Ignore 
    @Expose 
    @SerializedName("user_teams") 
    List<UserTeam> mUserTeams; 

    @Column(name = "kudos_fund") 
    @Expose 
    @SerializedName("kudos_fund") 
    int mKudosFund; 

    @Ignore 
    @Expose 
    @SerializedName("kudos_received") 
    List<Kudos> mKudosReceived; 

    @Ignore 
    @Expose 
    @SerializedName("badges") 
    List<UserBadge> mUserBadge; 

    @Column(name = "active_user_team_id") 
    @Expose 
    @SerializedName("active_user_team_id") 
    int mActiveUserTeamId; 

    @Column(name = "kudos_received_total") 
    @Expose 
    @SerializedName("kudos_received_total") 
    int mKudosReceivedTotal; 

    public User() { 

    } 

    @Override 
    public long save() { 
     if (mStartedOn != null) 
      startedOnString = mStartedOn.toString(); 

     if (mUserTeams != null) 
      for (final UserTeam mUserTeam : mUserTeams) 
       if (mUserTeam.getRemoteId() == mActiveUserTeamId) 
        mKudosFund = mUserTeam.getKudosFund(); 
     return super.save(); 
    } 

    public String getStartedOnString() { 
     return startedOnString; 
    } 

} 

Я буквально только начал андроид развития - я разработчик IOS и не привыкла к AsyncTasks. Кто-нибудь знает основную причину проблемы? Это единственные журналы у меня есть:

#0. Crashed: AsyncTask #1: 0 0 0x0000000000000000 
     at android.os.AsyncTask$3.done(AsyncTask.java:300) 
     at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355) 
     at java.util.concurrent.FutureTask.setException(FutureTask.java:222) 
     at java.util.concurrent.FutureTask.run(FutureTask.java:242) 
     at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231) 
     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) 
     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) 
     at java.lang.Thread.run(Thread.java:818) 

-- 

Fatal Exception: java.lang.RuntimeException: An error occured while executing doInBackground() 
     at android.os.AsyncTask$3.done(AsyncTask.java:300) 
     at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355) 
     at java.util.concurrent.FutureTask.setException(FutureTask.java:222) 
     at java.util.concurrent.FutureTask.run(FutureTask.java:242) 
     at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231) 
     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) 
     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) 
     at java.lang.Thread.run(Thread.java:818) 
Caused by android.database.sqlite.SQLiteException: duplicate column name: users_count (code 1): , while compiling: alter table USER_TEAM add users_count INTEGER; 
     at android.database.sqlite.SQLiteConnection.nativePrepareStatement(SQLiteConnection.java) 
     at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:1093) 
     at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:670) 
     at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588) 
     at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:59) 
     at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:31) 
     at android.database.sqlite.SQLiteDatabase.executeSql(SQLiteDatabase.java:1798) 
     at android.database.sqlite.SQLiteDatabase.execSQL(SQLiteDatabase.java:1729) 
     at com.orm.SchemaGenerator.executeScript(SchemaGenerator.java:97) 
     at com.orm.SchemaGenerator.executeSugarUpgrade(SchemaGenerator.java:75) 
     at com.orm.SchemaGenerator.doUpgrade(SchemaGenerator.java:52) 
     at com.orm.SugarDb.onUpgrade(SugarDb.java:31) 
     at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:256) 
     at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:163) 
     at com.orm.SugarDb.getDB(SugarDb.java:36) 
     at com.orm.SugarRecord.find(SugarRecord.java:189) 
     at com.orm.query.Select.list(Select.java:118) 
     at com.playconsulting.totem.database.DatabaseHelper.getCurrentUser(DatabaseHelper.java:965) 
     at com.playconsulting.totem.database.asynctasks.GetCurrentUserAsyncTask.doInBackground(GetCurrentUserAsyncTask.java:21) 
     at com.playconsulting.totem.database.asynctasks.GetCurrentUserAsyncTask.doInBackground(GetCurrentUserAsyncTask.java:13) 
     at android.os.AsyncTask$2.call(AsyncTask.java:288) 
     at java.util.concurrent.FutureTask.run(FutureTask.java:237) 
     at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231) 
     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) 
     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) 
     at java.lang.Thread.run(Thread.java:818) 

#0. Crashed: AsyncTask #1: 0 0 0x0000000000000000 
     at android.os.AsyncTask$3.done(AsyncTask.java:300) 
     at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355) 
     at java.util.concurrent.FutureTask.setException(FutureTask.java:222) 
     at java.util.concurrent.FutureTask.run(FutureTask.java:242) 
     at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231) 
     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) 
     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) 
     at java.lang.Thread.run(Thread.java:818) 

#1. MarketingHandler 
     at android.os.MessageQueue.nativePollOnce(MessageQueue.java) 
     at android.os.MessageQueue.next(MessageQueue.java:143) 
     at android.os.Looper.loop(Looper.java:130) 
     at android.os.HandlerThread.run(HandlerThread.java:61) 

#2. ProfileHandler 
     at android.os.MessageQueue.nativePollOnce(MessageQueue.java) 
     at android.os.MessageQueue.next(MessageQueue.java:143) 
     at android.os.Looper.loop(Looper.java:130) 
     at android.os.HandlerThread.run(HandlerThread.java:61) 

#3. OkHttp https://api.totem.team/api/client/user 
     at org.joda.time.convert.StringConverter.<clinit>(StringConverter.java:44) 
     at org.joda.time.convert.ConverterManager.<init>(ConverterManager.java:107) 
     at org.joda.time.convert.ConverterManager.getInstance(ConverterManager.java:90) 
     at org.joda.time.base.BaseDateTime.<init>(BaseDateTime.java:171) 
     at org.joda.time.DateTime.<init>(DateTime.java:257) 
     at com.playconsulting.totem.rest.deserializers.DateTimeDeserializer.deserialize(DateTimeDeserializer.java:18) 
     at com.playconsulting.totem.rest.deserializers.DateTimeDeserializer.deserialize(DateTimeDeserializer.java:15) 
     at com.google.gson.TreeTypeAdapter.read(TreeTypeAdapter.java:58) 
     at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:117) 
     at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:217) 
     at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.read(TypeAdapterRuntimeTypeWrapper.java:40) 
     at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:82) 
     at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:61) 
     at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:117) 
     at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:217) 
     at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:117) 
     at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:217) 
     at com.google.gson.Gson.fromJson(Gson.java:861) 
     at com.google.gson.Gson.fromJson(Gson.java:826) 
     at retrofit.GsonResponseBodyConverter.convert(GsonResponseBodyConverter.java:36) 
     at retrofit.GsonResponseBodyConverter.convert(GsonResponseBodyConverter.java:24) 
     at retrofit.OkHttpCall.parseResponse(OkHttpCall.java:148) 
     at retrofit.OkHttpCall.access$100(OkHttpCall.java:29) 
     at retrofit.OkHttpCall$1.onResponse(OkHttpCall.java:94) 
     at com.squareup.okhttp.Call$AsyncCall.execute(Call.java:177) 
     at com.squareup.okhttp.internal.NamedRunnable.run(NamedRunnable.java:33) 
     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) 
     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) 
     at java.lang.Thread.run(Thread.java:818) 

#4. AsyncTask #3 
     at java.lang.Object.wait(Object.java) 
     at java.lang.Thread.parkFor(Thread.java:1220) 
     at sun.misc.Unsafe.park(Unsafe.java:299) 
     at java.util.concurrent.locks.LockSupport.park(LockSupport.java:157) 
     at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2016) 
     at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:410) 
     at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1035) 
     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1097) 
     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) 
     at java.lang.Thread.run(Thread.java:818) 

#5. DB_Thread 
     at android.os.MessageQueue.nativePollOnce(MessageQueue.java) 
     at android.os.MessageQueue.next(MessageQueue.java:143) 
     at android.os.Looper.loop(Looper.java:130) 
     at android.os.HandlerThread.run(HandlerThread.java:61) 

#6. HeapTrimmerDaemon 
     at dalvik.system.VMRuntime.trimHeap(VMRuntime.java) 
     at java.lang.Daemons$HeapTrimmerDaemon.run(Daemons.java:312) 
     at java.lang.Thread.run(Thread.java:818) 

#7. ReferenceQueueDaemon 
     at java.lang.Object.wait(Object.java) 
     at java.lang.Daemons$ReferenceQueueDaemon.run(Daemons.java:133) 
     at java.lang.Thread.run(Thread.java:818) 

#8. Queue 
     at java.lang.Object.wait(Object.java) 
     at java.lang.Thread.parkFor(Thread.java:1220) 
     at sun.misc.Unsafe.park(Unsafe.java:299) 
     at java.util.concurrent.locks.LockSupport.park(LockSupport.java:157) 
     at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2016) 
     at java.util.concurrent.PriorityBlockingQueue.take(PriorityBlockingQueue.java:510) 
     at io.fabric.sdk.android.services.concurrency.DependencyPriorityBlockingQueue.performOperation(DependencyPriorityBlockingQueue.java:197) 
     at io.fabric.sdk.android.services.concurrency.DependencyPriorityBlockingQueue.get(DependencyPriorityBlockingQueue.java:236) 
     at io.fabric.sdk.android.services.concurrency.DependencyPriorityBlockingQueue.take(DependencyPriorityBlockingQueue.java:65) 
     at io.fabric.sdk.android.services.concurrency.DependencyPriorityBlockingQueue.take(DependencyPriorityBlockingQueue.java:46) 
     at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1035) 
     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1097) 
     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) 
     at java.lang.Thread.run(Thread.java:818) 

#9. ManifestHandler 
     at android.os.MessageQueue.nativePollOnce(MessageQueue.java) 
     at android.os.MessageQueue.next(MessageQueue.java:143) 
     at android.os.Looper.loop(Looper.java:130) 
     at android.os.HandlerThread.run(HandlerThread.java:61) 

#10. main 
     at android.os.MessageQueue.nativePollOnce(MessageQueue.java) 
     at android.os.MessageQueue.next(MessageQueue.java:143) 
     at android.os.Looper.loop(Looper.java:130) 
     at android.app.ActivityThread.main(ActivityThread.java:5951) 
     at java.lang.reflect.Method.invoke(Method.java) 
     at java.lang.reflect.Method.invoke(Method.java:372) 
     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1400) 
     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1195) 

#11. Queue 
     at java.lang.Object.wait(Object.java) 
     at java.lang.Thread.parkFor(Thread.java:1220) 
     at sun.misc.Unsafe.park(Unsafe.java:299) 
     at java.util.concurrent.locks.LockSupport.park(LockSupport.java:157) 
     at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2016) 
     at java.util.concurrent.PriorityBlockingQueue.take(PriorityBlockingQueue.java:510) 
     at io.fabric.sdk.android.services.concurrency.DependencyPriorityBlockingQueue.performOperation(DependencyPriorityBlockingQueue.java:197) 
     at io.fabric.sdk.android.services.concurrency.DependencyPriorityBlockingQueue.get(DependencyPriorityBlockingQueue.java:236) 
     at io.fabric.sdk.android.services.concurrency.DependencyPriorityBlockingQueue.take(DependencyPriorityBlockingQueue.java:65) 
     at io.fabric.sdk.android.services.concurrency.DependencyPriorityBlockingQueue.take(DependencyPriorityBlockingQueue.java:46) 
     at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1035) 
     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1097) 
     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) 
     at java.lang.Thread.run(Thread.java:818) 

#12. Queue 
     at java.lang.Object.wait(Object.java) 
     at java.lang.Thread.parkFor(Thread.java:1220) 
     at sun.misc.Unsafe.park(Unsafe.java:299) 
     at java.util.concurrent.locks.LockSupport.park(LockSupport.java:157) 
     at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2016) 
     at java.util.concurrent.PriorityBlockingQueue.take(PriorityBlockingQueue.java:510) 
     at io.fabric.sdk.android.services.concurrency.DependencyPriorityBlockingQueue.performOperation(DependencyPriorityBlockingQueue.java:197) 
     at io.fabric.sdk.android.services.concurrency.DependencyPriorityBlockingQueue.get(DependencyPriorityBlockingQueue.java:236) 
     at io.fabric.sdk.android.services.concurrency.DependencyPriorityBlockingQueue.take(DependencyPriorityBlockingQueue.java:65) 
     at io.fabric.sdk.android.services.concurrency.DependencyPriorityBlockingQueue.take(DependencyPriorityBlockingQueue.java:46) 
     at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1035) 
     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1097) 
     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) 
     at java.lang.Thread.run(Thread.java:818) 

#13. AsyncTask #1 
     at java.lang.Object.wait(Object.java) 
     at java.lang.Thread.parkFor(Thread.java:1220) 
     at sun.misc.Unsafe.park(Unsafe.java:299) 
     at java.util.concurrent.locks.LockSupport.park(LockSupport.java:157) 
     at java.util.concurrent.FutureTask.awaitDone(FutureTask.java:400) 
     at java.util.concurrent.FutureTask.get(FutureTask.java:162) 
     at com.crashlytics.android.core.CrashlyticsExecutorServiceWrapper.executeSyncLoggingException(CrashlyticsExecutorServiceWrapper.java:47) 
     at com.crashlytics.android.core.CrashlyticsUncaughtExceptionHandler.uncaughtException(CrashlyticsUncaughtExceptionHandler.java:235) 
     at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:693) 
     at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:690) 

#14. Crashlytics Report Uploader 
     at java.lang.Thread.sleep(Thread.java) 
     at java.lang.Thread.sleep(Thread.java:1031) 
     at java.lang.Thread.sleep(Thread.java:985) 
     at com.crashlytics.android.core.ReportUploader$Worker.attemptUploadWithRetry(ReportUploader.java:146) 
     at com.crashlytics.android.core.ReportUploader$Worker.onRun(ReportUploader.java:131) 
     at io.fabric.sdk.android.services.common.BackgroundPriorityRunnable.run(BackgroundPriorityRunnable.java:30) 
     at java.lang.Thread.run(Thread.java:818) 

#15. Queue 
     at java.lang.Object.wait(Object.java) 
     at java.lang.Thread.parkFor(Thread.java:1220) 
     at sun.misc.Unsafe.park(Unsafe.java:299) 
     at java.util.concurrent.locks.LockSupport.park(LockSupport.java:157) 
     at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2016) 
     at java.util.concurrent.PriorityBlockingQueue.take(PriorityBlockingQueue.java:510) 
     at io.fabric.sdk.android.services.concurrency.DependencyPriorityBlockingQueue.performOperation(DependencyPriorityBlockingQueue.java:197) 
     at io.fabric.sdk.android.services.concurrency.DependencyPriorityBlockingQueue.get(DependencyPriorityBlockingQueue.java:236) 
     at io.fabric.sdk.android.services.concurrency.DependencyPriorityBlockingQueue.take(DependencyPriorityBlockingQueue.java:65) 
     at io.fabric.sdk.android.services.concurrency.DependencyPriorityBlockingQueue.take(DependencyPriorityBlockingQueue.java:46) 
     at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1035) 
     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1097) 
     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) 
     at java.lang.Thread.run(Thread.java:818) 

#16. OkHttp ConnectionPool 
     at java.lang.Object.wait(Object.java) 
     at java.lang.Thread.parkFor(Thread.java:1220) 
     at sun.misc.Unsafe.park(Unsafe.java:299) 
     at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:197) 
     at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2055) 
     at java.util.concurrent.LinkedBlockingQueue.poll(LinkedBlockingQueue.java:435) 
     at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1035) 
     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1097) 
     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) 
     at java.lang.Thread.run(Thread.java:818) 

#17. AsyncTask #2 
     at dalvik.system.DexFile.getClassNameList(DexFile.java) 
     at dalvik.system.DexFile.access$100(DexFile.java:36) 
     at dalvik.system.DexFile$DFEnum.<init>(DexFile.java:258) 
     at dalvik.system.DexFile.entries(DexFile.java:246) 
     at com.orm.util.ReflectionUtil.getAllClasses(ReflectionUtil.java:297) 
     at com.orm.util.ReflectionUtil.getDomainClasses(ReflectionUtil.java:253) 
     at com.orm.SchemaGenerator.doUpgrade(SchemaGenerator.java:44) 
     at com.orm.SugarDb.onUpgrade(SugarDb.java:31) 
     at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:256) 
     at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:163) 
     at com.orm.SugarDb.getDB(SugarDb.java:36) 
     at com.orm.SugarRecord.find(SugarRecord.java:189) 
     at com.orm.query.Select.list(Select.java:118) 
     at com.playconsulting.totem.database.DatabaseHelper.getCurrentUser(DatabaseHelper.java:965) 
     at com.playconsulting.totem.database.asynctasks.GetCurrentUserAsyncTask.doInBackground(GetCurrentUserAsyncTask.java:21) 
     at com.playconsulting.totem.database.asynctasks.GetCurrentUserAsyncTask.doInBackground(GetCurrentUserAsyncTask.java:13) 
     at android.os.AsyncTask$2.call(AsyncTask.java:288) 
     at java.util.concurrent.FutureTask.run(FutureTask.java:237) 
     at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231) 
     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) 
     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) 
     at java.lang.Thread.run(Thread.java:818) 

#18. FinalizerWatchdogDaemon 
     at java.lang.Thread.sleep(Thread.java) 
     at java.lang.Thread.sleep(Thread.java:1031) 
     at java.lang.Thread.sleep(Thread.java:985) 
     at java.lang.Daemons$FinalizerWatchdogDaemon.sleepFor(Daemons.java:257) 
     at java.lang.Daemons$FinalizerWatchdogDaemon.waitForFinalization(Daemons.java:268) 
     at java.lang.Daemons$FinalizerWatchdogDaemon.run(Daemons.java:216) 
     at java.lang.Thread.run(Thread.java:818) 

#19. AnalyticsHandler 
     at android.os.MessageQueue.nativePollOnce(MessageQueue.java) 
     at android.os.MessageQueue.next(MessageQueue.java:143) 
     at android.os.Looper.loop(Looper.java:130) 
     at android.os.HandlerThread.run(HandlerThread.java:61) 

#20. FinalizerDaemon 
     at java.lang.Object.wait(Object.java) 
     at java.lang.Object.wait(Object.java:422) 
     at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:101) 
     at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:72) 
     at java.lang.Daemons$FinalizerDaemon.run(Daemons.java:173) 
     at java.lang.Thread.run(Thread.java:818) 

#21. Queue 
     at java.lang.Object.wait(Object.java) 
     at java.lang.Thread.parkFor(Thread.java:1220) 
     at sun.misc.Unsafe.park(Unsafe.java:299) 
     at java.util.concurrent.locks.LockSupport.park(LockSupport.java:157) 
     at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2016) 
     at java.util.concurrent.PriorityBlockingQueue.take(PriorityBlockingQueue.java:510) 
     at io.fabric.sdk.android.services.concurrency.DependencyPriorityBlockingQueue.performOperation(DependencyPriorityBlockingQueue.java:197) 
     at io.fabric.sdk.android.services.concurrency.DependencyPriorityBlockingQueue.get(DependencyPriorityBlockingQueue.java:236) 
     at io.fabric.sdk.android.services.concurrency.DependencyPriorityBlockingQueue.take(DependencyPriorityBlockingQueue.java:65) 
     at io.fabric.sdk.android.services.concurrency.DependencyPriorityBlockingQueue.take(DependencyPriorityBlockingQueue.java:46) 
     at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1035) 
     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1097) 
     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) 
     at java.lang.Thread.run(Thread.java:818) 

#22. pool-5-thread-1 
     at java.lang.Object.wait(Object.java) 
     at java.lang.Thread.parkFor(Thread.java:1220) 
     at sun.misc.Unsafe.park(Unsafe.java:299) 
     at java.util.concurrent.locks.LockSupport.park(LockSupport.java:157) 
     at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2016) 
     at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:410) 
     at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1035) 
     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1097) 
     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) 
     at java.lang.Thread.run(Thread.java:818) 

в настоящее время на версии 19 Manifest

<meta-data 
     android:name="VERSION" 
     android:value="19" /> 
    <meta-data 

Однако продублировать линия находится в 15

+3

сообщение LogCat детали –

+0

проблема sqlite.SQLiteException meanse находится в DatabaseHelper.getCurrentUser() метод –

+2

_duplicate имя столбца: users_count (код 1):, при компиляции : alter table USER_TEAM добавить users_count INTEGER; _ –

ответ

1

Я знаю, что я был сильно отклонен, но по сути, ответ заключается в том, что Sugar DB автоматически добавляет столбцы в Databse и что документация неверна. Вам не нужно выполнять миграцию при изменении таблицы. Я удалил SQL из 2.sql, 3.sql и т. Д. И просто оставил их пустыми. Только вставить материал там, если вам нужно изменить имя столбца и т.д.

+0

, это сработало для меня, спасибо! , но почему они не отказались от документации? – David

0

Это может быть потому, что "onUpgrade" называет кратные раз. Таким образом, вам нужно проверить ниже.

  1. Надлежащей версия базы данных и передать в конструктор DatabaseHelper

    public DatabaseHelper(Context aContext) { 
        super(aContext, databaseName, null, databaseVersion); 
    } 
    
  2. Проверьте правильность кода в onUpgrade.

    public void onUpgrade(SQLiteDatabase db, int oldVersion , int newVersion) { 
        if (oldVersion != DATABASE_VERSION) { 
         updateTablesUSERTEAM(db); 
        } 
    } 
    
  3. Goto Настройки-> Приложения -> найти приложение -> четкие данные

  4. Re запустить свой код.

+0

Обратите внимание, что OP использует SugarORM. –

+0

Странно, что версия, которая поднимается, как уже находящаяся в базе данных, равна 15, но моя текущая версия - 19 в манифесте –

+0

. Пожалуйста, вставьте свой файл манифеста, где вы найдете версию на mension. Как и код Java, где вы расширяете «SQLiteOpenHelper» –

 Смежные вопросы

  • Нет связанных вопросов^_^