Skip to content
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

UnsatisfiedLinkError when using ActivityExample.java #88

Open
kallmetony opened this issue Jun 29, 2024 · 3 comments
Open

UnsatisfiedLinkError when using ActivityExample.java #88

kallmetony opened this issue Jun 29, 2024 · 3 comments

Comments

@kallmetony
Copy link

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)
@LimoDerEchte
Copy link

I have the same issue

@Tofpu
Copy link

Tofpu commented Jul 10, 2024

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")

@JnCrMx
Copy link
Owner

JnCrMx commented Jul 21, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants