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

IidCompatibilityCheckFailure lint check fails with a null pointer exception (NPE)... #1701

Open
yogurtearl opened this issue Jun 23, 2020 · 30 comments
Assignees
Labels
api: installations firebase-installations Firebase Installations service

Comments

@yogurtearl
Copy link

yogurtearl commented Jun 23, 2020

IidCompatibilityCheckFailure lint check fails with a null pointer exception (NPE)...

Using bom 25.4.1 and Iid 20.2.0

The check failed to run as it encountered unknown failure. This is most likely caused by a new version of Android Gradle Plugin that this check does not support. Please make sure your build does not depend on firebase-iid version earlier than 20.1.1 as it will cause issues.

[REQUIRED] Step 2: Describe your environment

  • Android gradle plugin 4.0.0
  • Firebase Component: bom 25.4.1 and Iid 20.2.0

[REQUIRED] Step 3: Describe the problem

Steps to reproduce:

Run lintRelease

Seems to be related to dagger 2.28, or Google places SDK 2.3.0 or androidtimesquare lib 1.7.10

@google-oss-bot
Copy link
Contributor

I found a few problems with this issue:

  • I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.
  • This issue does not seem to follow the issue template. Make sure you provide all the required information.

@ankitaj224
Copy link
Contributor

@yogurtearl Thanks for reporting this issue. I am Ankita from the Firebase team.

I used the following setup you mentioned but I couldn't reproduce this issue:

  • Android gradle plugin 4.0.0
  • Firebase Component: bom 25.4.1 and Iid 20.2.0
  • Gradle version: 6.1.1

It's possible that the firebase-installations lint check could fail to run on a newer version of Android Gradle Plugin. But I tested it out with Android gradle plugin 4.0.0 and the check works as expected.

Could help me with more details like

  • Your app android dependency graph? This will help us identify if you are running any incompatible iid version
  • Any other steps that can help me reproduce this issue.

@yogurtearl
Copy link
Author

I am using Gradle 6.5

@ankitaj224
Copy link
Contributor

Hi @yogurtearl

Thanks for the Gradle version. I tried running with that version and still dint see the check fail. Are you able to consistently run into lint check failure.

@yogurtearl
Copy link
Author

Yes, it is a nullpointerexception, but not sure how to get lint to print the full stack trace.

@perracodex
Copy link

I started to get the same issue in Android Studio when performing a code inspection.

Gradle: 6.1.1

Firebase dependencies:
implementation 'com.google.firebase:firebase-analytics:17.4.4'
implementation 'com.google.firebase:firebase-ml-vision:24.0.3'
implementation 'com.google.firebase:firebase-ml-vision-face-model:20.0.1'

image

@ankitaj224
Copy link
Contributor

Thanks for your response @perracolabs & @yogurtearl .

I will try with versions as shown in @perracolabs comment & see if I am able to reproduce the issue.

@perracolabs Which version of Android studio & Android Gradle plugin are using?

@ankitaj224
Copy link
Contributor

@yogurtearl Regarding how to get a full stack trace:

When you run lintRelease it generates a local HTML report with detailed errors. You can try checking if that file has the full stack trace.

@perracodex
Copy link

perracodex commented Jul 10, 2020

@ankitaj224

Gradle version: 6.1.1
Android Studio: 4.0

In case is of any use, the lint warning appears when performing a code inspection at "whole project" level

@perracodex
Copy link

I've found out that "firebase-ml-vision-face-model:20.0.1" has been deprecated, I removed it as it would had made sense that this could be the issue based in the lint notes about the 20.1.1 minimal version requirement.
But, this issue still happens using only the next 2 dependencies:

    implementation 'com.google.firebase:firebase-analytics:17.4.4'
    implementation 'com.google.firebase:firebase-ml-vision:24.0.3'

PS: Make sure to perform a "whole project" code inspection in order to reproduce the issue. For a moment I thought it was solved after I removed the deprecated library, yet I missed this setting.

