Android Lint Options

Yun-ju An
Yun-ju An
Aug 9, 2017 · 4 min read

리소스 정리 해보기.

사용하지 않는 리소스가 많은 경우 or 양이 많아 사용 확인하기 어려운 경우! 쉽게 확인하고, 삭제할 수 있는 있는 방법이 있습니다.

레거시 리소스 포화 상태인 프로젝트를 Android Lint Options 을 사용하여 정리했던 경험을 떠올려 포스팅해보고 합니다 :)

Android Lint ?

안드로이드 애플리케이션을 구성하는 코드를 분석한다. 작성한 코드 내에서 발생할 수 있는 잠재적, 성능에 지장을 줄 수 있는 문제를 미리 검출하여 코드 품질 향상시킨다.

설정 방법 (빌드 스크립트, build.gradle)

Gradle 빌드스크립트 내 lintOptions 항목 하위에 옵션을 추가합니다.

android {
lintOptions {
checkReleaseBuilds false
abortOnError false
}
}

checkReleaseBuilds : Release 빌드시에 Fatal 규칙에 저촉한다면 빌드를 중단

abortOnError : 위험도가 Error 혹은 Fatal의 규칙에 저촉한다면 빌드를 중단

#1 Gradle 을 통한 방법

./gradlew lint 명령 실행 합니다.

$ ./gradlew lint
Incremental java compilation is an incubating feature.
:xxx:preBuild UP-TO-DATE
.....
Ran lint on variant release: 18 issues found
Ran lint on variant debug: 18 issues found
Wrote HTML report to file:///Users/Yun/android/xxx/build/outputs/lint-results-debug.html
Wrote XML report to file:///Users/Yun/android/xxx/build/outputs/lint-results-debug.xml
BUILD SUCCESSFUL
Total time: 27.066 secs
This build could be faster, please consider using the Gradle Daemon: https://docs.gradle.org/2.10/userguide/gradle_daemon.html

내용 확인

build/outputs/lint-results.html

상세한 검사 내용은 해당 경로에서 확인 가능 합니다.

사용하지 않은 리소스 정리 전 vs 정리 후

우선 저는 711개 > 99개 까지 리소스를 제거 하였습니다. (정말 대단..합니다…..어마무시한 숫자.. 2차 작업이 필요합니다.)

#2 Android Studio menu 통한 방법

Project > Analyze > Inspect Code…

Inspection profile ‘…’ 버튼을 누르면 수행할 검사 종류 선택이 가능 합니다.

Lint 외 다른 검사도 가능 하군요.

내용 확인

하단 Inspection 탭에서 상세 내용 확인 가능 합니다.

린트를 통해 깔끔하고 쉽게 코드 개선을 해봅시다. 😉

자세한 내용은 아래를 참고해주세요.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade