Gonzalo
Gonzalo

Reputation: 3764

'Calling new methods on older versions' lint check not finding higher than minimum api calls in Android Studio

I'm developing an Android app on Android Studio and I'm calling a method from API level 19. My build.gradle looks like this:

android {
    compileSdkVersion 24
    buildToolsVersion '24.0.2'

    productFlavors {
        // Define separate dev and prod product flavors.
        dev {
            // dev utilizes minSDKVersion = 21 to allow the Android gradle plugin
            // to pre-dex each module and produce an APK that can be tested on
            // Android Lollipop without time consuming dex merging processes.
            minSdkVersion 21
        }
        prod {
            // The actual minSdkVersion for the application.
            minSdkVersion 16
        }
    }

    defaultConfig {
        applicationId "com.myapp"
        minSdkVersion 16
        multiDexEnabled true
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"
    }
}

I have no lint.xml files in my project, so no lint checks are overriden.

The problem is that the lint check "Calling new methods on older versions." doesn't find the method call for API level 19. If I open the build variants panel and select prodDebug or prodRelease the method gets underlined in red, but the project builds well. How can I get Android Studio to effectively show the aforementioned method in the analyze result or to block me from correctly building the project?

Edit I found a way to search for methods not complying with the minimum SDK. By going to the Gradle panel on the right and running the lint task, an HTML report is generated, which finally shows the API 19 call along with other calls. Why is this not implemented into Android Studio?

Since this still does not work in Android Studio per se, but rather in Gradle, I'm not closing the question yet.

Upvotes: 4

Views: 1514

Answers (1)

Pavneet_Singh
Pavneet_Singh

Reputation: 37414

Gradle won't tell you if you are using the methods that are not supported in you minSDK if your compiled SDK version is not the minimum one. read more about it

So simply the solution is use lint feature i.e inspectcode

right click , either on project/class then => analyze=>inspectCode

Upvotes: 1

Related Questions