apps-android-commons: App keeps crashing on opening

Summary:

App keeps crashing on opening.

Steps to reproduce:

I cloned the repo from GitHub and tried to compile it. Can’t open the app now.

System logs:

2020-03-30 22:05:52.054 13692-13692/fr.free.nrw.commons.beta E/LoadedApk: Unable to instantiate appComponentFactory
    java.lang.ClassNotFoundException: Didn't find class "fr.free.nrw.commons.beta.commons" on path: DexPathList[[zip file "/system/framework/org.apache.http.legacy.boot.jar", zip file "/data/app/fr.free.nrw.commons.beta-YxpmNSMHaflmNsRTrCV_tw==/base.apk"],nativeLibraryDirectories=[/data/app/fr.free.nrw.commons.beta-YxpmNSMHaflmNsRTrCV_tw==/lib/arm64, /data/app/fr.free.nrw.commons.beta-YxpmNSMHaflmNsRTrCV_tw==/base.apk!/lib/arm64-v8a, /system/lib64]]
        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
        at android.app.LoadedApk.createAppFactory(LoadedApk.java:228)
        at android.app.LoadedApk.createOrUpdateClassLoaderLocked(LoadedApk.java:733)
        at android.app.LoadedApk.getClassLoader(LoadedApk.java:812)
        at android.app.LoadedApk.getResources(LoadedApk.java:1034)
        at android.app.ContextImpl.createAppContext(ContextImpl.java:2357)
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5821)
        at android.app.ActivityThread.access$1200(ActivityThread.java:200)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1673)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:201)
        at android.app.ActivityThread.main(ActivityThread.java:6810)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873)

2020-03-30 23:19:13.076 28318-28375/fr.free.nrw.commons D/OkHttp: --> GET https://commons.wikimedia.org/w/api.php?format=json&formatversion=2&errorformat=plaintext&action=query&list=logevents&letype=upload&leprop=title|timestamp|ids&lelimit=500&leuser=Anmol1311
2020-03-30 23:19:13.077 28318-28318/fr.free.nrw.commons E/ContributionsFragment: onFragmentResumed fr.free.nrw.commons.contributions.ContributionsListFragment
2020-03-30 23:19:13.084 28318-28373/fr.free.nrw.commons E/AndroidRuntime: FATAL EXCEPTION: arch_disk_io_0
    Process: fr.free.nrw.commons, PID: 28318
    java.lang.RuntimeException: Exception while computing database live data.
        at androidx.room.RoomTrackingLiveData$1.run(RoomTrackingLiveData.java:92)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:764)
     Caused by: java.lang.IllegalStateException: Room cannot verify the data integrity. Looks like you've changed schema but forgot to update the version number. You can simply fix this by increasing the version number.
        at androidx.room.RoomOpenHelper.checkIdentity(RoomOpenHelper.java:154)
        at androidx.room.RoomOpenHelper.onOpen(RoomOpenHelper.java:135)
        at androidx.sqlite.db.framework.FrameworkSQLiteOpenHelper$OpenHelper.onOpen(FrameworkSQLiteOpenHelper.java:142)
        at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:409)
        at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:298)
        at androidx.sqlite.db.framework.FrameworkSQLiteOpenHelper$OpenHelper.getWritableSupportDatabase(FrameworkSQLiteOpenHelper.java:92)
        at androidx.sqlite.db.framework.FrameworkSQLiteOpenHelper.getWritableDatabase(FrameworkSQLiteOpenHelper.java:53)
        at androidx.room.RoomDatabase.inTransaction(RoomDatabase.java:476)
        at androidx.room.RoomDatabase.assertNotSuspendingTransaction(RoomDatabase.java:281)
        at androidx.room.RoomDatabase.query(RoomDatabase.java:324)
        at androidx.room.util.DBUtil.query(DBUtil.java:83)
        at fr.free.nrw.commons.contributions.ContributionDao_Impl$10.call(ContributionDao_Impl.java:666)
        at fr.free.nrw.commons.contributions.ContributionDao_Impl$10.call(ContributionDao_Impl.java:663)
        at androidx.room.RoomTrackingLiveData$1.run(RoomTrackingLiveData.java:90)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) 
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) 
        at java.lang.Thread.run(Thread.java:764) 
