-
Notifications
You must be signed in to change notification settings - Fork 152
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
Does the client still build in Android studio? #561
Comments
Hi @spink4
This seems unrelated to the hivemq-mqtt-client.
This should only be a warning, but maybe this changed. To find out a proper fix, can you please add the full output of the |
Thanks for the prompt reply. From a new 'empty activity' project in Android studio, here is the full output:
It does break my app if I include minify/proguard in the build process. Thank you for taking a look at this. Steve. |
Can you please add the content of the file |
Thanks for your reply. The missing_rules.txt contains:
I added this rule to proguard-rules.txt and did a rebuild. This time around the missing_rules.txt file contained:
I added the lot and it does then build without any errors or warnings. It's an 'empty activity' android app so its hard to test. If I do the same process on my app I end up with a proguard-rules.txt that looks like this:
It does build without showing any of the warnings but unfortunately the app is still broken when I run it on a device. If I remove the minify step from the build process then it works beautifully. Does that help? I'm really happy with the hive client because it's super stable so I would love to get this sorted.. Steve. |
I built an app that connects, publishes and disconnects when clicking a button and it works for me (only tested with an emulator and not a real device).
|
Thanks so much for your effort on this. My setup is:
The purpose of the Android 'empty activity' project was really just to show the warnings that were being generated (in a clean environment), but I didn't take it any further than that. My app makes an API call as soon as it starts and that breaks if the build includes the minify process. My app uses Retrofit2 for the API call so maybe that uses a library that mqtt also uses. I'm not sure. I'm happy to share code with you but I guess it's best not to post it in a public forum. What do you suggest? Thanks again for all your help, it's very much appreciated. Steve. |
I think best would be if you could
|
Good idea. I will get this setup as soon as I can. Steve. |
I have the exact same issue |
Is there any way to prioritise this issue? This is the only MQTT library that seemed to work with Android very well with Obfuscation and R8 and everything. It doesn't anymore with the latest Gradle Version (8.0.0) and Java 17 |
Can you share a reproducer? |
Hi @SgtSilvio thanks for the quick reply. Yes so I get an error similar to what @spink4 pasted above. I'm pasting it here again.
To reproduce this error just include the hivemq mqtt client in your android app. Make sure you have the latest gradle 8.0.0 or above because it uses R8 to minify by default. Upgrade Java from 1.8 to 17. And then try to build a release version of the android app with these enabled
About android retrofix
|
Can you explain what problem you are facing? Does the app crash? The log lines that you showed are only warnings and no errors. |
The app doesn't build in release mode. With the latest gradle version the log lines I showed are no longer warnings. They are errors. So I had to downgrade gradle to 7.4.1 and they became warnings again. But I need to use the latest version of gradle |
I'm using this awesome MQTT client without any issues on Android API levels 29+, building in the CLI with Gradle 8.1.1, Android Gradle Plugin 8.0.0 and Android Studio 2022.2.1 (all the latest versions at the time of writing this). The only gotcha is that you have to navigate Proguard rules a bit yourself, something that other libraries also tend to require. That said, libraries could ship with their own Proguard consumer rules these days, so a default could be offered that way. The log output is pretty much telling you what to do exactly:
Whether simply ignoring the missing classes is a good idea must be decided by you, after evaluating what you use in detail yourself. Perhaps we can figure out a good default that this library should ship with? I'm currently only using the
|
Hey @bddckr thanks for the reply. I tried adding the I will give it another go in a few days. I'm caught up with another project.
And yes this would be great. And yes it would be great if this library could specify the default proguard rules. Once again I really appreciate your in-depth reply. I will definitely give it another go. |
Agree that this would be the desired state, but all the warning rules originate from dependencies, mostly netty, so in a perfect world, these libraries should ship with good defaults. It would be a bigger effort to maintain them in this library. Also, different people could use different versions of netty. |
Oh ok. That makes sense @SgtSilvio. Thanks! Hopefully the netty community will provide one soon. |
It does break my app if I build a minified version. I ended up not using minify in the build process (temporary solution!) but will try to find time to properly look at what is breaking and why. |
Any ideas on how to fix this guys? I'm stuck on Gradle wrapper 7.6.3 because version 8 still breaks minified release builds. This works for now, but whenever Android Studio Hedgehog releases in the next few weeks, this Gradle wrapper version won't be supported anymore. Source: https://developer.android.com/build/releases/gradle-plugin#api-level-support |
Slight correction: it seems Gradle 8 is not forced on Android Studio Hedgehog. However, you then can't safely apply API level 34, since Gradle 7 isn't tested on that API level. You get a lint error for this as well. However, it does compile for now. |
Checklist
issues
.discussions
.❓ Question
I am really happy with your mqtt client as it works flawlessly in my use case (an android app). My problem comes when building a minified release version using R8/proguard in android studio. I followed the instructions for android here but I get multiple errors such as:
Unexpected reference to missing service class: META-INF/services/reactor.blockhound.integration.BlockHoundIntegration.
Missing class io.netty.channel.epoll.Epoll (referenced from: com.hivemq.client.internal.netty.NettyEventLoopProvider com.hivemq.client.internal.netty.NettyEventLoopProvider$EpollHolder.eventLoopProvider())
Missing class io.netty.channel.epoll.EpollEventLoopGroup (referenced from: com.hivemq.client.internal.netty.NettyEventLoopProvider com.hivemq.client.internal.netty.NettyEventLoopProvider$EpollHolder.eventLoopProvider())
Missing class io.netty.channel.epoll.EpollSocketChannel (referenced from: com.hivemq.client.internal.netty.NettyEventLoopProvider com.hivemq.client.internal.netty.NettyEventLoopProvider$EpollHolder.eventLoopProvider())
Missing class io.netty.handler.codec.http.FullHttpResponse (referenced from: void com.hivemq.client.internal.mqtt.handler.websocket.MqttWebsocketHandshakeHandler.channelRead(io.netty.channel.ChannelHandlerContext, java.lang.Object) and 1 other context)
Missing class io.netty.handler.codec.http.HttpClientCodec (referenced from: void com.hivemq.client.internal.mqtt.handler.websocket.MqttWebSocketInitializer.initChannel(io.netty.channel.Channel, com.hivemq.client.internal.mqtt.MqttClientConfig, com.hivemq.client.internal.mqtt.MqttWebSocketConfigImpl, java.util.function.Consumer, java.util.function.BiConsumer))
My proguard-rules.pro contains:
and the build.gradle has:
I've tried creating a new 'empty activity' project from android studio but I still get the same errors when building a minified release.
I understand android studio uses R8 rather than proguard now - could this have anything to do with it?
Thank you for your help.
Steve.
The text was updated successfully, but these errors were encountered: