Android androidTestUtil 配置中的并非所有文件都是 APK 导致的 Lint 基础结构错误
Android Lint Infrastructure error caused by Not all files in androidTestUtil configuration are APKs
在 gradle 中迁移到 Kotlin DSL 后,我正在使用 android lint,开始出现此错误
Execution failed for task ':base:lintDebug'.
> Lint infrastructure error
Caused by: java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at com.android.tools.lint.gradle.api.ReflectiveLintRunner.runLint(ReflectiveLintRunner.kt:37)
at com.android.build.gradle.tasks.LintBaseTask.runLint(LintBaseTask.java:133)
at com.android.build.gradle.tasks.LintPerVariantTask.doTaskAction(LintPerVariantTask.java:52)
at com.android.build.gradle.internal.tasks.NonIncrementalGlobalTask$taskAction$$inlined$recordTaskAction.invoke(BaseTask.kt:63)
at com.android.build.gradle.internal.tasks.Blocks.recordSpan(Blocks.java:51)
......
Caused by: com.android.builder.errors.EvalIssueException: Not all files in androidTestUtil configuration are APKs: /Users/me/.gradle/caches/modules-2/files-2.1/androidx.annotation/annotation/1.0.0/45599f2cd5965ac05a1488fa2a5c0cdd7c499ead/annotation-1.0.0.jar /Users/me/.gradle/caches/modules-2/files-2.1/androidx.test/monitor/1.3.0/60a29f8cfadc1a8e841d96dad42483d681130a9c/monitor-1.3.0.aar /Users/me/.gradle/caches/modules-2/files-2.1/androidx.test/rules/1.3.0/f7030a787ad72ccc283f24f3325336846fd521d5/rules-1.3.0.aar /Users/me/.gradle/caches/modules-2/files-2.1/androidx.test/runner/1.3.0/e8862a8d71f5a8ab90d822b7d9349c7e4e74e49b/runner-1.3.0.aar /Users/me/.gradle/caches/modules-2/files-2.1/junit/junit/4.12/2973d150c0dc1fefe998f834810d68f278ea58ec/junit-4.12.jar /Users/me/.gradle/caches/modules-2/files-2.1/org.hamcrest/hamcrest-core/1.3/42a25dc3219429f0e5d060061f71acb49bf010a0/hamcrest-core-1.3.jar
我有以下 lintOptions
lintOptions {
abortOnError !project.hasProperty("runBaseline")
warningsAsErrors true
checkReleaseBuilds false
absolutePaths = false
lintConfig file('../lint.xml')
if (!project.hasProperty("runBaseline")) {
baseline file("lint-baseline.xml")
} else if (project.name == "base"){
lintConfig file('../lint-for-baseline.xml')
}
htmlOutput file("$project.buildDir/outputs/reports/lint.html")
xmlOutput file("$project.buildDir/outputs/reports/lint-report.xml")
}
他们没有改变。它在 CI 和本地失败,所以我认为它与本地的 Android Studio 无关(意味着无效缓存没有帮助),而是与项目本身有关。
更新到 AGP 7.0 解决了故障。我仍然有这个警告,但它不会导致 lint 失败。你可以跟踪 https://issuetracker.google.com/issues/195342726
Not all files in androidTestUtil configuration are APKs: /Users/me/.gradle/caches/modules-2/files-2.1/androidx.annotation/annotation/1.0.0/45599f2cd5965ac05a1488fa2a5c0cdd7c499ead/annotation-1.0.0.jar /Users/me/.gradle/caches/modules-2/files-2.1/androidx.test/monitor/1.3.0/60a29f8cfadc1a8e841d96dad42483d681130a9c/monitor-1.3.0.aar /Users/me/.gradle/caches/modules-2/files-2.1/androidx.test/rules/1.3.0/f7030a787ad72ccc283f24f3325336846fd521d5/rules-1.3.0.aar /Users/me/.gradle/caches/modules-2/files-2.1/androidx.test/runner/1.3.0/e8862a8d71f5a8ab90d822b7d9349c7e4e74e49b/runner-1.3.0.aar /Users/me/.gradle/caches/modules-2/files-2.1/junit/junit/4.12/2973d150c0dc1fefe998f834810d68f278ea58ec/junit-4.12.jar /Users/me/.gradle/caches/modules-2/files-2.1/org.hamcrest/hamcrest-core/1.3/42a25dc3219429f0e5d060061f71acb49bf010a0/hamcrest-core-1.3.jar
在 gradle 中迁移到 Kotlin DSL 后,我正在使用 android lint,开始出现此错误
Execution failed for task ':base:lintDebug'.
> Lint infrastructure error
Caused by: java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at com.android.tools.lint.gradle.api.ReflectiveLintRunner.runLint(ReflectiveLintRunner.kt:37)
at com.android.build.gradle.tasks.LintBaseTask.runLint(LintBaseTask.java:133)
at com.android.build.gradle.tasks.LintPerVariantTask.doTaskAction(LintPerVariantTask.java:52)
at com.android.build.gradle.internal.tasks.NonIncrementalGlobalTask$taskAction$$inlined$recordTaskAction.invoke(BaseTask.kt:63)
at com.android.build.gradle.internal.tasks.Blocks.recordSpan(Blocks.java:51)
......
Caused by: com.android.builder.errors.EvalIssueException: Not all files in androidTestUtil configuration are APKs: /Users/me/.gradle/caches/modules-2/files-2.1/androidx.annotation/annotation/1.0.0/45599f2cd5965ac05a1488fa2a5c0cdd7c499ead/annotation-1.0.0.jar /Users/me/.gradle/caches/modules-2/files-2.1/androidx.test/monitor/1.3.0/60a29f8cfadc1a8e841d96dad42483d681130a9c/monitor-1.3.0.aar /Users/me/.gradle/caches/modules-2/files-2.1/androidx.test/rules/1.3.0/f7030a787ad72ccc283f24f3325336846fd521d5/rules-1.3.0.aar /Users/me/.gradle/caches/modules-2/files-2.1/androidx.test/runner/1.3.0/e8862a8d71f5a8ab90d822b7d9349c7e4e74e49b/runner-1.3.0.aar /Users/me/.gradle/caches/modules-2/files-2.1/junit/junit/4.12/2973d150c0dc1fefe998f834810d68f278ea58ec/junit-4.12.jar /Users/me/.gradle/caches/modules-2/files-2.1/org.hamcrest/hamcrest-core/1.3/42a25dc3219429f0e5d060061f71acb49bf010a0/hamcrest-core-1.3.jar
我有以下 lintOptions
lintOptions {
abortOnError !project.hasProperty("runBaseline")
warningsAsErrors true
checkReleaseBuilds false
absolutePaths = false
lintConfig file('../lint.xml')
if (!project.hasProperty("runBaseline")) {
baseline file("lint-baseline.xml")
} else if (project.name == "base"){
lintConfig file('../lint-for-baseline.xml')
}
htmlOutput file("$project.buildDir/outputs/reports/lint.html")
xmlOutput file("$project.buildDir/outputs/reports/lint-report.xml")
}
他们没有改变。它在 CI 和本地失败,所以我认为它与本地的 Android Studio 无关(意味着无效缓存没有帮助),而是与项目本身有关。
更新到 AGP 7.0 解决了故障。我仍然有这个警告,但它不会导致 lint 失败。你可以跟踪 https://issuetracker.google.com/issues/195342726
Not all files in androidTestUtil configuration are APKs: /Users/me/.gradle/caches/modules-2/files-2.1/androidx.annotation/annotation/1.0.0/45599f2cd5965ac05a1488fa2a5c0cdd7c499ead/annotation-1.0.0.jar /Users/me/.gradle/caches/modules-2/files-2.1/androidx.test/monitor/1.3.0/60a29f8cfadc1a8e841d96dad42483d681130a9c/monitor-1.3.0.aar /Users/me/.gradle/caches/modules-2/files-2.1/androidx.test/rules/1.3.0/f7030a787ad72ccc283f24f3325336846fd521d5/rules-1.3.0.aar /Users/me/.gradle/caches/modules-2/files-2.1/androidx.test/runner/1.3.0/e8862a8d71f5a8ab90d822b7d9349c7e4e74e49b/runner-1.3.0.aar /Users/me/.gradle/caches/modules-2/files-2.1/junit/junit/4.12/2973d150c0dc1fefe998f834810d68f278ea58ec/junit-4.12.jar /Users/me/.gradle/caches/modules-2/files-2.1/org.hamcrest/hamcrest-core/1.3/42a25dc3219429f0e5d060061f71acb49bf010a0/hamcrest-core-1.3.jar