powered by Jive Software

java.lang.AssertionError thrown after upgrading Android Gradle Plugin to 4.1

Hi there,

After upgrading Android Gradle Plugin to 4.1 and Gradle wrapper to 6.7 we started getting the following crash:

Process: com.gamesys.corp.virgingamesslots, PID: 20359 
at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.parsePackets(XMPPTCPConnection.java:1154)
at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.access$1000(XMPPTCPConnection.java:1092)
at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader$1.run(XMPPTCPConnection.java:1112)
at java.lang.Thread.run(Thread.java:923)

With XMPP stream being: (because of 2 links per post limit for new users, I’m adding it in a separate post)

This is the relevant part in XMPPTCPConnection.java:

case "stream":
    // We found an opening stream.
    if ("jabber:client".equals(parser.getNamespace(null))) {
        streamId = parser.getAttributeValue("", "id");
        String reportedServerDomain = parser.getAttributeValue("", "from");
        assert (config.getXMPPServiceDomain().equals(reportedServerDomain));

We’re using the following Smack components:

api "org.igniterealtime.smack:smack-legacy:$smackVersion"
api "org.igniterealtime.smack:smack-core:$smackVersion"
api "org.igniterealtime.smack:smack-resolver-minidns:$smackVersion"
api "org.igniterealtime.smack:smack-tcp:$smackVersion"
api("org.igniterealtime.smack:smack-android-extensions:$smackVersion") {
    exclude module: "smack-omemo"
    exclude module: "smack-omemo-signal"

With the smackVersion being 4.3.4

Considering the app only crashes when using Android Gradle Plugin 4.1 and while building a debug version of the app, we assume the crash is caused by this change:

Assertions in debug builds

When you build the debug version of your app using Android Gradle plugin 4.1.0 and higher, the built-in compiler (D8) will rewrite your app’s code to enable assertions at compile time, so you always have assertion checks active.

So by the looks of it, failing assertions in debug builds crash the app.

Since not being able to use Smack in debug builds is kind of limiting I have two questions. Are the library creators aware of this behaviour (we tried using the 4.4.0-beta2 sadly the app crashes on startup there) and does anyone have any ideas for a workaround. At the moment we are looking into ways of disabling the above mentioned compiler behaviour.


Adding XMPP stream:

2020-11-04 11:57:20.630 5835-6465/com.gamesys.corp.virgingamesslots D/SMACK: SENT (0): <stream:stream xmlns='jabber:client' to='virgingames-notifications.chat.gamesysgames.com' xmlns:stream='http://etherx.jabber.org/streams' version='1.0' xml:lang='en'>
2020-11-04 11:57:20.643 5835-6467/com.gamesys.corp.virgingamesslots D/SMACK: RECV (0): <?xml version='1.0' encoding='UTF-8'?><stream:stream xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" from="chat" id="agkm0cvjlc" xml:lang="en" version="1.0">

The XMPP domain announced by the server, ‘chat’ does not match the one configured in Smack’s ConnectionConfiguration. This is what triggers the assertion.

Thanks Flow, we did manage to solve the issue by changing the client configuration.

This topic was automatically closed 62 days after the last reply. New replies are no longer allowed.