Lint error with Fragments on Android L: “This meth

2020-06-16 02:59发布

问题:

This method is not overriding anything with the current build target, but will in API level 11 (current target is 1).

How do I neutralize this error? The app compiles and runs. I'm using gradle:

android {
    compileSdkVersion "android-L"
    buildToolsVersion "19.1.0"

    defaultConfig {
        applicationId "com.codepath.apps.restclienttemplate"
        minSdkVersion 14
        targetSdkVersion "android-L"
    }
    ....
}

According to to the <uses-sdk> docs, if minSdkVersion is absent it defaults to 1, so I'm thinking lint doesn't know what version is required.

回答1:

Try this, worked for me:

  1. download android-21 sdk from here: https://mega.co.nz/#!klwQWQ6Z!seD3n0x9dkTyR29c7HxNE6XkHXtmpjfcbYrfntVOXmY

  2. unzip it in you sdk path

  3. in your gradle build file change this

compileSdkVersion "android-L" buildToolsVersion "19.1.0"

to

compileSdkVersion 21
buildToolsVersion "20.0.0"


回答2:

Experienced the same issue on Android Studion v0.8.0 (it was downloaded from official website, and it wasn't the latest version for that time (:sad) )

Just update the programm (Help -> Check for Update...). In my case I updated to 0.8.6 and the issue has gone.



回答3:

I suspect that strings for API levels such as android-L or L resolves to 1 for the API level and it sees tons of methods that don't exist until later API levels (even very low API level methods added in 4 or 7).

Since the SDK is a preview and not final, I added this to my lint.xml file:

<!-- Android L pre-release disabled checks -->
<issue id="Override" severity="ignore"/>

Be sure to remove it once Android L's SDK is officially released and you can use 21 instead of a string.