Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom Lint Rule not listed in eclipse / android studio

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

  1. Created JAR with custom lint check rule
  2. Placed the jar into ~/.android/lint

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

like image 617
Kirtan Avatar asked Oct 28 '14 08:10

Kirtan


People also ask

How do I enable lint?

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.

How do you do lint check on Android?

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.

What is lint rules in Android Studio?

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.

How do I create a lint rule in Eclipse?

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.

How do I suppress Lint checks in Android Studio?

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.

What is lint tool in Android Studio?

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.


1 Answers

i solved this by adding jar module into project and explicitly specifying lint dependency in app.gradle

lintChecks project(':your_module_name')  
like image 72
Pwn Avatar answered Sep 20 '22 11:09

Pwn