Elementa UI Library Not Working - NoClassDefFoundError when Opening WindowScreen in Forge 1.20.1
I am encountering an issue when trying to open a WindowScreen in Forge 1.20.1 using the Elementa UI library. Every time I attempt to do so, I get the following error:
Caused by: java.lang.NoClassDefFoundError: gg/essential/elementa/WindowScreen Caused by: java.lang.ClassNotFoundException: gg.essential.elementa.WindowScreen
I’ve tried several versions of Elementa as well as UniversalCraft, but the issue persists.
The WindowScreen should open without any issues, without throwing the NoClassDefFoundError.
- Minecraft Version: 1.20.1
- Forge Version: 47.4.0
- Elementa Version: every version
- UniversalCraft Version: every version
- Java Version: 17
Note: I am using Java for my mod development, even though the Elementa library is written in Kotlin.
I also searched for Forge versions in Maven, but whenever I used them, I encountered the same error. Additionally, when I tried using fg.deobf, it didn't work either because the Forge versions didn’t have a mods.toml file.
Are you experiencing this crash/error in production or in the developer environment?
in development environment
Elementa 695 is a Fabric mod and cannot be loaded in Forge. I tried a Forge version (1.18.1), and it loaded successfully:
implementation(fg.deobf("gg.essential:elementa-1.18.1-forge:657")) implementation(fg.deobf("gg.essential:universalcraft-1.20.1-forge:381"))
But the same error occurred.The Forge classloader can't find it for some reason.
I met the same error too, in Minecraft version 1.20.1 & Forge version 47.4.6; I used Elementa 710 & UniversalCraft 427;In a result, the NoClassDefFoundError always shown up when tring open an Elementa UI;
I tried to solve this error in two days but got nothing, I tried to use runtimeOnly, or configuration.*.extendsFrom(*) to seperate it from other libs for shadowJar. As a result, the runClient task cannot import Elementa classes, but they can be found in libs/targetmod.shadow.jar
There are only 10 'elementa' in the whole log file, and they are all shown in errors.
Here is my build.gradle.kts:
// ...
val embed: Configuration by configurations.creating
configurations.implementation.get().extendsFrom(embed)
configurations.runtimeOnly.get().extendsFrom(embed)
// ...
dependencies {
minecraft("net.minecraftforge:forge:$minecraftVersion-$forgeVersion")
implementation(libs.kotlin.stdlib)
implementation(libs.kotlin.stdlib.jdk8)
implementation(libs.kotlinForForge)
embed(libs.elementa)
embed(libs.universalCraft)
// If added, it's still not work
// implementation(libs.elementa)
// implementation(libs.universalCraft)
}
// ...
tasks.named<ShadowJar>("shadowJar") {
configurations = listOf(embed)
relocate("gg.essential.elementa", "$packageName.elementa")
relocate("gg.essential.universalcraft", "$packageName.universalcraft")
archiveClassifier.set("")
}
// ...
tasks.named("build") {
dependsOn(tasks.named("shadowJar"))
}
// ...