Kotlin and Android Development featuring Jetpack: Error in generated Game.java (page 136)

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 build without errors.

Reasons for the assumption:

  • The Database Inspector ISN’T appearing (as far as I can tell, in Arctic Fox, it was moved to the “App Inspection” tab and no longer exists as a Tool window of its own).

  • I assume the act of successfully building and running the app is what creates and populates the database on the emulator, and…

  • once that database exists, Android Studio notices it & reveals the Database Inspector functionality.

There are no visible errors in the sourcecode itself (no red squiggly lines in any editable source files, no red marks along the right margin), but I’m getting a slew of errors in the generated app/build/tmp/kapt3/stubs/debug/dev/mfazio/pennydrop/data/Game.java class, PennyDropDao.java, and Player.java (note: all are *.java and presumably generated, the *.kt files seem to be fine) that I’m not sure how to troubleshoot:

C:\src\experiments\android\PennyDrop\app\build\tmp\kapt3\stubs\debug\dev\mfazio\pennydrop\data\Game.java:7: warning: There are multiple good constructors and Room will pick the no-arg constructor. You can use the @Ignore annotation to eliminate unwanted constructors.
public final class Game {
             ^
C:\src\experiments\android\PennyDrop\app\build\tmp\kapt3\stubs\debug\dev\mfazio\pennydrop\data\Game.java:11: error: Cannot find setter for field.
    private final dev.mfazio.pennydrop.data.GameState gameState = null;
                                                      ^
C:\src\experiments\android\PennyDrop\app\build\tmp\kapt3\stubs\debug\dev\mfazio\pennydrop\data\Game.java:13: error: Cannot find setter for field.
    private final java.time.OffsetDateTime startTime = null;
                                           ^
C:\src\experiments\android\PennyDrop\app\build\tmp\kapt3\stubs\debug\dev\mfazio\pennydrop\data\Game.java:15: error: Cannot find setter for field.
    private final java.time.OffsetDateTime endTime = null;
                                           ^
C:\src\experiments\android\PennyDrop\app\build\tmp\kapt3\stubs\debug\dev\mfazio\pennydrop\data\Game.java:17: error: Cannot find setter for field.
    private final java.util.List<java.lang.Integer> filledSlots = null;
                                                    ^
C:\src\experiments\android\PennyDrop\app\build\tmp\kapt3\stubs\debug\dev\mfazio\pennydrop\data\Game.java:19: error: Cannot find setter for field.
    private final java.lang.Integer lastRoll = null;
                                    ^
C:\src\experiments\android\PennyDrop\app\build\tmp\kapt3\stubs\debug\dev\mfazio\pennydrop\data\Game.java:21: error: Cannot find setter for field.
    private final java.lang.String currentTurnText = null;
                                   ^
C:\src\experiments\android\PennyDrop\app\build\tmp\kapt3\stubs\debug\dev\mfazio\pennydrop\data\Game.java:22: error: Cannot find setter for field.
    private final boolean canRoll = false;
                          ^
C:\src\experiments\android\PennyDrop\app\build\tmp\kapt3\stubs\debug\dev\mfazio\pennydrop\data\Game.java:23: error: Cannot find setter for field.
    private final boolean canPass = false;
                          ^
C:\src\experiments\android\PennyDrop\app\build\tmp\kapt3\stubs\debug\dev\mfazio\pennydrop\data\Game.java:7: warning: There are multiple good constructors and Room will pick the no-arg constructor. You can use the @Ignore annotation to eliminate unwanted constructors.
public final class Game {
             ^
C:\src\experiments\android\PennyDrop\app\build\tmp\kapt3\stubs\debug\dev\mfazio\pennydrop\data\Game.java:11: error: Cannot find setter for field.
    private final dev.mfazio.pennydrop.data.GameState gameState = null;
                                                      ^
C:\src\experiments\android\PennyDrop\app\build\tmp\kapt3\stubs\debug\dev\mfazio\pennydrop\data\Game.java:13: error: Cannot find setter for field.
    private final java.time.OffsetDateTime startTime = null;
                                           ^
C:\src\experiments\android\PennyDrop\app\build\tmp\kapt3\stubs\debug\dev\mfazio\pennydrop\data\Game.java:15: error: Cannot find setter for field.
    private final java.time.OffsetDateTime endTime = null;
                                           ^
C:\src\experiments\android\PennyDrop\app\build\tmp\kapt3\stubs\debug\dev\mfazio\pennydrop\data\Game.java:17: error: Cannot find setter for field.
    private final java.util.List<java.lang.Integer> filledSlots = null;
                                                    ^
C:\src\experiments\android\PennyDrop\app\build\tmp\kapt3\stubs\debug\dev\mfazio\pennydrop\data\Game.java:19: error: Cannot find setter for field.
    private final java.lang.Integer lastRoll = null;
                                    ^
C:\src\experiments\android\PennyDrop\app\build\tmp\kapt3\stubs\debug\dev\mfazio\pennydrop\data\Game.java:21: error: Cannot find setter for field.
    private final java.lang.String currentTurnText = null;
                                   ^
C:\src\experiments\android\PennyDrop\app\build\tmp\kapt3\stubs\debug\dev\mfazio\pennydrop\data\Game.java:22: error: Cannot find setter for field.
    private final boolean canRoll = false;
                          ^
C:\src\experiments\android\PennyDrop\app\build\tmp\kapt3\stubs\debug\dev\mfazio\pennydrop\data\Game.java:23: error: Cannot find setter for field.
    private final boolean canPass = false;
                          

Any idea which class to even start looking at to figure out what’s wrong? I’m guessing I forgot an annotation somewhere… or possibly, in an attempt to fix an earlier typo problem by copying files from the .zip file, might have created a bigger one by prematurely copying something mentioned later in the chapter that’s now triggering the error above by expecting the presence of something that officially hasn’t been added yet as of page 136.

For what it’s worth, it looks like the following methods of PennyDropDao.kt haven’t yet been mentioned as of page 136, but are in the .zip file’s version, and the references to them by the lines added prior to page 136 will generate errors in PennyDropDao.kt itself unless they’re added:

getPlayer()
insertGame()
insertPlayer()
insertPlayers()
updateGame()

According to WinMerge, my versions of Converters.kt, Game.kt, GameState.kt, GameStatus.kt, PennyDropDatabase.kt, and PennyDropRepository.kt are presently identical to the versions in the zipfile.

As far as I can recall, my copy of PennyDropDao.kt was identical, until I commented the methods out, then went through chapter 5 from the start and moved the methods from inside the comment block to the outside in the order they’re mentioned in the chapter. That’s how I noticed that 5 methods listed above were referenced by the code, but not mentioned yet as of page 136… they were still in the comment block as of page 136.