7
votes

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".

1
Looks like you're compiling against one version of the API and running against another. See the note in the create issue section about using Tools 22. - brindy
I compiled the jar with lint-api-23.0.2.jar and also my lint version 23.0.2 when i check at my teerminal by lint --version. Still getting the same error. - guydemossyrock
Can you post the code you've got? I am guessing you're calling the 7 argument version of #create since that's the one it can't find - but the Tools 22+ version takes 8 arguments, which means your classpath at build time might have something errant about it. - brindy
Actually i am using the exact same project on the tools.android.com/tips/lint-custom-rules. So my code is, public static final Issue ISSUE = Issue.create( "MyId", "My brief summary of the issue", "My summary of what the detector looks for", "My longer explanation of the issue", Category.CORRECTNESS, 6, Severity.WARNING, new Implementation(MyDetector.class, Scope.RESOURCE_FILE_SCOPE)); - guydemossyrock

1 Answers

1
votes

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...