Skip to content

Commit e01536a

Browse files
committed
Add sample for Android Studio 3.x
As of 3.0 beta 5, we finally have support for automatically packaging and running lint checks in your project, such that you don't have to add your own local jar copy tasks anymore (or worse, dropping it in ~/.android/lint as the current version of this sample describes). This CL moves the current sample into an android-studio-2 folder, and adds a new adnroid-studio-3 folder with a project showing the new project layout.
1 parent b14198a commit e01536a

File tree

27 files changed

+612
-22
lines changed

27 files changed

+612
-22
lines changed

README.md

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Custom Lint Rules
2-
============
2+
=================
33

44
The [Android `lint` tool](http://developer.android.com/tools/help/lint.html) is a static code
55
analysis tool that checks your Android project source files for potential bugs and optimization
@@ -31,31 +31,15 @@ git clone https://github.com/googlesamples/android-custom-lint-rules.git
3131
cd android-custom-lint-rules
3232
```
3333

34-
##### Build the validator
34+
##### Build the code
3535

36-
`./gradlew build`
37-
38-
##### Copy to the lint directory
39-
40-
`cp ./build/libs/android-custom-lint-rules.jar ~/.android/lint/`
41-
42-
##### Verify whether the issues are registered with lint
43-
44-
`lint --show MainActivityDetector`
45-
46-
##### Run lint
47-
48-
`./gradlew lint`
49-
50-
> Note: If you can't run `lint` directly, you may want to include android tools `PATH` in your
51-
`~/.bash_profile`.
52-
> (i.e. `PATH=$PATH:~/Library/Android/sdk/tools`)
53-
>
54-
> Then run `source ~/.bash_profile`.
36+
For Android Studio 3.x and above, use the sample in `android-studio-3`.
37+
If you are targeting Android Studio 2.x and older, use the sample in `android-studio-2`.
5538

5639
Support
5740
-------
5841

42+
- The "lint-dev" Google group: https://groups.google.com/forum/#!forum/lint-dev
5943
- Google+ Community: https://plus.google.com/communities/105153134372062985968
6044
- Stack Overflow: http://stackoverflow.com/questions/tagged/android
6145

android-studio-2/README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
See README.md in the parent directory for general information.
2+
3+
Getting Started
4+
---------------
5+
6+
##### Fetch code
7+
8+
```
9+
git clone https://github.com/googlesamples/android-custom-lint-rules.git
10+
cd android-custom-lint-rules
11+
```
12+
13+
##### Build the validator
14+
15+
`./gradlew build`
16+
17+
##### Copy to the lint directory
18+
19+
`cp ./build/libs/android-custom-lint-rules.jar ~/.android/lint/`
20+
21+
##### Verify whether the issues are registered with lint
22+
23+
`lint --show MainActivityDetector`
24+
25+
##### Run lint
26+
27+
`./gradlew lint`
28+
29+
> Note: If you can't run `lint` directly, you may want to include android tools `PATH` in your
30+
`~/.bash_profile`.
31+
> (i.e. `PATH=$PATH:~/Library/Android/sdk/tools`)
32+
>
33+
> Then run `source ~/.bash_profile`.

build.gradle renamed to android-studio-2/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ dependencies {
3636

3737
jar {
3838
manifest {
39-
attributes("Lint-Registry-v2": "com.example.google.lint.MyIssueRegistry")
39+
attributes("Lint-Registry": "com.example.google.lint.MyIssueRegistry")
4040
}
4141
}
4242

File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)