21

After updating to com.google.firebase:firebase-firestore:16.0.0 I get the following lint error:

  Error: Invalid package reference in library; not included in Android: javax.naming.directory. Referenced from io.grpc.internal.DnsNameResolver.JndiResolver. [InvalidPackage]
  Error: Invalid package reference in library; not included in Android: javax.naming. Referenced from io.grpc.internal.DnsNameResolver.JndiResolver. [InvalidPackage]

Seems that the grpc dependency is making lint unhappy. How can I solve this?

Sam Stern
  • 24,624
  • 13
  • 93
  • 124

2 Answers2

31

You can remove this error by setting the following content in a lint.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<lint>
    <issue id="InvalidPackage">
        <ignore path="*/io.grpc/grpc-core/*"/>
    </issue>
</lint>

The lint.xml should be at the root of your application module.

The advantage over demoting the error to a warning is that if you later happen to add a dependency which really have an invalid package, you will still get the error.

nicopico
  • 3,606
  • 1
  • 28
  • 30
  • Thanks for the more specific answer! Agree that's better. – Sam Stern May 04 '18 at 15:04
  • 1
    It seems the answer is correct, can you accept it as correct @SamStern ? – ademar111190 Aug 24 '18 at 17:26
  • Do you know the reason why this would happen? – Jack Dec 31 '18 at 01:07
  • I'm a little confused by the path, why do you have `grpc-core`, this does not seem to appear in the error. – Sheepdogsheep May 21 '19 at 11:47
  • Where is `lint.xml`? Do I create it myself? Where is it? – salyela May 22 '19 at 18:16
  • @Sheepdogsheep the invalid package is referenced by `io.grpc.internal.DnsNameResolver.JndiResolver` (see the error message). The path I used was the one matching the JAR containing this class – nicopico May 23 '19 at 14:06
  • @salyela you have to create the file yourself, usually at the root of your application module. The documentation states you can create it at the root of your _project_ though. See https://developer.android.com/studio/write/lint#pref – nicopico May 23 '19 at 14:15
18

This error should be safe to ignore. You can downgrade all InvalidPackage errors to warnings using this block:

android {

    // ...

    lintOptions {
        warning 'InvalidPackage'
    }
}
Sam Stern
  • 24,624
  • 13
  • 93
  • 124