Skip to content

Does the client still build in Android studio? #561

Open
@spink4

Description

@spink4

Checklist

❓ 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:

-keepclassmembernames class io.netty.** { *; }
-keepclassmembers class org.jctools.** { *; }

and the build.gradle has:

buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    packagingOptions {
        exclude 'META-INF/INDEX.LIST'
        exclude 'META-INF/io.netty.versions.properties'
    }

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions