Lint api和kotlin api太旧,可能导致java.lang.NoSuchFieldError:Companion

时间:2019-05-08 07:03:10

标签: android sdk

当我像这样用kotlin编写自定义棉绒规则时:

class AlarmDetector : Detector(), SourceCodeScanner {
companion object Issues {
    private val IMPLEMENTATION = Implementation(
        AlarmDetector::class.java,
        Scope.JAVA_FILE_SCOPE
    )

    /** Alarm set too soon/frequently   */
    @JvmField
    val ISSUE = Issue.create(
        id = "ShortAlarm",
        briefDescription = "Short or Frequent Alarm",
        explanation = """
        Frequent alarms are bad for battery life. As of API 22, the `AlarmManager` will override \
        near-future and high-frequency alarm requests, delaying the alarm at least 5 seconds into the \
        future and ensuring that the repeat interval is at least 60 seconds.

        If you really need to do work sooner than 5 seconds, post a delayed message or runnable to a \
        Handler.""",
        category = Category.CORRECTNESS,
        priority = 6,
        severity = Severity.WARNING,
        implementation = IMPLEMENTATION
    )
}
other code ...

组装lint.jar之后,将其放置到“ /.android/lint”

使用android gradle插件:3.1.1在我的项目中运行良好

但是当我使用以下命令在android sdk(sdk / tools / bin / lint)中使用lint工具时:lint --show

我遇到错误

Could not load custom lint check jar file 
java.lang.NoSuchFieldError: Companion

我发现最新的SDK工具是26.1.1 https://developer.android.com/studio/releases/sdk-tools

lint&lint-api&lint-check的版本为26.0.0-dev kotlin-stdlib的版本是1.1.3 它太旧了 我希望SDK工具中的棉绒能够更新

0 个答案:

没有答案
相关问题