【问题标题】:How to suppress Lint warnings in generated sources?如何在生成的源中抑制 Lint 警告?
【发布时间】:2019-08-07 15:58:27
【问题描述】:

带房间版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"

RoomDatabase@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 运行它,你可以在其中指定范围。

标签: android android-room androidx deprecation-warning android-lint


【解决方案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"

【讨论】:

    猜你喜欢
    • 2016-12-24
    • 2021-02-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-02-11
    • 2020-12-27
    • 2019-04-23
    • 2013-11-07
    相关资源
    最近更新 更多