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!

Where Next?

Popular Pragmatic Bookshelf topics Top

jon
Some minor things in the paper edition that says “3 2020” on the title page verso, not mentioned in the book’s errata online: p. 186 But...
New
mikecargal
Title: Hands-On Rust (Chap 8 (Adding a Heads Up Display) It looks like ​.with_simple_console_no_bg​(SCREEN_WIDTH*2, SCREEN_HEIGHT*2...
New
joepstender
The generated iex result below should list products instead of product for the metadata. (page 67) iex&gt; product = %Product{} %Pento....
New
curtosis
Running mix deps.get in the sensor_hub directory fails with the following error: ** (Mix) No SSH public keys found in ~/.ssh. An ssh aut...
New
jgchristopher
“The ProductLive.Index template calls a helper function, live_component/3, that in turn calls on the modal component. ” Excerpt From: Br...
New
jskubick
I’m under the impression that when the reader gets to page 136 (“View Data with the Database Inspector”), the code SHOULD be able to buil...
New
oaklandgit
Hi, I completed chapter 6 but am getting the following error when running: thread 'main' panicked at 'Failed to load texture: IoError(O...
New
dsmith42
Hey there, I’m enjoying this book and have learned a few things alredayd. However, in Chapter 4 I believe we are meant to see the “&gt;...
New
davetron5000
Hello faithful readers! If you have tried to follow along in the book, you are asked to start up the dev environment via dx/build and ar...
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

malloryerik
Any thoughts on Svelte? Svelte is a radical new approach to building user interfaces. Whereas traditional frameworks like React and Vue...
New
wolf4earth
@AstonJ prompted me to open this topic after I mentioned in the lockdown thread how I started to do a lot more for my fitness. https://f...
New
brentjanderson
Bought the Moonlander mechanical keyboard. Cherry Brown MX switches. Arms and wrists have been hurting enough that it’s time I did someth...
New
rustkas
Intensively researching Erlang books and additional resources on it, I have found that the topic of using Regular Expressions is either c...
New
Maartz
Hi folks, I don’t know if I saw this here but, here’s a new programming language, called Roc Reminds me a bit of Elm and thus Haskell. ...
New
Help
I am trying to crate a game for the Nintendo switch, I wanted to use Java as I am comfortable with that programming language. Can you use...
New
PragmaticBookshelf
Author Spotlight Mike Riley @mriley This month, we turn the spotlight on Mike Riley, author of Portable Python Projects. Mike’s book ...
New
husaindevelop
Inside our android webview app, we are trying to paste the copied content from another app eg (notes) using navigator.clipboard.readtext ...
New
PragmaticBookshelf
Author Spotlight: Tammy Coron @Paradox927 Gaming, and writing games in particular, is about passion, vision, experience, and immersio...
New
PragmaticBookshelf
Author Spotlight: Sophie DeBenedetto @SophieDeBenedetto The days of the traditional request-response web application are long gone, b...
New

Sub Categories: