Checker Framework를 사용하여 런타임시 Nullability failure, UI constraint failure 등의 내 app-checking에 대한 정적 분석을하고 싶습니다. https://checkerframework.org/manual/#android-gradle의 지침을 따라 실행했지만 checkTypes가 작업이 아니라는 오류가 나타납니다. 나는 지침을 올바르게 따라 갔다고 생각하고, 그들이 가지고있는 대소 문자 불일치를 수정했다. 어떤 아이디어가 그것을 고칠 수 있습니까? 내 build.gradle은 다음과 같습니다 :안드로이드에서 Checker Framework 실행하기
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
google()
}
apply plugin: 'jacoco'
apply plugin: 'com.getkeepsafe.dexcount'
gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xmaxerrs" << "500"
}
}
android {
compileSdkVersion 25
buildToolsVersion '26.0.2'
defaultConfig {
applicationId "com.handshake.hsdm"
minSdkVersion 19
targetSdkVersion 25
versionCode 35
versionName "0.0.35"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
testCoverageEnabled = false
}
debug {
testCoverageEnabled = false
}
checkTypes {
javaCompileOptions.annotationProcessorOptions.
classNames.add("org.checkerframework.checker.guieffect.GuiEffectChecker")
// You can pass options like so:
// javaCompileOptions.annotationProcessorOptions.arguments.put("warns", "")
}
}
dexOptions {
preDexLibraries = false
}
sourceSets {
main {
manifest.srcFile 'src/main/AndroidManifest.xml'
}
}
packagingOptions {
//These files constantly step on each other from multiple libraries, don't include them
exclude 'META-INF/ASL2.0'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/*'
exclude 'plugin.xml'
exclude 'plugin.properties'
exclude 'about_files/LICENSE-2.0.txt'
}
testOptions {
unitTests.all {
jacoco {
includeNoLocationClasses = true
}
}
}
jacoco {
version = '0.7.3.201502191951'
}
configurations.all {
resolutionStrategy.force 'com.google.code.findbugs:jsr305:2.0.1'
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
configurations {
checkerFrameworkAnnotatedJDK {
description = 'a copy of JDK classes with Checker Framework type qualifers inserted'
}
}
task jacocoTestReport(type: JacocoReport, dependsOn: ['testDebugUnitTest', 'createDebugCoverageReport']) {
reports {
xml.enabled = true
html.enabled = true
}
def fileFilter = ['**/R.class', '**/R$*.class', '**/BuildConfig.*', '**/Manifest*.*', '**/*Test*.*', 'android/**/*.*',
'com/handshake/hsdm/demo/**','com/handshake/hsdm/localstorage/schema1/*Dao*',
'com/handshake/hsdm/localstorage/schema1/*Factory*', 'com/handshake/hsdm/dagger2',
'**/*Module*', '**/*_Factory*', '**/*_MembersInjector*'
]
def debugTree = fileTree(dir: "${buildDir}/intermediates/classes/debug", excludes: fileFilter)
def mainSrc = "${project.projectDir}/src/main/java"
sourceDirectories = files([mainSrc])
classDirectories = files([debugTree])
executionData = fileTree(dir: "$buildDir", includes: [
"jacoco/testDebugUnitTest.exec",
"outputs/code-coverage/connected/*coverage.ec"
])
afterEvaluate {
classDirectories = files(classDirectories.files.collect {
fileTree(dir: it, exclude: ['com/handshake/hsdm/demo/**'])
})
}
}
dependencies {
//Clipping dependencies
ext.checkerFrameworkVersion = '2.2.1'
implementation "org.checkerframework:checker-qual:${checkerFrameworkVersion}"
annotationProcessor "org.checkerframework:checker:${checkerFrameworkVersion}"
checkerFrameworkAnnotatedJDK "org.checkerframework:jdk8:${checkerFrameworkVersion}"
}
apply plugin: 'com.google.gms.google-services'
gradle.projectsEvaluated {
tasks.withType(JavaCompile).all { compile ->
if (compile.name.contains("checkTypes")) {
compile.options.compilerArgs += [
"-Xbootclasspath/p:${configurations.checkerFrameworkAnnotatedJDK.asPath}"
]
}
}
}
편집 : 미래 라인 javaCompileOptions.annotationProcessorOptions.classNames + = [ "org.checkerframework.checker.nullness.NullnessChecker을"] readers-의 경우 문제가 될 것으로 보인다. 단검 및 기타 주석 처리기를 실행하지만 분명히 검사기가 실행되지는 않습니다.
어디에서 어떻게 오류가 표시됩니까? – CommonsWare
gradlew checkTypes를 실행할 때. 정확한 메시지는 "* 무엇이 잘못 되었습니까 : ''HSDM '루트 프로젝트에'checkTypes '태스크가 없습니다." –
그들의 문서는 "체커를 실행하려면 checkTypes 변형을 사용하여 빌드하십시오"라고 말합니다. 'gradlew checkTypes' 아래의 줄은 잘못되었습니다. 빌드 유형을 만드는 방법이 아니기 때문에,'gradlew debug'를 통해'debug' 빌드를 만드는 것 이상입니다. 그것은'gradlew assembleDebug' 또는'gradlew installDebug'입니다. 그러나, 나는'checkTypes '와 같은 대소 문자가 혼합 된 빌드 유형을 시도한 적이 없으므로 작업 이름이 어떻게 조합되는지 모르겠습니다. Android Studio의 Gradle 도구를보고 어떤 작업이 있는지 확인하거나 명령 줄에 작업 목록을 표시하고 표시되는 내용을 확인합니다. – CommonsWare