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

telemachus
Python Testing With Pytest - Chapter 2, warnings for “unregistered custom marks” While running the smoke tests in Chapter 2, I get these...
New
johnp
Hi Brian, Looks like the api for tinydb has changed a little. Noticed while working on chapter 7 that the .purge() call to the db throws...
New
ianwillie
Hello Brian, I have some problems with running the code in your book. I like the style of the book very much and I have learnt a lot as...
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
brunogirin
When I run the coverage example to report on missing lines, I get: pytest --cov=cards --report=term-missing ch7 ERROR: usage: pytest [op...
New
brunogirin
When trying to run tox in parallel as explained on page 151, I got the following error: tox: error: argument -p/–parallel: expected one...
New
hazardco
On page 78 the following code appears: &lt;%= link_to ‘Destroy’, product, class: ‘hover:underline’, method: :delete, data: { confirm...
New
s2k
Hi all, currently I wonder how the Tailwind colours work (or don’t work). For example, in app/views/layouts/application.html.erb I have...
New
mert
AWDWR 7, page 152, page 153: Hello everyone, I’m a little bit lost on the hotwire part. I didn’t fully understand it. On page 152 @rub...
New
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
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
AstonJ
There’s a whole world of custom keycaps out there that I didn’t know existed! Check out all of our Keycaps threads here: https://forum....
New
New
PragmaticBookshelf
“A Mystical Experience” Hero’s Journey with Paolo Perrotta @nusco Ever wonder how authoring books compares to writing articles?...
New
DevotionGeo
The V Programming Language Simple language for building maintainable programs V is already mentioned couple of times in the forum, but I...
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 Mike Riley @mriley This month, we turn the spotlight on Mike Riley, author of Portable Python Projects. Mike’s book ...
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
PragmaticBookshelf
Author Spotlight: Sophie DeBenedetto @SophieDeBenedetto The days of the traditional request-response web application are long gone, b...
New

Latest in PragProg

View all threads ❯