I would like to be able to run the lint task when I'm building projects with the android studio to ensure the lint rules are being followed.
I have tried using task dependencies but with no luck. My TeamCity build server uses the build task which runs the lint task so that works great. However, the android studio appears to use generateDebugSources
and compileDebugJava
tasks interchangeably when I have selected the debug build variant.
Here is what I have tried in my build.gradle:
assemble.dependsOn lint
Run lint using the standalone tool If you're not using Android Studio or Gradle, you can use the standalone lint tool after you install the Android SDK Command-Line Tools from the SDK Manager. You can then locate the lint tool at android_sdk /cmdline-tools/ version /bin/lint .
Description. The lint command checks C and C++ language source code for coding and syntax errors and for inefficient or non-portable code. You can use this program to: Identify source code and library incompatibility. Enforce type-checking rules more strictly than does the compiler.
If you just want to configure your Android Studio project to run the lint check before the default run configuration without affecting how your gradle tasks are configured, you can follow these steps.
:app:check
)check
step before the existing Gradle-aware make
stepNow, Android Studio will run the lint check and fail the build if any lint errors occur.
To runt lint and analyze your project, simply select Analyze > Inspect Code
.
You should get a nice window with all issues.
Also check Run lint in Android Studio for more information.
I did a little more research, try adding this to your build.gradle
.
lintOptions { abortOnError true }
There are many options that you can apply to the build.gradle
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With