Error with com.rabbitmq:amqp-client:5.2.0 dependency

786 views
Skip to first unread message

Anel Fernández

unread,
Mar 28, 2018, 10:47:00 AM3/28/18
to rabbitmq-users
Hi there!

I want to use RabbitMQ Java Client in my Android app, I added the dependency

implementation com.rabbitmq:amqp-client:5.2.0

but when I try to build my project I got the following error:
Exception in thread "main" java.lang.TypeNotPresentException: Type io.micrometer.core.instrument.MeterRegistry not present
        at sun
.invoke.util.BytecodeDescriptor.parseSig(BytecodeDescriptor.java:85)
        at sun
.invoke.util.BytecodeDescriptor.parseMethod(BytecodeDescriptor.java:54)
        at sun
.invoke.util.BytecodeDescriptor.parseMethod(BytecodeDescriptor.java:41)
        at java
.lang.invoke.MethodType.fromMethodDescriptorString(MethodType.java:1067)
        at com
.google.devtools.build.android.desugar.LambdaDesugaring$InvokedynamicRewriter.visitInvokeDynamicInsn(LambdaDesugaring.java:399)
        at org
.objectweb.asm.MethodVisitor.visitInvokeDynamicInsn(Unknown Source)
        at org
.objectweb.asm.MethodVisitor.visitInvokeDynamicInsn(Unknown Source)
        at org
.objectweb.asm.ClassReader.a(Unknown Source)
        at org
.objectweb.asm.ClassReader.b(Unknown Source)
        at org
.objectweb.asm.ClassReader.accept(Unknown Source)
        at org
.objectweb.asm.ClassReader.accept(Unknown Source)
        at com
.google.devtools.build.android.desugar.Desugar.desugarClassesInInput(Desugar.java:401)
        at com
.google.devtools.build.android.desugar.Desugar.desugarOneInput(Desugar.java:326)
        at com
.google.devtools.build.android.desugar.Desugar.desugar(Desugar.java:280)
        at com
.google.devtools.build.android.desugar.Desugar.main(Desugar.java:584)
Caused by: java.lang.ClassNotFoundException: Class io.micrometer.core.instrument.MeterRegistry not found
        at com
.google.devtools.build.android.desugar.HeaderClassLoader.findClass(HeaderClassLoader.java:53)
        at java
.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at java
.lang.ClassLoader.loadClass(ClassLoader.java:357)
        at sun
.invoke.util.BytecodeDescriptor.parseSig(BytecodeDescriptor.java:83)
       
... 14 more

This is my build.gradle file

apply plugin
: 'com.android.application'
android
{
    compileSdkVersion
27
    defaultConfig
{
        applicationId
"xxx"
        minSdkVersion
16
        targetSdkVersion
27        
       
...        
   
}
   
...    
    compileOptions
{
        sourceCompatibility
JavaVersion.VERSION_1_8
        targetCompatibility
JavaVersion.VERSION_1_8
   
}    
}
...
dependencies
{
    implementation fileTree
(include: ['*.jar'], dir: 'libs')
   
...
   
// RabbitMQ
    implementation
'com.rabbitmq:amqp-client:5.2.0'
   
...
}

How can I solve that issue?

Thanks in advance...


Arnaud Cogoluègnes

unread,
Mar 28, 2018, 12:23:44 PM3/28/18
to rabbitm...@googlegroups.com
Micrometer is an optional dependency used for metrics in the RabbitMQ Java client. You should not need to add the dependency if you're not using it. You can try to add it [1] to see if it resolves your problem, but this is just a workaround, again it shouldn't be included if it's not used.

[1] http://mvnrepository.com/artifact/io.micrometer/micrometer-core/1.0.2

--
You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-users+unsubscribe@googlegroups.com.
To post to this group, send email to rabbitmq-users@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Message has been deleted

Michael Klishin

unread,
Mar 28, 2018, 1:37:37 PM3/28/18
to rabbitm...@googlegroups.com
Note that this is happening in Android Studio, which is a less commonly used target for our client.

To the OP: please post your project’s dependency tree (printed by `gradle app:dependencies`).

It can be that an optional dependency is brought in or another library also happens to depend on Micrometer (who knows).

