sentry-java icon indicating copy to clipboard operation
sentry-java copied to clipboard

Sentry Android missing Maven dependencies

Open Hanmac opened this issue 3 years ago • 10 comments

Description

I added this to my pom.xml:

<dependency>
    <groupId>io.sentry</groupId>
    <artifactId>sentry-android</artifactId>
    <version>5.6.3</version>
</dependency>

then i try to run Maven Update and i get this: Missing artifact io.sentry:sentry-android:jar:5.6.3? because https://repo.maven.apache.org/maven2/io/sentry/sentry-android/5.6.3/ only has pom and aar files.

i think it isn't a problem and just try to add <type>pom</type> or <type>aar</type> to my dependency.

but then what ever i try i get: Missing artifact io.sentry:sentry-android-core:jar:5.6.3 for the dependencies of the sentry-android package.

is there something i did wrong there? i mean i shouldn't be need to define them all manually?

testing other versions:

  • 1.7.30 is the last version that works in my Eclipse
  • below like 1.7.29 does work too
  • higher like 2.0.2 doesn't work anymore

Hanmac avatar Mar 13 '22 12:03 Hanmac

I guess you're facing a similar issue, so you probably need to go for the same workaround as mentioned in the answer.

Maven by default is looking for a .jar dependency, but sentry-android-core is distributed as an .aar for quite a while already. I don't think there's any other workaround there, Maven just has worse support for android libraries than Gradle.

romtsn avatar Mar 14 '22 06:03 romtsn

@romtsn i don't think the problem lies with maven there, i think the problem is this file:

https://repo1.maven.org/maven2/io/sentry/sentry-android/5.6.3/sentry-android-5.6.3.pom

why doesn't it say it wants sentry-android-core it wants it as <type>aar</type> ?

i assume this file is under your control, right?

same with https://repo1.maven.org/maven2/io/sentry/sentry-android-core/5.6.3/sentry-android-core-5.6.3.pom if it would explicit say it wants <type>aar</type> then maven wouldn't have a problem with that

And if that pom file is generated by gradle, wouldn't that make it a gradle problem?

Also a quick google search, Gradle got the same problem with aar and traverse dependency

Hanmac avatar Mar 14 '22 08:03 Hanmac

Oh, indeed, I just looked up and it looks like this is a Gradle bug actually.

Dunno if we should follow the suggested workarounds there @marandaneto or just wait till Gradle fixes it (though it's been 5 years since the bug is open lol)?

romtsn avatar Mar 14 '22 08:03 romtsn

@romtsn linked in the Gradle bug there is this workaround: https://github.com/androidx/media/commit/bf2c652b5f1658ac3851ee067c130c22a7522561

Hanmac avatar Mar 14 '22 12:03 Hanmac

Oh, indeed, I just looked up and it looks like this is a Gradle bug actually.

Dunno if we should follow the suggested workarounds there @marandaneto or just wait till Gradle fixes it (though it's been 5 years since the bug is open lol)?

We don't have control over the generated pom either, what's about raising an issue on https://github.com/vanniktech/gradle-maven-publish-plugin? Since this is the plugin that generates the files.

marandaneto avatar Mar 14 '22 12:03 marandaneto

with explicit dependencies to the aar files i could get maven to download them, (even if my Eclipse still doesn't like it)

currently i have a problem that proguard is complaining about that https://mvnrepository.com/artifact/androidx.lifecycle/lifecycle-runtime/2.2.0 doesn't have a MANIFEST.MF inside

is that something i can fix, you can fix, or is that something that androidx messed up?

i need to consult the other developers of my project if androidx is needed or not

Hanmac avatar Mar 16 '22 08:03 Hanmac

@Hanmac That's out of our control, feel free to remove the AndroidX libs, e.g. https://docs.sentry.io/platforms/android/configuration/releases/#androidx-support

marandaneto avatar Mar 17 '22 09:03 marandaneto

i did report it on their issue ticker, also i disabled the androidx libs with excluded

my current pom xml part:


        <dependency>
            <groupId>io.sentry</groupId>
            <artifactId>sentry-android</artifactId>
            <version>5.6.3</version>
            <type>aar</type>
            <exclusions>
                <exclusion>
                    <groupId>io.sentry</groupId>
                    <artifactId>sentry-android-core</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>io.sentry</groupId>
                    <artifactId>sentry-android-ndk</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <!-- manual sentry-android dependencies because of Gradle Bug -->
        <dependency>
            <groupId>io.sentry</groupId>
            <artifactId>sentry-android-core</artifactId>
            <version>5.6.3</version>
            <type>aar</type>
            <exclusions>
                <exclusion>
                    <groupId>androidx.lifecycle</groupId>
                    <artifactId>lifecycle-process</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>androidx.lifecycle</groupId>
                    <artifactId>lifecycle-common-java8</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>androidx.core</groupId>
                    <artifactId>core</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>io.sentry</groupId>
            <artifactId>sentry-android-ndk</artifactId>
            <version>5.6.3</version>
            <type>aar</type>
            <exclusions>
                <exclusion>
                    <groupId>io.sentry</groupId>
                    <artifactId>sentry-android-core</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <!-- runtime dependency of sentry -->
        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <version>2.8.5</version>
        </dependency>
    </dependencies>

now i need to get it working for my colleges.

the gson thing was a surprise for me, because i didn't noticed until it crashed for him.

now if only the Editors (Eclipse and Intelij would support it)

Hanmac avatar Mar 17 '22 13:03 Hanmac

I failed to build the Android apk with Java 11 because sdklib problems: https://github.com/simpligility/android-maven-plugin/issues/792

when try to build it with Java 8, i can built it

when i manually init Sentry with SentryAndroid.init(this)

but the app crashes with:

    java.lang.NoSuchMethodError: No static method metafactory(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite; in class Ljava/lang/invoke/LambdaMetafactory; or its super classes (declaration of 'java.lang.invoke.LambdaMetafactory' appears in /apex/com.android.art/javalib/core-oj.jar)
        at io.sentry.android.core.SentryAndroid.init(SentryAndroid.java:40)
        at io.sentry.android.core.SentryAndroid.init(SentryAndroid.java:30)
        at forge.app.Main.onCreate(Main.java:67)

when i try to auto-init Sentry, it doesn't seem to work at all

probably something wrong with the Lambda SentryAndroid uses?

Edit: i got it working with replacing dex with d8 i needed to manipulate the MANIFEST.MF inside the d8.jar

Hanmac avatar Mar 20 '22 12:03 Hanmac

We'll add an item to the https://docs.sentry.io/platforms/android/troubleshooting/ page instead of fixing it in the tooling since Maven isn't that popular in the Android world anyway.

marandaneto avatar May 11 '22 14:05 marandaneto