discord-game-sdk4j
discord-game-sdk4j copied to clipboard
UnsatisfiedLinkError when using ActivityExample.java
My code
public static void main(String[] args) {
try(CreateParams params = new CreateParams())
{
params.setClientID(1212137405386064023L);
params.setFlags(CreateParams.getDefaultFlags());
// Create the Core
try(Core core = new Core(params))
{
// Create the Activity
try(Activity activity = new Activity())
{
activity.setDetails("Running an example");
activity.setState("and having fun");
// Setting a start time causes an "elapsed" field to appear
activity.timestamps().setStart(Instant.now());
// We are in a party with 10 out of 100 people.
activity.party().size().setMaxSize(100);
activity.party().size().setCurrentSize(10);
// Make a "cool" image show up
activity.assets().setLargeImage("test");
// Setting a join secret and a party ID causes an "Ask to Join" button to appear
activity.party().setID("Party!");
activity.secrets().setJoinSecret("Join!");
// Finally, update the current activity to our activity
core.activityManager().updateActivity(activity);
}
// Run callbacks forever
while(true)
{
core.runCallbacks();
try
{
// Sleep a bit to save CPU
Thread.sleep(16);
}
catch(InterruptedException e)
{
e.printStackTrace();
}
}
}
}
}
Exception
Exception in thread "main" java.lang.UnsatisfiedLinkError: 'long de.jcm.discordgamesdk.CreateParams.allocate()'
at de.jcm.discordgamesdk.CreateParams.allocate(Native Method)
at de.jcm.discordgamesdk.CreateParams.<init>(CreateParams.java:83)
at org.example.Main.main(Main.java:12)
I have the same issue
I ran into the same issue, too. I was using the release version, which was last released in 2022.
To fix it, use the commit version instead of the release version on JitPack. As of today, it's commit 5cdac341e3, which you can find on JitPack. Example:
implementation("com.github.JnCrMx:discord-game-sdk4j:5cdac341e3")
Hello,
this is because you are using the latest unreleased version of the example, but the latest released version of the library.
The example of the latest version includes the code to download and use the native library: https://github.com/JnCrMx/discord-game-sdk4j/blob/v0.5.5/examples/ActivityExample.java
For the latest unreleased version, this native library is no longer needed and therefore got remove from the example. I need to soon make a major release, so that other project can finally use the new version without the native library.
My apologies for this causing confusion.