Specific steps to reproduce (e.g. a small Git repo we can close and build in Android Studio version X.Y.Z) would help, too.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-user...@googlegroups.com.
To post to this group, send email to rabbitm...@googlegroups.com.
Message has been deleted

Arnaud Cogoluègnes

unread,
Mar 29, 2018, 8:53:38 AM3/29/18
to rabbitm...@googlegroups.com
Micrometer isn't mentioned in the dependency tree. There's a fair amount of google results that look similar, and solutions are a mix of voodoo and Gradle incantations.

Can you please try to reproduce the issue on a brand new and simple project and share it on GitHub?


On Wed, Mar 28, 2018 at 9:23 PM, Anel Fernández <anel...@gmail.com> wrote:
Thanks so much for your answer. My project, before add the RabbitMQ Java client dependency, was building successfully, but when I add that dependency I got the error I mentioned above. I attached my project's dependency tree in 'dependencies.txt' file.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-user...@googlegroups.com.
To post to this group, send email to rabbitm...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-user...@googlegroups.com.
To post to this group, send email to rabbitm...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--

ztian...@gmail.com

unread,
Jul 12, 2018, 4:00:03 PM7/12/18
to rabbitmq-users

Hi Arnaud,
I'm meeting the same problem like Anel, I found this problem is happened when using the implementation 'com.rabbitmq:amqp-client:5.3.0' with jdk 1.8(which using java8) in android 8.0. I have create a repository in github, here is the link:
I have try to add the dependency in the app.gradle. it will only make me find more and more unFounded class.

Arnaud Cogoluègnes

unread,
Jul 13, 2018, 9:21:46 AM7/13/18
to rabbitm...@googlegroups.com
TL;DR
Caveat emptor, I'm no Android developer.
In gradle.properties add:
android.enableD8.desugaring=true

In app/build.gradle add the following in the android section:
lintOptions {
abortOnError false
}

The build should work then.

Now the details. I reproduced with your project and the following configuration:
Android Studio 3.1.3
Build #AI-173.4819257, built on June 4, 2018
JRE: 1.8.0_152-release-1024-b01 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Linux 4.4.0-130-generic

The stack trace is:
Exception in thread "main" java.lang.TypeNotPresentException: Type
io.micrometer.core.instrument.MeterRegistry not present
at sun.invoke.util.BytecodeDescriptor.parseSig(BytecodeDescriptor.java:85)
at sun.invoke.util.BytecodeDescriptor.parseMethod(BytecodeDescriptor.java:54)
at sun.invoke.util.BytecodeDescriptor.parseMethod(BytecodeDescriptor.java:41)
at java.lang.invoke.MethodType.fromMethodDescriptorString(MethodType.java:1067)
at com.google.devtools.build.android.desugar.LambdaDesugaring$InvokedynamicRewriter.visitInvokeDynamicInsn(LambdaDesugaring.java:406)
at org.objectweb.asm.ClassReader.readCode(ClassReader.java:1623)
at org.objectweb.asm.ClassReader.readMethod(ClassReader.java:1126)
at org.objectweb.asm.ClassReader.accept(ClassReader.java:698)
at org.objectweb.asm.ClassReader.accept(ClassReader.java:500)
at com.google.devtools.build.android.desugar.Desugar.desugarClassesInInput(Desugar.java:477)
at com.google.devtools.build.android.desugar.Desugar.desugarOneInput(Desugar.java:361)
at com.google.devtools.build.android.desugar.Desugar.desugar(Desugar.java:314)
at com.google.devtools.build.android.desugar.Desugar.main(Desugar.java:711)

Thanks to [1] I disabled the lambda desugaring. I don't know the
implication of this, you should check if it's ok for your project.

Then I had warnings from lint and set "abortOnError false" as
suggested. This shouldn't harm your project if you don't use the
mentioned classes.

Thanks for providing a sample project, it's been very helpful.

[1] https://github.com/gradle/gradle/issues/2384

Arnaud Cogoluègnes

unread,
Jul 13, 2018, 9:53:43 AM7/13/18
to rabbitm...@googlegroups.com
Looks like disabling desugaring should be harmless [1].

[1] https://developer.android.com/studio/write/java8-support
Reply all
Reply to author
Forward
0 new messages