How to Build Smack?

Hello, how do I build smack 4.4.7 since there are no grade/wrapper folder in the souce code?
And if I want to build master version for smack, Android Studio reported: “unsupported Java. Your build is currently configured to use Java 17.0.9 and Gradle 6.8.3.”

You can download and install Gradle on your own computer, and use that to build Smack. This way, you do not need the Gradle wrapper.

Please refer to Guidelines for Smack Developers and Contributors · igniterealtime/Smack Wiki · GitHub for some details.


You left the MUC before you let anyone give you the answer.

The CI of smack uses Java 11, so you can assume that is the supported version, bytecode is forward compatible but NOT backwards compatible, therefore any jdk11+ should work, unless Flow has decided to compile the library under a different jdk.

Do you have any proof that it is Smack which is causing the unsupported Java version error?

Also something Fishbowler pointed out, you are likely using some jdk which was installed on your device, this is likely not supported. Depending on the sdk version you are building for, please search up the android jdk version requirements for each sdk target, your answer likely lies there.

Depending on the operating system you are on, Java is handled differently, for example some Linux distributions symlink a “default” version to /usr/bin/java which is within PATH, this is likely what android studio would pick up first… so all you might be missing here is some IDE-side configuration, however Linux is just an example.

Hope this helps.

1 Like

Also Guus, especially how they are struggling with the age old “doesn’t work on my machine”, surely it is better to use the gradlew here to eliminate any chances of version compatibility being the issue?

Sure, if there’s a wrapper, use that. If I understood the original question correctly, that wrapper was missing though.

Oh I am not sure if there is a gradlew within Smack, I just saw you say the following:

This way, you do not need the Gradle wrapper.

My point was simply, they are having issues with compatibility, so why encourage the use of a different gradle install instead of the embedded one (if it exists), where you are likely to be more compatible using the same version (which the gradle wrapper ensures) as the devs are using.

I have no idea if Smack actually has a gradle wrapper.

Hope that clarifies.

No argument here (although using the wrapper is unlikely to resolve any issues that relate to versions of Java being used, I think).

I believe that there’s a Gradle wrapper in the master branch of Smack’s source repository, but not in the exact version that the original poster mentioned. By any means, use it if it’s available (but otherwise, you need not be blocked: you can roll your own).

No argument here (although using the wrapper is unlikely to resolve any issues that relate to versions of Java being used, I think).

It wasn’t because I believe its the cause, but when diagnosing an issue eliminating all other points of failure is useful, by the shear off chance it could be gradle.

Funny enough I have seen Gradle throw errors if the wrong version is used with the wrong version of Java.

I still think its likely a android sdk version incompatibility, and that a lower Java version (Most likely JDK11) is what is required.

Yes. In the master branch of Smark, there is a Gradle wrapper. And I have build smack use java 1.8.
However, I found smack is only a library, and the project does not include a demo APP.
Where can I find a example APP using smack?

The docs(Overview (Smack 4.4.7 API)) is not easy for beginners.

You’re right, it is not an easy project to get started with.

There is a bit of documentation in the Smack Github repository’s wiki, here: Home · igniterealtime/Smack Wiki · GitHub - in particular, the readme&upgrade guides can be helpful.

We also have a small guide in the Openfire documentation that shows how you can get a minimally working client together. You can find that guide here: Smack: A Minimal Working Example (in Java)

I hope this helps!

Just an additional note, Spark, the IgniteRealtime XMPP client, uses Smack: Spark/core/pom.xml at master · igniterealtime/Spark · GitHub

You could take a look through the code there and see how things are handled.

Good luck :slight_smile:

Edit: You can also join the MUC, sure someone would help you out there too:

Edit x2: Spark is old and currently has no maintainer, the code there might not be the best, but it still provides a production reference if required, prefer the documentation Guus has provided above however as this is more up to date.