Search code examples
android-studiosuppress-warningsclang-tidy

How to tell AndroidStudio to be less pedantic about native code


I am using AndroidStudio to build NDK based applications with C and C++ code.

The IDE goes overboard with warnings, like the one below:

clang-tidy warning

How can I disable this and other gratuitous warnings from the IDE? Is this done on a per-project base, or an IDE setting? In any case, the deluge of warnings are not helping.

  • Ubuntu LTS
  • Android Studio 3.5
  • Native code built via gradle/cmake.

Solution

  • Release notes of Android Studio state:

    Android Studio now includes support for static code analysis using Clang-Tidy for projects that include native code. To enable support for Clang-Tidy, update your NDK to r18 or higher. You can then enable or re-enable the inspections by opening the Settings or Preferences dialog and navigating to Editor > Inspections > C/C++ > General > Clang-Tidy. When selecting this inspection in the Settings or Preferences dialog, you can also see the list of Clang-Tidy checks that are enabled and disabled under the Option section of the right-most panel.

    To disable the warnings just go to:

    Preferences->Editor->Inspections->C/C++->General->Clang-tidy

    and uncheck Clang-tidy or edit the list of checks to disable those that annoy you.