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

Unable to load library 'discord-rpc': The specified module could not be found. #30

Closed Gxorge closed 6 years ago

Gxorge commented 6 years ago

Hello,

I'm trying to make a Minecraft mod that includes this library and I keep getting this error

Error: net.minecraftforge.fml.common.LoaderException: java.lang.UnsatisfiedLinkError: Unable to load library 'discord-rpc': The specified module could not be found.

Then in console I get this error:

// Hi. I'm Minecraft, and I'm a crashaholic.

Time: 28/08/18 11:20
Description: There was a severe problem during mod loading that has caused the game to fail

net.minecraftforge.fml.common.LoaderException: java.lang.UnsatisfiedLinkError: Unable to load library 'discord-rpc': The specified module could not be found.

    at net.minecraftforge.fml.common.LoadController.transition(LoadController.java:162)
    at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:559)
    at net.minecraftforge.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:243)
    at net.minecraft.client.Minecraft.func_71384_a(Minecraft.java:417)
    at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:329)
    at net.minecraft.client.main.Main.main(SourceFile:124)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
    at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
Caused by: java.lang.UnsatisfiedLinkError: Unable to load library 'discord-rpc': The specified module could not be 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)
    at curiousclient.discord.DiscordRP.init(DiscordRP.java:11)
    at curiousclient.CuriousClient.preInit(CuriousClient.java:36)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at net.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:560)
    at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74)
    at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47)
    at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322)
    at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304)
    at com.google.common.eventbus.EventBus.post(EventBus.java:275)
    at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:211)
    at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:189)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74)
    at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47)
    at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322)
    at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304)
    at com.google.common.eventbus.EventBus.post(EventBus.java:275)
    at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:118)
    at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:556)
    ... 10 more

Anyone know what I'm doing wrong?

Thanks, George

Gxorge commented 6 years ago

(Oh and also I'm building the mod Gradle. I have tried using shadowjar as well and that hasn't worked)

MinnDevelopment commented 6 years ago

It looks like you are missing the dependency for the natives, please post your build.gradle for reference.

Gxorge commented 6 years ago
// For those who want the bleeding edge
buildscript {
    repositories {
        jcenter()
        maven {
            name = "forge"
            url = "http://files.minecraftforge.net/maven"
        }
        maven {
            url "https://plugins.gradle.org/m2/"
        }
    }
    dependencies {
        classpath "net.minecraftforge.gradle:ForgeGradle:2.1-SNAPSHOT"
        classpath "com.github.jengelman.gradle.plugins:shadow:1.2.4"
        classpath "club.minnced:java-discord-rpc:2.0.1"
    }
}

apply plugin: "com.github.johnrengelman.shadow"
apply plugin: "net.minecraftforge.gradle.forge"
apply plugin: "java"

/*
// for people who want stable - not yet functional for MC 1.8.8 - we require the forgegradle 2.1 snapshot
plugins {
    id "net.minecraftforge.gradle.forge" version "2.0.2"
}
*/
version = "1.0"
group = "curiousclient" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "CuriousClient"
sourceCompatibility = targetCompatibility = 1.8

shadowJar {
    relocate 'org.apache.commons', 'curiousclient.apache'
    classifier ''
}

repositories {
    maven { url 'https://jitpack.io' }
    jcenter()
}

minecraft {
    version = "1.8.9-11.15.1.1722"
    runDir = "run"

    // the mappings can be changed at any time, and must be in the following format.
    // snapshot_YYYYMMDD   snapshot are built nightly.
    // stable_#            stables are built at the discretion of the MCP team.
    // Use non-default mappings at your own risk. they may not allways work.
    // simply re-run your setup task after changing the mappings to update your workspace.
    mappings = "stable_20"
    // makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
}

reobf {
    shadowJar {}
}

dependencies {
    compile "club.minnced:java-discord-rpc:2.0.1"
}

processResources {
    // this will ensure that this task is redone when the versions change.
    inputs.property "version", project.version
    inputs.property "mcversion", project.minecraft.version

    // replace stuff in mcmod.info, nothing else
    from(sourceSets.main.resources.srcDirs) {
        include 'mcmod.info'

        // replace version and mcversion
        expand 'version':project.version, 'mcversion':project.minecraft.version
    }

    // copy everything else, thats not the mcmod.info
    from(sourceSets.main.resources.srcDirs) {
        exclude 'mcmod.info'
    }
}

artifacts {
    shadowJar
}
Gxorge commented 6 years ago

Also the plugin does work when I run buildClient. Everything works fine when I do that

MinnDevelopment commented 6 years ago

Multiple things to point out here:

Gxorge commented 6 years ago

(Sorry I'm a bit stupid) So I've removed jitpack from the dependencies, what else do I need to do (with the processResources?)

Gxorge commented 6 years ago

^ I have also removed this library from the buildScript

Gxorge commented 6 years ago

Sorry, but what exactly do I need to put in the processResources? I've looked around the internet a bit and I can't really find what to put in it? Thanks

MinnDevelopment commented 6 years ago

It looks like all the libraries are loaded into the jar. Make sure your platform is listed in the supported platforms: linux-x86-64, win32-x86-64, win32-x86, and darwin

Gxorge commented 6 years ago

Yup, it’s in that list.

Gxorge commented 6 years ago

But going back to what you said earlier ("Your processResources does not include resources from dependencies (this is your biggest issue)"). What exactly do I need to put in the processResources?

MinnDevelopment commented 6 years ago

I misunderstood how processResources works, it actually doesn't even use dependencies since the jars are essentially resources them-self already.

Gxorge commented 6 years ago

So do we know what is potentially wrong then? Or is this just an issue unrelated to this library?

Gxorge commented 6 years ago

I've moved to a different library as I just couldn't get this one to work. Thanks for all the help, anyway

MinnDevelopment commented 6 years ago

It looks to me like you were using an out-dated version of JNA which was not loading the library properly. You could've tried using -Djna.debug_load=true to see where it fails as well. This is really an issue with your setup and I can't help there.