Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding Custom Lint Rules

Tags:

java

android

lint

I am following the tutorial on this(http://tools.android.com/tips/lint-custom-rules) page. I am stuck at the step:

lint --show MyId

I get the following error message, any ideas?

Could not load custom rule jar file /Users/me/.android/lint/CustomLintRule.jar java.lang.NoSuchMethodError: com.android.tools.lint.detector.api.Issue.create(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lcom/android/tools/lint/detector/api/Category;ILcom/android/tools/lint/detector/api/Severity;Ljava/lang/Class;Ljava/util/EnumSet;)Lcom/android/tools/lint/detector/api/Issue; at googleio.demo.MyDetector.(MyDetector.java:16) at googleio.demo.MyIssueRegistry.getIssues(MyIssueRegistry.java:15) at com.android.tools.lint.client.api.JarFileIssueRegistry.(JarFileIssueRegistry.java:93) at com.android.tools.lint.client.api.JarFileIssueRegistry.get(JarFileIssueRegistry.java:70) at com.android.tools.lint.client.api.LintClient.addCustomLintRules(LintClient.java:911) at com.android.tools.lint.Main.getGlobalRegistry(Main.java:642) at com.android.tools.lint.Main.run(Main.java:204) at com.android.tools.lint.Main.main(Main.java:113) Invalid id or category "MyId".

like image 989
guydemossyrock Avatar asked Sep 05 '14 07:09

guydemossyrock


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.

What is lint in gradle?

GitHub - nebula-plugins/gradle-lint-plugin: A pluggable and configurable linter tool for identifying and reporting on patterns of misuse or deprecations in Gradle scripts.


1 Answers

I was same too.

  1. I'm using mac and AndroidStudio 0.8.6.
  2. I exported "customrule.jar" in Eclipse using lint-api.jar in "/Applications/Android Studio.app/sdk/tools/lib".
  3. Eclise project for the rule is compiled well with the lint-api.jar.
  4. But, when I run "lint --show MyId", I got the same error.

So I downloaded adt-bundle and I tried with "lint-api.jar" in it and the error was gone.

I think "lint-api.jar" included in AndroidStudio is something wrong...

like image 166
Sean Avatar answered Oct 19 '22 11:10

Sean