I have created custom android Lint check rule it works well when I run it from command line but Android Studio does not take that rule when checking it with "Inspect Code".I have selected all the Lint Rules in Inspection Profile of android studio.
What I did is
When I run the lint checking from command line it works as it should. like below output shows it check against the rule.
lint OpenGLLearning
Scanning OpenGLLearning: ...............................
Scanning OpenGLLearning (Phase 2): ....
res/layout/activity_opengl.xml:8: Error: Edit Text ID Must be starting with et [etName]
<EditText
^
Here etName is my Issue ID for custom lint rule which I created. but Android Studio does not list "etName" rule anywhere and not show error when checked against lint with Inspect Code.
when I run
./gradlew check
it does checks against rule.and custom rule also appears when I run lint --list command on terminal but not able to figure out why it not checked by Inspect Code in Android Studio.
I am using build tools 21.0.2 and Target Version 21
Tip: You can manage the lint checking feature for your Java, Kotlin, or XML source files in the Default Preferences dialog. Select File > Other Settings > Default Settings, and then in the left pane of the Default Preferences dialog, select Editor > Inspections.
Lint checks are automatically performed by the Gradle build system. To see the available checks in Android Studio File Settings Editor Inspections. You can also run the lint checks manually by right-clicking on your project and select Analyze Inspect Code. You can run link also from the command line.
Android build system provides a lot of Lint rules that are quite helpful such as Hardcoded String in xml layout, Missing Permissions in Java/Kotlin code. After lint runs over the codebase, it generates a report in html and xml showing warnings and errors. Sometimes, based on your requirements, you may need to write your custom lint rules.
If you're using Eclipse, create a plain Java project using a simple library: Next, add the lint_api.jar file to the classpath of the project. This jar file contains the Lint APIs that rules implement.
For example, you can suppress lint checking for specific issues that are not relevant to your project and, you can configure lint to report non-critical issues at a lower severity level. The built-in lint tool checks your code while you're using Android Studio. You can view warnings and errors in two ways: As pop-up text in the Code Editor.
The lint tool. A static code scanning tool that you can run on your Android project either from the command line or in Android Studio (see Manually run inspections). The lint tool checks for structural code problems that could affect the quality and performance of your Android application.
i solved this by adding jar module into project and explicitly specifying lint dependency in app.gradle
lintChecks project(':your_module_name')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With