dachristenson

dachristenson

Kotlin and Android Development featuring Jetpack: Ch 10 (end) program crashes during run

@mfazio23

I had the project running as of p. 249, but by the end of Ch. 10 (p. 258), something new has made the program crash when it tries to perform one or more database operations. My Android tablet DOES have an active Internet connection when this happens. Using Logcat, I get this error:

AndroidRuntime          com.example.abl                      E  FATAL EXCEPTION: arch_disk_io_0
                                                                                                    Process: com.example.abl, PID: 9864
                                                                                                    java.lang.RuntimeException: Exception while computing database live data.
                                                                                                    	at androidx.room.RoomTrackingLiveData.refreshRunnable$lambda$0(RoomTrackingLiveData.kt:74)
                                                                                                    	at androidx.room.RoomTrackingLiveData.$r8$lambda$PhMGW5zFk4QWazERd2lfEeLZqW0(Unknown Source:0)
                                                                                                    	at androidx.room.RoomTrackingLiveData$$ExternalSyntheticLambda0.run(Unknown Source:2)
                                                                                                    	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:923)
                                                                                                    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. Expected identity hash: 39bfe0dd708bc9d7771a09a627f9e596, found: 3947fff4293a2527ac1bdc53260a7ac0
                                                                                                    	at androidx.room.RoomOpenHelper.checkIdentity(RoomOpenHelper.kt:146)
                                                                                                    	at androidx.room.RoomOpenHelper.onOpen(RoomOpenHelper.kt:127)
                                                                                                    	at androidx.sqlite.db.framework.FrameworkSQLiteOpenHelper$OpenHelper.onOpen(FrameworkSQLiteOpenHelper.kt:287)
                                                                                                    	at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:501)
                                                                                                    	at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:387)
                                                                                                    	at androidx.sqlite.db.framework.FrameworkSQLiteOpenHelper$OpenHelper.getWritableOrReadableDatabase(FrameworkSQLiteOpenHelper.kt:232)
                                                                                                    	at androidx.sqlite.db.framework.FrameworkSQLiteOpenHelper$OpenHelper.innerGetDatabase(FrameworkSQLiteOpenHelper.kt:190)
                                                                                                    	at androidx.sqlite.db.framework.FrameworkSQLiteOpenHelper$OpenHelper.getSupportDatabase(FrameworkSQLiteOpenHelper.kt:151)
                                                                                                    	at androidx.sqlite.db.framework.FrameworkSQLiteOpenHelper.getWritableDatabase(FrameworkSQLiteOpenHelper.kt:104)
                                                                                                    	at androidx.room.RoomDatabase.inTransaction(RoomDatabase.kt:632)
                                                                                                    	at androidx.room.RoomDatabase.assertNotSuspendingTransaction(RoomDatabase.kt:451)
                                                                                                    	at androidx.room.RoomDatabase.query(RoomDatabase.kt:480)
                                                                                                    	at androidx.room.util.DBUtil.query(DBUtil.kt:75)
                                                                                                    	at com.example.abl.data.BaseballDao_Impl$9.call(BaseballDao_Impl.java:456)
                                                                                                    	at com.example.abl.data.BaseballDao_Impl$9.call(BaseballDao_Impl.java:452)
                                                                                                    	at androidx.room.RoomTrackingLiveData.refreshRunnable$lambda$0(RoomTrackingLiveData.kt:72)
                                                                                                    	at androidx.room.RoomTrackingLiveData.$r8$lambda$PhMGW5zFk4QWazERd2lfEeLZqW0(Unknown Source:0) 
                                                                                                    	at androidx.room.RoomTrackingLiveData$$ExternalSyntheticLambda0.run(Unknown Source:2) 
                                                                                                    	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:923)

Also, while I’m not sure if it’s connected, I noticed that Android Studio does not like four lines in nag_graph.xml:

        <argument
            android:name="teamId"
            app:argType="string" />
        <argument
            android:name="teamName"
            app:argType="string" />

This is true for both times that this block appears in nav_graph.xml, and the error is the same: “‘teamId’ [or ‘teamName’] is not a valid destination for tag ‘argument’.” As far as I can tell, my code is identical to the code provided with the book here. Is this another case of something in Android having been changed, or is Android Studio making an error in its static analysis here?

My code can be seen here: GitHub - dachristenson/Android_Baseball_League: Working through Part II of "Kotlin and Android Development Featuring Jetpack" by Michael Fazio.

Thanks in advance!

Marked As Solved

mfazio23

mfazio23

Author of Kotlin and Android Development featuring Jetpack

The first issue is due to differences between the database installed on your device versus what you’re trying to deploy. Normally, if the DB is changing you’ll want to create a migration, but for testing, just uninstall and reinstall the app.

The second one is actually an Android Studio bug! I didn’t know this was a thing, but it turns out it’s a known issue: Google Issue Tracker

Let me know if you run into anything else!

Popular Prag Prog topics Top

abtin
page 20: … protoc command… I had to additionally run the following go get commands in order to be able to compile protobuf code using go...
New
belgoros
Following the steps described in Chapter 6 of the book, I’m stuck with running the migration as described on page 84: bundle exec sequel...
New
jeffmcompsci
Title: Design and Build Great Web APIs - typo “https://company-atk.herokuapp.com/2258ie4t68jv” (page 19, third bullet in URL list) Typo:...
New
herminiotorres
Hi! I know not the intentions behind this narrative when called, on page XI: mount() |&gt; handle_event() |&gt; render() but the correc...
New
jeremyhuiskamp
Title: Web Development with Clojure, Third Edition, vB17.0 (p9) The create table guestbook syntax suggested doesn’t seem to be accepted ...
New
adamwoolhether
I’m not quite sure what’s going on here, but I’m unable to have to containers successfully complete the Readiness/Liveness checks. I’m im...
New
AufHe
I’m a newbie to Rails 7 and have hit an issue with the bin/Dev script mentioned on pages 112-113. Iteration A1 - Seeing the list of prod...
New
tkhobbes
After some hassle, I was able to finally run bin/setup, now I have started the rails server but I get this error message right when I vis...
New
dtonhofer
@parrt In the context of Chapter 4.3, the grammar Java.g4, meant to parse Java 6 compilation units, no longer passes ANTLR (currently 4....
New
SlowburnAZ
Getting an error when installing the dependencies at the start of this chapter: could not compile dependency :exla, "mix compile" failed...
New

Other popular topics Top

axelson
I’ve been really enjoying obsidian.md: It is very snappy (even though it is based on Electron). I love that it is all local by defaul...
New
AstonJ
Or looking forward to? :nerd_face:
New
siddhant3030
I’m thinking of buying a monitor that I can rotate to use as a vertical monitor? Also, I want to know if someone is using it for program...
New
New
AstonJ
This looks like a stunning keycap set :orange_heart: A LEGENDARY KEYBOARD LIVES ON When you bought an Apple Macintosh computer in the e...
New
PragmaticBookshelf
“Finding the Boundaries” Hero’s Journey with Noel Rappin @noelrappin Even when you’re ultimately right about what the future ho...
New
Exadra37
Oh just spent so much time on this to discover now that RancherOS is in end of life but Rancher is refusing to mark the Github repo as su...
New
AstonJ
Continuing the discussion from Thinking about learning Crystal, let’s discuss - I was wondering which languages don’t GC - maybe we can c...
New
First poster: bot
zig/http.zig at 7cf2cbb33ef34c1d211135f56d30fe23b6cacd42 · ziglang/zig. General-purpose programming language and toolchain for maintaini...
New
CommunityNews
A Brief Review of the Minisforum V3 AMD Tablet. Update: I have created an awesome-minisforum-v3 GitHub repository to list information fo...
New

Latest in PragProg

View all threads ❯