Sentry-java: Invalid package reference in library, not included in Android - abortOnError

Created on 30 Mar 2018  路  8Comments  路  Source: getsentry/sentry-java

Sentry: 1.7.2
Android Studio: 3.1.0
We use abort on error, as:

android {
    lintOptions {
        abortOnError false
    }
}

And due to Sentry in project we get following error:

The first 3 errors (out of 8) were:
/Users/michaltajchert/.gradle/caches/modules-2/files-2.1/io.sentry/sentry/1.7.2/1616fbb57237652c7c5f4b1e7758e0a579cf9eaf/sentry-1.7.2.jar: Error: Invalid package reference in library; not included in Android: javax.naming. Referenced from io.sentry.config.JndiLookup. [InvalidPackage]
/Users/michaltajchert/.gradle/caches/modules-2/files-2.1/io.sentry/sentry/1.7.2/1616fbb57237652c7c5f4b1e7758e0a579cf9eaf/sentry-1.7.2.jar: Error: Invalid package reference in library; not included in Android: javax.servlet.http. Referenced from io.sentry.event.helper.BasicRemoteAddressResolver. [InvalidPackage]
/Users/michaltajchert/.gradle/caches/modules-2/files-2.1/io.sentry/sentry/1.7.2/1616fbb57237652c7c5f4b1e7758e0a579cf9eaf/sentry-1.7.2.jar: Error: Invalid package reference in library; not included in Android: javax.servlet. Referenced from io.sentry.servlet.SentryServletContainerInitializer. [InvalidPackage]

Android bug

Most helpful comment

We ran into this too. To fix this, in your lint.xml, you can add:

<lint>
    <issue id="InvalidPackage">
        <ignore path="**/sentry*.jar"/>
    </issue>
</lint>

And in your gradle config:

android {
    lintOptions {
        lintConfig file("path-to-lint.xml")
    }
}

I'm not sure how to fix this at the Sentry library level, however.

fwiw, I think is harmless: I think since Sentry uses one SDK for both Desktop and Android, it accesses some code that would be included in a desktop installation but this doesn't cause any crashes on Android.

All 8 comments

Hm, I'm confused, shouldn't abortOnError false not abort?

All of those packages/classes are protected and not loaded/called/used if not available. I'm not sure how we can tell the linter that they're safe? Any ideas?

Hi, sorry - I meant abortOnError true.
Also to be honest I don't know a solution to that one.

You can add disable 'InvalidPackage' to your lintOptions but I don't know how to just disable that for Sentry packages. :(

We ran into this too. To fix this, in your lint.xml, you can add:

<lint>
    <issue id="InvalidPackage">
        <ignore path="**/sentry*.jar"/>
    </issue>
</lint>

And in your gradle config:

android {
    lintOptions {
        lintConfig file("path-to-lint.xml")
    }
}

I'm not sure how to fix this at the Sentry library level, however.

fwiw, I think is harmless: I think since Sentry uses one SDK for both Desktop and Android, it accesses some code that would be included in a desktop installation but this doesn't cause any crashes on Android.

Correct, and thank you for the directions on how to fix. I may try to fold them into the Android docs (and at least they're on Google now).

experiencing this as well.

This is a good fix/workaround but is it possible to get rid of that error and being able to fix this directly in the source code ?

@SaezChristopher yes, it would be possible, but this is not gonna be worked on this repo.

We have a brand new Android SDK that is on BETA right now and it has been designed to not have non-android packages.

We invite you to test and give some feedback :)
https://github.com/getsentry/sentry-android

Stay tuned.

Was this page helpful?
0 / 5 - 0 ratings