如何抑制生成源代码中的Lint警告?

4
使用 Room 版本 2.1.0-alpha04
implementation "androidx.room:room-runtime:2.1.0-alpha04"
annotationProcessor "androidx.room:room-compiler:2.1.0-alpha04"
testImplementation "androidx.room:room-testing:2.1.0-alpha04"

@Dao 的实现引起了这些警告,根据生成的 Dao_Impl 文件:

[deprecation] setTransactionSuccessful() in RoomDatabase has been deprecated
[deprecation] beginTransaction() in RoomDatabase has been deprecated
[deprecation] endTransaction() in RoomDatabase has been deprecated

还有这个@Database类:

[deprecation] mCallbacks in RoomDatabase has been deprecated

问题是,这些文件位于mobile/build/generated/source/apt/debug中,而只有类似<ignore path="src/main/..."/>的路径才能被捕获。到目前为止,我尝试了绝对路径和相对路径以及**/,还有带通配符和不带通配符的限定类名:

<?xml version="1.0" encoding="UTF-8"?>
<lint>
    <issue id="Deprecated" severity="informational">
        <ignore regexp="androidx.room.RoomDatabase" />
    </issue>

    <issue id="Deprecated">
        <ignore regexp="com.acme.database.dao.*Dao_Impl" />
    </issue>
</lint>

如何使用lint.xml来压制在build/generated/source目录下出现的废弃警告,或者是否有更新/稳定版本的RoomDatabase可以使用(而且不会导致这些警告出现)?

你是如何启动代码检查的?我只习惯在Android Studio中运行它,因为你可以指定范围。 - Carl Anderson
1个回答

1

将 Room 更新到版本 2.2.0-alpha02 会移除弃用警告:

annotationProcessor "androidx.room:room-compiler:2.2.6"
testImplementation "androidx.room:room-testing:2.2.6"
implementation "androidx.room:room-runtime:2.2.6"

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接