MinnDevelopment / java-discord-rpc

Java bindings for https://github.com/discordapp/discord-rpc (using JNA)
Apache License 2.0
132 stars 38 forks source link

Natives not found even tho they're in /src/main/resources #23

Closed bddvlpr closed 6 years ago

bddvlpr commented 6 years ago

I've setup this project using Maven and it worked before but now it stopped detecting the natives, i've tried reinstalling them in the correct folder but it still gives an exception.

java.lang.UnsatisfiedLinkError: Unable to load library 'discord-rpc': dlopen(libdiscord-rpc.dylib, 9): image not found
    at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:169)
    at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:242)
    at com.sun.jna.Library$Handler.<init>(Library.java:140)
    at com.sun.jna.Native.loadLibrary(Native.java:368)
    at com.sun.jna.Native.loadLibrary(Native.java:353)
    at club.minnced.discord.rpc.DiscordRPC.<clinit>(DiscordRPC.java:42)
m-sterling commented 6 years ago

Hi StijnSimons,

The natives are not found in this repository. They're found in the MinnDevelopment/discord-rpc-release repo. Once you add that repo to your Maven dependencies, you need to add the natives directory to your buildpath.

(This is taken from this SO page and this wiki page which explain how to add the natives for LWJGL; the process is exactly the same for the RPC natives)

For Eclipse:

For IntelliJ:

Hopefully this works for you. Please let me know if you continue to experience this issue!

bddvlpr commented 6 years ago

Same error, it is in the dependencies tho. image

m-sterling commented 6 years ago

Just because it's in the dependencies doesn't mean it's included in the build path. Maven is intended for use with JAR files, not the RPC resources. Using Maven for them works for auto-updating to the latest version of them and such, but you still need to follow the above instructions to include them in your build path.

bddvlpr commented 6 years ago

Tried that. Same error.

bddvlpr commented 6 years ago

Just opened an old project using java-discord-rpc. For some reason this works, even though everything is the same.

bddvlpr commented 6 years ago

For some reason, adding

<dependency>
        <groupId>net.java.dev.jna</groupId>
        <artifactId>jna</artifactId>
        <version>4.5.1</version>
</dependency>

fixxed this.

m-sterling commented 6 years ago

Yep, this library depends on JNA, so not having it would definitely cause some issues.

Glad you were able to figure it out!

bddvlpr commented 6 years ago

It did have the dependency, it was just an older version.