Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash on startup after upgrade from old version (ALTER TABLE failure?) #5873

Closed
mnalis opened this issue Sep 4, 2024 · 5 comments
Closed
Assignees
Labels

Comments

@mnalis
Copy link
Member

mnalis commented Sep 4, 2024

Updated from old SC version (exact old SC version unfortunately unknown, but probably about a year to year and a half old - as Vespucci 19.0.3.0 is installed and was probably current at that time), app crashes on startup, and attempted restarts also crash (instead of offering to send logs)

Crash log:

java.lang.RuntimeException: Unable to create application de.westnordost.streetcomplete.StreetCompleteApplication: org.koin.core.error.InstanceCreationException: Could not create instance for '[Singleton:'de.westnordost.streetcomplete.util.logs.DatabaseLogger']'
	at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4831)
	at android.app.ActivityThread.access$1800(ActivityThread.java:151)
	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1461)
	at android.os.Handler.dispatchMessage(Handler.java:102)
	at android.os.Looper.loop(Looper.java:157)
	at android.app.ActivityThread.main(ActivityThread.java:5603)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:774)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:652)
Caused by: org.koin.core.error.InstanceCreationException: Could not create instance for '[Singleton:'de.westnordost.streetcomplete.util.logs.DatabaseLogger']'
	at org.koin.core.instance.InstanceFactory.create(SourceFile)
	at org.koin.core.instance.SingleInstanceFactory.create(SourceFile)
	at org.koin.core.instance.SingleInstanceFactory$get$1.invoke(SourceFile:0)
	at org.koin.core.instance.SingleInstanceFactory$get$1.invoke(SourceFile:0)
	at org.koin.mp.KoinPlatformTools.synchronized(SourceFile)
	at org.koin.core.instance.SingleInstanceFactory.get(SourceFile)
	at org.koin.core.registry.InstanceRegistry.resolveInstance$koin_core(SourceFile)
	at org.koin.core.scope.Scope.resolveValue(SourceFile)
	at org.koin.core.scope.Scope.resolveInstance(SourceFile)
	at org.koin.core.scope.Scope.get(SourceFile)
	at de.westnordost.streetcomplete.StreetCompleteApplication$special$$inlined$inject$default$2.invoke(SourceFile)
	at kotlin.SynchronizedLazyImpl.getValue(SourceFile)
	at de.westnordost.streetcomplete.StreetCompleteApplication.getDatabaseLogger(SourceFile)
	at de.westnordost.streetcomplete.StreetCompleteApplication.setLoggerInstances(SourceFile)
	at de.westnordost.streetcomplete.StreetCompleteApplication.onCreate(SourceFile)
	at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1014)
	at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4828)
	... 8 more
Caused by: org.koin.core.error.InstanceCreationException: Could not create instance for '[Singleton:'de.westnordost.streetcomplete.data.logs.LogsController']'
	at org.koin.core.instance.InstanceFactory.create(SourceFile)
	at org.koin.core.instance.SingleInstanceFactory.create(SourceFile)
	at org.koin.core.instance.SingleInstanceFactory$get$1.invoke(SourceFile:0)
	at org.koin.core.instance.SingleInstanceFactory$get$1.invoke(SourceFile:0)
	at org.koin.mp.KoinPlatformTools.synchronized(SourceFile)
	at org.koin.core.instance.SingleInstanceFactory.get(SourceFile)
	at org.koin.core.registry.InstanceRegistry.resolveInstance$koin_core(SourceFile)
	at org.koin.core.scope.Scope.resolveValue(SourceFile)
	at org.koin.core.scope.Scope.resolveInstance(SourceFile)
	at org.koin.core.scope.Scope.get(SourceFile)
	at de.westnordost.streetcomplete.ApplicationModuleKt.appModule$lambda$8$lambda$3(SourceFile)
	at de.westnordost.streetcomplete.ApplicationModuleKt.$r8$lambda$3-TyuVXRL1xv-ahvDgr6BgsTHHE(SourceFile:0)
	at de.westnordost.streetcomplete.ApplicationModuleKt$$ExternalSyntheticLambda5.invoke(SourceFile:0)
	... 25 more
Caused by: org.koin.core.error.InstanceCreationException: Could not create instance for '[Factory:'de.westnordost.streetcomplete.data.logs.LogsDao']'
	at org.koin.core.instance.InstanceFactory.create(SourceFile)
	at org.koin.core.instance.FactoryInstanceFactory.get(SourceFile)
	at org.koin.core.registry.InstanceRegistry.resolveInstance$koin_core(SourceFile)
	at org.koin.core.scope.Scope.resolveValue(SourceFile)
	at org.koin.core.scope.Scope.resolveInstance(SourceFile)
	at org.koin.core.scope.Scope.get(SourceFile)
	at de.westnordost.streetcomplete.data.logs.LogsModuleKt.logsModule$lambda$2$lambda$1(SourceFile)
	at de.westnordost.streetcomplete.data.logs.LogsModuleKt.$r8$lambda$kyS79NN-INclZLCZGB8PYd6ph10(SourceFile:0)
	at de.westnordost.streetcomplete.data.logs.LogsModuleKt$$ExternalSyntheticLambda2.invoke(SourceFile:0)
	... 38 more