2020-03-30 23:19:13.085 28318-28375/fr.free.nrw.commons D/CookieManager: Domain:commons.wikimedia.org
2020-03-30 23:19:13.090 28318-28373/fr.free.nrw.commons E/ACRA: ACRA caught a RuntimeException for fr.free.nrw.commons
    java.lang.RuntimeException: Exception while computing database live data.
        at androidx.room.RoomTrackingLiveData$1.run(RoomTrackingLiveData.java:92)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:764)
     Caused by: java.lang.IllegalStateException: Room cannot verify the data integrity. Looks like you've changed schema but forgot to update the version number. You can simply fix this by increasing the version number.
        at androidx.room.RoomOpenHelper.checkIdentity(RoomOpenHelper.java:154)
        at androidx.room.RoomOpenHelper.onOpen(RoomOpenHelper.java:135)
        at androidx.sqlite.db.framework.FrameworkSQLiteOpenHelper$OpenHelper.onOpen(FrameworkSQLiteOpenHelper.java:142)
        at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:409)
        at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:298)
        at androidx.sqlite.db.framework.FrameworkSQLiteOpenHelper$OpenHelper.getWritableSupportDatabase(FrameworkSQLiteOpenHelper.java:92)
        at androidx.sqlite.db.framework.FrameworkSQLiteOpenHelper.getWritableDatabase(FrameworkSQLiteOpenHelper.java:53)
        at androidx.room.RoomDatabase.inTransaction(RoomDatabase.java:476)
        at androidx.room.RoomDatabase.assertNotSuspendingTransaction(RoomDatabase.java:281)
        at androidx.room.RoomDatabase.query(RoomDatabase.java:324)
        at androidx.room.util.DBUtil.query(DBUtil.java:83)
        at fr.free.nrw.commons.contributions.ContributionDao_Impl$10.call(ContributionDao_Impl.java:666)
        at fr.free.nrw.commons.contributions.ContributionDao_Impl$10.call(ContributionDao_Impl.java:663)
        at androidx.room.RoomTrackingLiveData$1.run(RoomTrackingLiveData.java:90)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) 
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) 
        at java.lang.Thread.run(Thread.java:764) 

Device and Android version:

Redmi Note 5 Pro MIUI version 11 Android 9

Commons app version:

master betaDebug

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 35 (22 by maintainers)

Most upvoted comments

@6point022 I know this isn’t a solution to the actual problem you’ve reported. But just try clearing the app’s data and using the app. You would not experience the crash.

Yeah, a lot of programmers on stackoverflow also said that it works for them as well, but I was stuck on that for days and all these steps helped me out. Happy coding 👍

Caused by: java.lang.IllegalStateException: Room cannot verify the data integrity. Looks like you’ve changed schema but forgot to update the version number. You can simply fix this by increasing the version number.

Let me add some information about why we’re facing this issue based on the little knowledge about Room that I have.

As the error message clearly states the schema has changed without the version number being changed.

  • What constitutes the schema here? For now, it’s the fields of the Contribution class that are persisted.

  • When was it changed/Who changed it? I suspect the crash observed here might be due to a change to the Contribution class done in PR #3569.

  • Why didn’t we catch this during testing? It’s complicated. In simple terms: a fresh app install wouldn’t have caught the issue. As the validation would fail only when there’s an existing version of the app installed and we install a new one that would introduce a schema conflict.

  • How do we avoid this in future? We would have to ensure that the schema version number of is updated whenever the fields of the classes being persisted using room are changed.

Kindly correct me if I’m wrong somewhere as what I’ve mentioned is purely based on what I remember and it’s been rusty for a while. 🙂

cc @misaochan

But just try clearing the app’s data and using the app. You would not experience the crash.

@sivaraam Thanks a lot, it worked! 😄

The reason for the actual problem is very clear in the error message. Quoting the relevant portion:

Caused by: java.lang.IllegalStateException: Room cannot verify the data integrity. Looks like you’ve changed schema but forgot to update the version number. You can simply fix this by increasing the version number.