Android Studio kullanarak bir Android projesi oluşturuyorum. Uygulamanın build.gradle
ekleyin: Özellik denetim kutusu yapılandırma dosyasında hata yok
apply from: '../config/quality.gradle'
Sonra iki dosyalarla
config
dir oluşturun:
quality.gradle
gibi: gibi
apply plugin: 'checkstyle'
task checkstyle(type: Checkstyle) {
configFile file("${project.rootDir}/config/checkstyle.xml")
source 'src'
include '**/*.java'
exclude '**/gen/**'
classpath = files()
}
Ve checkstyle.xml
:
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
"http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
<module name="Checker">
<module name="TreeWalker">
<module name="NeedBraces">
<property name="tokens" value="LITERAL_CASE, LITERAL_DEFAULT"/>
<property name="allowSingleLineStatement" value="true"/>
</module>
</module>
</module>
Running gradle checkstyle
bana verir takip eden hata:
Executing external task 'checkstyle'...
:app:checkstyle FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:checkstyle'.
> Unable to create a Checker: cannot initialize module TreeWalker - Property 'allowSingleLineStatement' in module NeedBraces does not exist, please check the documentation
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
çizgiyi kaldırırsanız:
çalışır<property name="allowSingleLineStatement" value="true"/>
. Ama documentation'u okurken, ilk versiyonu da çalışmalı.
O benzer olur: Yanlış veya ne şekilde yapıyorum
* What went wrong:
Execution failed for task ':app:checkstyle'.
> Unable to create a Checker: cannot initialize module TreeWalker - Unable to instantiate EmptyCatchBlock
dokümanlar bu missunderstanding am:
<module name="EmptyCatchBlock">
<property name="exceptionVariableName" value="expected|ignore"/>
</module>
beni atar mı?
'' file' anahtar sözcüğüyle 'configFile' yolundan önce çıkmam gerektiğine dikkat edin, ancak çözüm işe yaradı. Çok teşekkür ederim Thomas. – Birei
Yup, 'configFile' bir' Dosya'; cevabımı buna göre güncelledi. Teşekkürler! –
bu çözümü denedi, ancak IDEA bana 'Hata: (12, 0) Gradle: ': app' projesini değerlendirirken bir sorun oluştu. > Proje aracı argümanı için yöntem bulunamadı: (6.7) ': app'.' – pratt