Caused by: org.koin.core.error.InstanceCreationException: Could not create instance for '[Singleton:'de.westnordost.streetcomplete.data.Database']'
	at org.koin.core.instance.InstanceFactory.create(SourceFile)
	at org.koin.core.instance.SingleInstanceFactory.create(SourceFile)
	at org.koin.core.instance.SingleInstanceFactory$get$1.invoke(SourceFile:0)
	at org.koin.core.instance.SingleInstanceFactory$get$1.invoke(SourceFile:0)
	at org.koin.mp.KoinPlatformTools.synchronized(SourceFile)
	at org.koin.core.instance.SingleInstanceFactory.get(SourceFile)
	at org.koin.core.registry.InstanceRegistry.resolveInstance$koin_core(SourceFile)
	at org.koin.core.scope.Scope.resolveValue(SourceFile)
	at org.koin.core.scope.Scope.resolveInstance(SourceFile)
	at org.koin.core.scope.Scope.get(SourceFile)
	at de.westnordost.streetcomplete.data.logs.LogsModuleKt.logsModule$lambda$2$lambda$0(SourceFile)
	at de.westnordost.streetcomplete.data.logs.LogsModuleKt.$r8$lambda$i-oS8Q7Mi4HXv9zHfsTHA1uUv00(SourceFile:0)
	at de.westnordost.streetcomplete.data.logs.LogsModuleKt$$ExternalSyntheticLambda1.invoke(SourceFile:0)
	... 47 more
Caused by: android.database.sqlite.SQLiteException: duplicate column name: is_near (code 1): , while compiling: ALTER TABLE osm_element_edits ADD COLUMN is_near int DEFAULT 1 NOT NULL
	at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
	at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:887)
	at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:498)
	at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
	at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
	at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:31)
	at android.database.sqlite.SQLiteDatabase.executeSql(SQLiteDatabase.java:1674)
	at android.database.sqlite.SQLiteDatabase.execSQL(SQLiteDatabase.java:1605)
	at de.westnordost.streetcomplete.data.AndroidDatabase.exec(SourceFile)
	at de.westnordost.streetcomplete.data.Database$DefaultImpls.exec$default(SourceFile)
	at de.westnordost.streetcomplete.data.DatabaseInitializer.onUpgrade(SourceFile)
	at de.westnordost.streetcomplete.data.StreetCompleteSQLiteOpenHelper.onUpgrade(SourceFile)
	at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:256)
	at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:163)
	at de.westnordost.streetcomplete.data.DbModuleKt.dbModule$lambda$1$lambda$0(SourceFile)
	at de.westnordost.streetcomplete.data.DbModuleKt.$r8$lambda$IGJU7etnWCTnBhldDo5YiS03WyI(SourceFile:0)
	at de.westnordost.streetcomplete.data.DbModuleKt$$ExternalSyntheticLambda1.invoke(SourceFile:0)
	... 60 more

How to Reproduce

  • have old SC version installed
  • download v59.0-alpha4 and upgrade to it
  • start SC
  • crash

Expected Behavior
I'd expeect SC to start up normally.

Also, if crashing, it would be nice if offering to send crash log on app startup was done very early; i.e. before database updates, map initialization and other things that are somewhat likely to crash again.

Versions affected
StreetComplete 59.0-alpha4 on Android 6.0.1 (Xiaomi Redmi Note 3)

@mnalis mnalis added the bug label Sep 4, 2024
@westnordost
Copy link
Member

It looks like the fault is here:

db.exec("ALTER TABLE ${ElementEditsTable.NAME} ADD COLUMN ${ElementEditsTable.Columns.IS_NEAR_USER_LOCATION} int DEFAULT 1 NOT NULL")

The column already exists in your database. The column is part of a feature implemented in #5474, released in v57.0.

It would be very helpful if we knew from which version you tried to upgrade so that it can be reproduced.
There must be something special about upgrading from that version, because otherwise this error would have happened for others upgrading to v57.0, too.

@westnordost westnordost added the feedback required more info is needed, issue will be likely closed if it is not provided label Sep 5, 2024
@mnalis

This comment was marked as outdated.

@westnordost
Copy link
Member

Could you try if it is reproducible when you download and install 5501, then upgrade to current?

@mnalis
Copy link
Member Author

mnalis commented Sep 6, 2024

That 5501 turned out to be red herring, but going by the versions/dates of other apps, I've found that after uninstalling, and then freshly installing SC 52.0, starting it up, and upgrading to v59.0-alpha4 leads to that crash.

@westnordost
Copy link
Member

Thank you for your investigation!

@westnordost westnordost removed the feedback required more info is needed, issue will be likely closed if it is not provided label Sep 6, 2024
@westnordost westnordost self-assigned this Sep 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants