How Do We Configure Android Studio to Run Its Lint on Every Build?

前端 未结 4 528
清酒与你
清酒与你 2020-12-12 19:21

Once upon a time, particularly in Eclipse-land, Lint would run on every build, and so if you failed Lint checks, you would find out immediately. With Android Studio (tested

4条回答
  •  眼角桃花
    2020-12-12 20:13

    Create inspection profile for Android Lint

    1. Go to File -> Settings -> Editor/Inspection
    2. Select Manage -> Copy
    3. Give it name "Android Lint Profile" and press Enter
    4. Leave marked only Android Lint rules on this tab

    Now you can run inspection only with Android Lint rules via Analyze->Inspect Code... by selecting "Android Lint Profile".

    On the next step, let's record Macro (Edit->Macros->Start Macro Recording) with next steps.

    1. Analyze->Inspect Code...
    2. Select "Android Lint Profile"
    3. Press Enter (it is important to use keyboard because Macro recorder doesn't catch mouse clicks on this windows)
    4. Click on "Run Selected Configuration" (green play button)

    Stop the macro recording and give it the name "Lint and Run".

    Final thing that should be done is mapping "Shift+F10" to our macro. Go to File->Settings...->Keymap. Find our macro and change shortcut.

    Now lint will be run before each build when you press Shift+F10 and results will be in Android Studio panel.

    But this solution have one big drawback. If you run your build by clicking on the Run button lint analysis will not be executed.

    May be this info will be helpful and someone will provide better solution using it.

提交回复
热议问题