Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lint errors if minSdk < 11 #3356

Closed
grandstaish opened this issue Aug 27, 2016 · 6 comments
Closed

Lint errors if minSdk < 11 #3356

grandstaish opened this issue Aug 27, 2016 · 6 comments
Assignees
Labels

Comments

@grandstaish
Copy link

grandstaish commented Aug 27, 2016

Apparently Realm should work on Android all the way down to API 9 (https://realm.io/docs/java/latest/#prerequisites), but if your minSdk is below 11, you get a whole bunch of lint errors that break the build (even with a new Realm sample).

@zaki50
Copy link
Contributor

zaki50 commented Aug 27, 2016

I couldn't reproduce this.

Could you share your build.gradle?

@grandstaish
Copy link
Author

grandstaish commented Aug 27, 2016

Sure, though it's a pretty basic gradle file. I was just trying Realm out:

apply plugin: 'com.android.application'
apply plugin: 'realm-android'

android {
  compileSdkVersion rootProject.ext.compileSdkVersion  // <-- this is 24
  buildToolsVersion rootProject.ext.buildToolsVersion  // <-- this is 24.0.2

  defaultConfig {
    applicationId "nz.bradcampbell.realmexample"
    minSdkVersion rootProject.ext.minSdkVersion // <-- this is 9
    targetSdkVersion rootProject.ext.targetSdkVersion // <-- this is 24
    versionCode 1
    versionName "1.0"
  }

  compileOptions {
    sourceCompatibility rootProject.ext.sourceCompatibilityVersion  // <-- this is 1.7
    targetCompatibility rootProject.ext.targetCompatibilityVersion // <-- this is 1.7
  }
}

dependencies {
  compile deps.supportAnnotations // latest
  compile deps.appCompat // latest
}

The errors were all to do with JsonReader APIs:

e.g.:

  • Call requires API level 11 (current min is 9): android.util.JsonReader#beginObject
  • Call requires API level 11 (current min is 9): android.util.JsonReader#hasNext
  • Etc.

Are you suppressing your lint errors?

@kneth
Copy link
Contributor

kneth commented Aug 29, 2016

The proxy classes have @SuppressWarnings("cast").

@Zhuinden
Copy link
Contributor

@kneth this discussion reminds me of #489 (comment)

@zaki50
Copy link
Contributor

zaki50 commented Aug 29, 2016

@grandstaish Thank you for providing detailed information.

I reproduced this issue.
./gradlew :app:lint reports errors of NewApi: Calling new methods on older versions.

Realm has a method that uses JsonReader in proxy classed but that method does not have @TargetApi(Build.VERSION_CODES.HONEYCOMB).
Because of this, lint reports errors even if the method is not used at all from user code.

It's a bug of Realm and should be fixed.

And we should update our documentation about limited support of Realm#create*FromJson() methods that take InputStream as a parameter.
Those methods only support Android 3.0 or later, but it is not mentioned in our documentation (those methods have an annotation of @TargetApi(Build.VERSION_CODES.HONEYCOMB) but the annotation is not shown in our API reference).

@zaki50
Copy link
Contributor

zaki50 commented Aug 30, 2016

Fixed in releases branch.
This issue will be solved in next release.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

5 participants