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 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
iPaul
page 37 ANTLRInputStream input = new ANTLRInputStream(is); as of ANTLR 4 .8 should be: CharStream stream = CharStreams.fromStream(i...
New
simonpeter
When I try the command to create a pair of migration files I get an error. user=&gt; (create-migration "guestbook") Execution error (Ill...
New
edruder
I thought that there might be interest in using the book with Rails 6.1 and Ruby 2.7.2. I’ll note what I needed to do differently here. ...
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
rmurray10127
Title: Intuitive Python: docker run… denied error (page 2) Attempted to run the docker command in both CLI and Powershell PS C:\Users\r...
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
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
EdBorn
Title: Agile Web Development with Rails 7: (page 70) I am running windows 11 pro with rails 7.0.3 and ruby 3.1.2p20 (2022-04-12 revision...
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

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
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
AstonJ
I ended up cancelling my Moonlander order as I think it’s just going to be a bit too bulky for me. I think the Planck and the Preonic (o...
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
mafinar
This is going to be a long an frequently posted thread. While talking to a friend of mine who has taken data structure and algorithm cou...
New
First poster: joeb
The File System Access API with Origin Private File System. WebKit supports new API that makes it possible for web apps to create, open,...
New
PragmaticBookshelf
Author Spotlight: VM Brasseur @vmbrasseur We have a treat for you today! We turn the spotlight onto Open Source as we sit down with V...
New
PragmaticBookshelf
Author Spotlight: Karl Stolley @karlstolley Logic! Rhetoric! Prag! Wow, what a combination. In this spotlight, we sit down with Karl ...
New
PragmaticBookshelf
Author Spotlight: Tammy Coron @Paradox927 Gaming, and writing games in particular, is about passion, vision, experience, and immersio...
New