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

Sentry Android missing Maven dependencies #1947

Closed
Hanmac opened this issue Mar 13, 2022 · 10 comments · Fixed by #2641
Closed

Sentry Android missing Maven dependencies #1947

Hanmac opened this issue Mar 13, 2022 · 10 comments · Fixed by #2641

Comments

@Hanmac
Copy link

Hanmac commented Mar 13, 2022

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
@romtsn
Copy link
Member

romtsn commented Mar 14, 2022

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 romtsn closed this as completed Mar 14, 2022
Repository owner moved this from Needs Discussion to Done in Mobile & Cross Platform SDK Mar 14, 2022
@Hanmac
Copy link
Author

Hanmac commented Mar 14, 2022

@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

@romtsn
Copy link
Member

romtsn commented Mar 14, 2022

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 romtsn reopened this Mar 14, 2022
Repository owner moved this from Done to Needs Discussion in Mobile & Cross Platform SDK Mar 14, 2022
@Hanmac
Copy link
Author

Hanmac commented Mar 14, 2022

@romtsn linked in the Gradle bug there is this workaround:
androidx/media@bf2c652

@marandaneto
Copy link
Contributor

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.

@Hanmac
Copy link
Author

Hanmac commented Mar 16, 2022

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

@marandaneto
Copy link
Contributor

@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

@Hanmac
Copy link
Author

Hanmac commented Mar 17, 2022

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
Copy link
Author

Hanmac commented Mar 20, 2022

I failed to build the Android apk with Java 11 because sdklib problems:
simpligility/android-maven-plugin#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

@marandaneto marandaneto added the wontfix This will not be worked on label May 11, 2022
@marandaneto
Copy link
Contributor

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.

Repository owner moved this from Needs Discussion to Done in Mobile & Cross Platform SDK May 11, 2022
@marandaneto marandaneto reopened this May 11, 2022
Repository owner moved this from Done to Needs Discussion in Mobile & Cross Platform SDK May 11, 2022
@marandaneto marandaneto added documentation and removed wontfix This will not be worked on labels May 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants