(#) String should be int !!! ERROR: String should be int This is an error. Id : `StringShouldBeInt` Summary : String should be int Severity : Error Category : Correctness Platform : Android Vendor : Android Open Source Project Feedback : https://issuetracker.google.com/issues/new?component=192708 Since : Initial Affects : Gradle build files Editing : This check runs on the fly in the IDE editor Implementation : [Source Code](https://cs.android.com/android-studio/platform/tools/base/+/mirror-goog-studio-main:lint/libs/lint-checks/src/main/java/com/android/tools/lint/checks/GradleDetector.kt) Tests : [Source Code](https://cs.android.com/android-studio/platform/tools/base/+/mirror-goog-studio-main:lint/libs/lint-tests/src/test/java/com/android/tools/lint/checks/GradleDetectorTest.kt) Copyright Year : 2014 The properties `compileSdkVersion`, `minSdkVersion` and `targetSdkVersion` are usually numbers, but can be strings when you are using an add-on (in the case of `compileSdkVersion`) or a preview platform (for the other two properties). However, you can not use a number as a string (e.g. "19" instead of 19); that will result in a platform not found error message at build/sync time. !!! Tip This lint check has an associated quickfix available in the IDE. (##) Example Here is an example of lint warnings produced by this check: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text build.gradle:4:Error: Use an integer rather than a string here (replace '19' with just 19) [StringShouldBeInt] compileSdkVersion '19' ---------------------- build.gradle:7:Error: Use an integer rather than a string here (replace '8' with just 8) [StringShouldBeInt] minSdkVersion '8' ----------------- build.gradle:8:Error: Use an integer rather than a string here (replace "16" with just 16) [StringShouldBeInt] targetSdkVersion "16" --------------------- build.gradle:10:Error: Use an integer rather than a string here (replace '19' with just 19) [StringShouldBeInt] compileSdk '19' --------------- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Here is the source file referenced above: `build.gradle`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~groovy linenumbers apply plugin: 'com.android.application' android { compileSdkVersion '19' buildToolsVersion "19.0.1" defaultConfig { minSdkVersion '8' targetSdkVersion "16" } compileSdk '19' } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ You can also visit the [source code](https://cs.android.com/android-studio/platform/tools/base/+/mirror-goog-studio-main:lint/libs/lint-tests/src/test/java/com/android/tools/lint/checks/GradleDetectorTest.kt) for the unit tests for this check to see additional scenarios. The above example was automatically extracted from the first unit test found for this lint check, `GradleDetector.testStringInt`. To report a problem with this extracted sample, visit https://issuetracker.google.com/issues/new?component=192708. (##) Suppressing You can suppress false positives using one of the following mechanisms: * Using a suppression comment like this on the line above: ```kt //noinspection StringShouldBeInt problematicStatement() ``` * Using a special `lint.xml` file in the source tree which turns off the check in that folder and any sub folder. A simple file might look like this: ```xml <?xml version="1.0" encoding="UTF-8"?> <lint> <issue id="StringShouldBeInt" severity="ignore" /> </lint> ``` Instead of `ignore` you can also change the severity here, for example from `error` to `warning`. You can find additional documentation on how to filter issues by path, regular expression and so on [here](https://googlesamples.github.io/android-custom-lint-rules/usage/lintxml.md.html). * In Gradle projects, using the DSL syntax to configure lint. For example, you can use something like ```gradle lintOptions { disable 'StringShouldBeInt' } ``` In Android projects this should be nested inside an `android { }` block. * For manual invocations of `lint`, using the `--ignore` flag: ``` $ lint --ignore StringShouldBeInt ...` ``` * Last, but not least, using baselines, as discussed [here](https://googlesamples.github.io/android-custom-lint-rules/usage/baselines.md.html).