简体   繁体   English

“Dao_Impl”中的“MyMethod”与“Dao”中的“MyMethod + extends”冲突; 两种方法具有相同的擦除,但都没有覆盖另一个

[英]'MyMethod' in 'Dao_Impl' clashes with 'MyMethod + extends' in 'Dao'; both methods have same erasure, yet neither overrides the other

I wasnt getting any errors before.我之前没有收到任何错误。 But today, i entered my project to edit and saw these errors.但是今天,我进入我的项目进行编辑并看到了这些错误。

First one is on this line;第一个在这条线上;

public final class NoteDao_Impl implements NoteDao {

// The error code is : Class 'NoteDao_Impl' must either be declared abstract or implement abstract method 'getAllNotes(Continuation<? super List<? extends Notes>>)' in 'NoteDao'

I can fix it with Alt + Enter and then clicking 'implement methods' but just in case i want to write it.我可以使用 Alt + Enter 修复它,然后单击“实现方法”,但以防万一我想写它。

The second one and third one is on these lines;第二个和第三个在这些线上;

@Override
// Error : Method does not override method from its superclass
public Object getAllNotes(final Continuation<? super List<Notes>> continuation) {
// Error : 'getAllNotes(Continuation<? super List<Notes>>)' in 'com.ahmetkaan.kediy.data.NoteDao_Impl' clashes with 'getAllNotes(Continuation<? super List<? extends Notes>>)' in 'com.ahmetkaan.kediy.data.NoteDao'; both methods have same erasure, yet neither overrides the other

The NoteDao;笔记道;

package com.ahmetkaan.kediy.data

import androidx.room.*

@Dao
interface NoteDao {

    @Query("SELECT * FROM notes ORDER BY id DESC")
    suspend fun getAllNotes() : List<Notes>

    @Query("SELECT * FROM notes WHERE id =:id")
    suspend fun getSpecificNote(id:Int) : Notes

    @Query("SELECT * FROM notes WHERE category = :id")
    suspend fun getCategoryNote(id:Int) : Notes

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    suspend fun insertNotes(note:Notes)

    @Delete
    suspend fun deleteNote(note:Notes)

    @Query("DELETE FROM notes WHERE id =:id")
    suspend fun deleteSpecificNote(id:Int)

    @Update
    suspend fun updateNote(note:Notes)
}

The problem appears when i set getAllNotes() method as "getAllNotes(): List " So i guess thats why.当我将 getAllNotes() 方法设置为“getAllNotes(): List”时出现问题所以我想这就是原因。 But i dont understand why i get this error now.但我不明白为什么我现在会收到此错误。 I do some research and i encounter some solutions like;我做了一些研究,遇到了一些解决方案,例如;

public class a<T extends Comparable> implements A<T>   

but probably i cant make it compatible with my project:,) Thanks in advance.但可能我无法使其与我的项目兼容:,) 在此先感谢。

I met the same problem.我遇到了同样的问题。 I try this link to fix the problem.我尝试使用此链接来解决问题。 You can try changing List<Notes> to Array<Notes> .您可以尝试将List<Notes>更改为Array<Notes> Hope it will help.希望它会有所帮助。

Also, if this error causes your app to crash at runtime, and you don't want to change the List to Array, maybe there is another approach.此外,如果此错误导致您的应用程序在运行时崩溃,并且您不想将 List 更改为 Array,也许还有另一种方法。 If you are using manual migration of the room database, try to change it to auto migration( Doc ).如果您正在使用房间数据库的手动迁移,请尝试将其更改为自动迁移( Doc )。 Although there still has this error in the build package, it won't affect your app performance.虽然在 build package 中仍然存在这个错误,但它不会影响您的应用程序性能。 Your app can run without crashing.您的应用程序可以运行而不会崩溃。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM