Adding Custom Lint Rules

↘锁芯ラ 提交于 2019-12-10 12:55:55

问题


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:


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



来源:https://stackoverflow.com/questions/25680418/adding-custom-lint-rules

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!