a.zampa

a.zampa

Kotlin and Android Development featuring Jetpack: error concerning function getCurrentStandings in BaseballDao.java

@mfazio23

I’m following the indications of the book and arriver ad chapter 10, but the app cannot be compiled due to an error in the BaseballDao.java class produced during the build process. I get the following errors:

  • Not sure how to convert a Cursor to this method’s return type (java.lang.Object).
  • Query method parameters should either be a type that can be converted into a database column or a List / Array that contains such type. You can consider adding a Type Adapter for this.
  • Unused parameter: continuation
  • Type of the parameter must be a class annotated with @Entity or a collection/array of it.
  • Not sure how to handle insert method’s return type.
  • Type of the parameter must be a class annotated with @Entity or a collection/array of it.
  • Not sure how to handle insert method’s return type.
  • Type of the parameter must be a class annotated with @Entity or a collection/array of it.
  • Not sure how to handle update method’s return type. Currently the supported return types are void, int or Int.
  • Type of the parameter must be a class annotated with @Entity or a collection/array of it.
  • Not sure how to handle update method’s return type. Currently the supported return types are void, int or Int.
  • The query returns some columns [teamId, division, wins, losses, winsLastTen, streakCount, streakType, divisionGamesBack, leagueGamesBack, id] which are not used by java.lang.Object. You can use @ColumnInfo annotation on the fields to specify the mapping. You can annotate the method with @RewriteQueriesToDropUnusedColumns to direct Room to rewrite your query to avoid fetching unused columns. You can suppress this warning by annotating the method with @SuppressWarnings(RoomWarnings.CURSOR_MISMATCH). Columns returned by the query: teamId, division, wins, losses, winsLastTen, streakCount, streakType, divisionGamesBack, leagueGamesBack, id.

The error message is

C:\Users\ale\AndroidStudioProjects\AndroidBaseballLeague\app\build\tmp\kapt3\stubs\debug\org\mathverse\androidbaseballleague\data\BaseballDao.java:31: error: Not sure how to convert a Cursor to this method’s return type (java.lang.Object).
public abstract java.lang.Object getCurrentStandings(@org.jetbrains.annotations.NotNull()

(I’m using org.mathverse.androidbaseballleague as package name, instead of dev.mfazio.abl).

The BaseballDao.java class contains the following lines

@org.jetbrains.annotations.Nullable()
@androidx.room.Query(value = "SELECT * FROM standings")
public abstract java.lang.Object getCurrentStandings(@org.jetbrains.annotations.NotNull()
kotlin.coroutines.Continuation<? super java.util.List<org.mathverse.androidbaseballleague.standings.TeamStanding>> continuation);

This is the only function of the database having prblems.
How can I solve this issue?
Thanks

Marked As Solved

a.zampa

a.zampa

Michael,

according to comment #11 to issue number 236612358, this problem is related to a change to Kotlin @Metadata annotation and can be solved forcing the dependency to the new version of kotlinx-metadata-jvm by adding

kapt “org.jetbrains.kotlinx:kotlinx-metadata-jvm:0.5.0”

This worked for me and solved another issue (room 2.4.2 didn’t allow to use vals into @Entity data classes asking, for the generated java class, setters for the corresponding variables).

Popular Prag Prog topics Top

jimschubert
In Chapter 3, the source for index introduces Config on page 31, followed by more code including tests; Config isn’t introduced until pag...
New
jamis
The following is cross-posted from the original Ray Tracer Challenge forum, from a post by garfieldnate. I’m cross-posting it so that the...
New
herminiotorres
Hi @Margaret , On page VII the book tells us the example and snippets will be all using Elixir version 1.11 But on page 3 almost the en...
New
joepstender
The generated iex result below should list products instead of product for the metadata. (page 67) iex&gt; product = %Product{} %Pento....
New
alanq
This isn’t directly about the book contents so maybe not the right forum…but in some of the code apps (e.g. turbo/06) it sends a TURBO_ST...
New
New
jskubick
I found an issue in Chapter 7 regarding android:backgroundTint vs app:backgroundTint. How to replicate: load chapter-7 from zipfile i...
New
brunogirin
When installing Cards as an editable package, I get the following error: ERROR: File “setup.py” not found. Directory cannot be installe...
New
kolossal
Hi, I need some help, I’m new to rust and was learning through your book. but I got stuck at the last stage of distribution. Whenever I t...
New
gorkaio
root_layout: {PentoWeb.LayoutView, :root}, This results in the following following error: no “root” html template defined for PentoWeb...
New

Other popular topics Top

New
AstonJ
Inspired by this post from @Carter, which languages, frameworks or other tech or tools do you think is killing it right now? :upside_down...
New
AstonJ
I have seen the keycaps I want - they are due for a group-buy this week but won’t be delivered until October next year!!! :rofl: The Ser...
New
PragmaticBookshelf
“Finding the Boundaries” Hero’s Journey with Noel Rappin @noelrappin Even when you’re ultimately right about what the future ho...
New
AstonJ
In case anyone else is wondering why Ruby 3 doesn’t show when you do asdf list-all ruby :man_facepalming: do this first: asdf plugin-upd...
New
mafinar
Crystal recently reached version 1. I had been following it for awhile but never got to really learn it. Most languages I picked up out o...
New
PragmaticBookshelf
Author Spotlight Jamis Buck @jamis This month, we have the pleasure of spotlighting author Jamis Buck, who has written Mazes for Prog...
New
PragmaticBookshelf
Author Spotlight: Karl Stolley @karlstolley Logic! Rhetoric! Prag! Wow, what a combination. In this spotlight, we sit down with Karl ...
New
First poster: bot
Large Language Models like ChatGPT say The Darnedest Things. The Errors They MakeWhy We Need to Document Them, and What We Have Decided ...
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 ❯