@petedoyle
Copy link

I might be seeing the same thing with a more descriptive error with Gradle 6.5.1 and Android Gradle Plugin 4.2.0-alpha04:

Check failed with exception: java.lang.NoSuchMethodException: com.android.tools.lint.detector.api.LintModelModuleProject.getGradleProjectModel()

@ankitaj224
Copy link
Contributor

@petedoyle Thanks for posting the descriptive error. This is super helpful.

@ankitaj224
Copy link
Contributor

I am still unable to reproduce this issue with all the versions mentioned here. I will continue to reproduce this issue, meanwhile if this lint check is blocking you by any chance - you can disable this lint check by adding the following lines in your gradle file.

android {
lintOptions {
disable "IncompatibleIidVersion"
}
}

@perracodex
Copy link

perracodex commented Jul 16, 2020

@ankitaj224

Find attached a simple test project where I can reproduce the issue.
In my case I only need to create a new empty project add a firebase dependency and will get the warning when doing a code inspection set to 'whole project'.

I also include an export of my Android Studio settings, so by importing them you can match a similar development environment, if you also use the same Gradle and Android Studio versions.

Gradle version: 6.1.1
Android Studio: 4.0

in gradle-wrapper.properties:
distributionUrl=https://services.gradle.org/distributions/gradle-6.1.1-all.zip

In the project level build.gradle:
classpath 'com.android.tools.build:gradle:4.0.1'

Test.zip

@vkryachko
Copy link
Member

It's worth noting that this is not a failure it's just a "weak warning"

context.report(
IID_COMPATIBILITY_CHECK_FAILURE,
Location.create(context.file),
"Check failed with exception: $ex"
)

So arguably it's not a bug that needs fixing, although I could be convinced that we can make it fail silently

cc @ankitaj224

@AdislanSaidov
Copy link

I have the same issue on Gradle 6.1.1 and Android Studio 4.2 Canary 5

@CoolMind
Copy link

CoolMind commented Oct 5, 2020

I have the same issue in AS 4.0.1, Gradle 6.4, Gradle plugin 4.0.1. No Dagger. FCM was installed a year ago. Didn't sign in Google in the top right corner of AS. After signing in Google Analyze > Inspect Code didn't change the behaviour.
image

@tmtrademarked
Copy link

Similarly, I just started seeing this after I updated to Gradle Plugin 4.1.0 with Gradle 6.5:

/Volumes/android/android-application/mobile: Information: Check failed with exception: java.lang.NoSuchMethodException: com.android.tools.lint.detector.api.LintModelModuleProject.getGradleProjectModel() [IidCompatibilityCheckFailure]

   Explanation for issues of type "IidCompatibilityCheckFailure":
   The check failed to run as it encountered unknown failure.
   This is most likely caused by a new version of Android Gradle Plugin that
   this check does not support.
   Please make sure your build does not depend on firebase-iid version earlier
   than 20.1.1 as it will cause issues.

Our dependencies show that we're using com.google.firebase:firebase-iid:20.3.0, so we should be over the version mentioned here.

@harshalbhakta
Copy link

@ankitaj224 You can check this repository to reproduce the error using Android Studio 4.1

Android Studio: 4.1
Gradle: 6.5

I created a new Empty Activity project using Android Studio 4.1. The only code I added after creating the new project was for adding Crashlytics to the project by following the instructions from the official documentation.

This commit (harshalbhakta/IidCompatibilityCheckFailureDemo@927c869) has the changes I made to enable Crashlytics. Code in this commit causes below lint warnings.

Screenshot 2020-10-17 at 12 23 53 PM

Screenshot 2020-10-17 at 12 23 19 PM

Check failed with exception: java.lang.NoSuchMethodException: com.android.tools.idea.lint.AndroidLintIdeProject$LintGradleProject.getGradleProjectModel()

Check failed with exception: java.lang.NoSuchMethodException: com.android.tools.idea.lint.common.LintIdeProject$LintModuleProject.getGradleProjectModel()
Firebase IID Compatibility Check Unable To Run

The check failed to run as it encountered unknown failure.
This is most likely caused by a new version of Android Gradle Plugin that this check does not support.
Please make sure your build does not depend on firebase-iid version earlier than 20.1.1 as it will cause issues. 

Issue id: IidCompatibilityCheckFailure

@Sloy
Copy link

Sloy commented Oct 20, 2020

I'm having this issue too since AGP 4.1, and I could reproduce it with @harshalbhakta project 👍

@chrisjenx
Copy link

Same issue on AGP 4.1, Gradle Version 6.7, iid is 20.3.0.
Note this is a multi module project.

@keremkusmezer
Copy link

Gradle Version 6.5 and iid is 20.3.0 Android Studio 4.1.0 having the same issue

@keremkusmezer
Copy link

The exception is caused by this line.

https://github.com/firebase/firebase-android-sdk/blob/15be8218dbb890dbc79deb858addece0ad255831/firebase-installations/customer-lint-checks/src/main/java/com/google/firebase/installations/lint/IncompatibleIidVersionDetector.kt
line number 90 reflection call which tries to access a removed method via reflection.

@ankitaj224
Copy link
Contributor

Hi Everyone.

Sorry for the delayed response. Yes, its a broken lint check caused by the reflection call in Firebase-Installations library resulting in this issue. I was figuring out if its safe to remove the lint check from the firebase-installations library.

We have decided on removing the lint check from Firebase Installations library by mid November. Since, this lint check failure is a weak warning, anyone getting this error please feel free to ignore it if your app depends on firebase-iid version i.e greater than 20.1.1

I will keep this issue open till we rollout the lint removal.

Thanks,
Ankita

@kenyee
Copy link

kenyee commented Nov 11, 2020

disable "IncompatibleIidVersion"

this also doesn't seem to work...I end up adding these to our lint baselines...

@chrisjenx
Copy link

@kenyee use disable 'IidCompatibilityCheckFailure'

@chrisjenx
Copy link

@ankitaj224 any update in newer releases? do you know if this has been fixed?

@kenyee
Copy link

kenyee commented Jan 23, 2021

also FYI, disable 'IidCompatibilityCheckFailure' doesn't work if you apply it to all modules... lint complains that the rule doesn't exist if that module doesn't use a firebase lib.

Would be nice if this were fixed in the firebase lint rule though...or just take out the entire rule out of Firebase for now until it gets fixed so we don't need this workaround...

@ankitaj224
Copy link
Contributor

Hi @chrisjenx

Yes, as part of the firebase-installations v16.3.5 release, this lint check has been removed from the library(firebase-installations) that introduced it.

Only firebase-messaging library has released a new version 21.0.1 that uses the latest version of firebase-installations. So, if you see this lint check warning been in your project due to a dependency on firebase-messaging. Update to the latest version of firebase-messaging v21.0.1 which will resolve this issue.

However, not all firebase libraries that depend on older version of firebase-installations have updated to the version that removes the lint check. Reason being different firebase libraries follow different release schedule. Note: This issue is a lint warning and not causing any major build failures.

A reasonable solution would be explicitly defining & updating the dependency on the firebase-installations library with the fix (v16.3.5) in your build file. Meanwhile, we will continue working with other firebase libraries to release with the newer version of firebase-installations.

Please let me know if you have any questions.

Thanks,
Ankita

@syslogic
Copy link

There's two options:
A) implementation "com.google.firebase:firebase-crashlytics:17.4.1" will make the check pass.
B) or provide lint.xml to ignore the check (eg. when Crashlytics is not required for the module):

<?xml version="1.0" encoding="UTF-8"?>
<lint>
    <issue id="IidCompatibilityCheckFailure" severity="ignore"/>
</lint

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: installations firebase-installations Firebase Installations service
Projects
None yet
Development

No branches or pull requests