Jump to content

java.lang.NoSuchFieldError, with any static field in init.Biomes with shadowJar


Recommended Posts

Posted (edited)

Hello Minecraft Forge Forums,

 

I kind of have a little bit of an issue with trying to run my mod.

 

I created a Gradle-based mod and I am using an external dependency. I wanted to embed the dependency into my mod's jar file. I used the Shadow plugin for Gradle, it compiles fine, but when I try to run the mod, I get java.lang.NoSuchFieldError when trying to use any static field in net.minecraft.init.Biomes. 

 

Here is my build.gradle file:

buildscript {
    repositories {
        jcenter()
        maven { url = "https://files.minecraftforge.net/maven" }
    }
    dependencies {
        classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
		classpath 'com.github.jengelman.gradle.plugins:shadow:1.2.3'
    }
}
apply plugin: 'net.minecraftforge.gradle.forge'
//Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.
apply plugin: 'com.github.johnrengelman.shadow'

version = "0.1"
group = "io.github.mymod" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "mymod"

shadowJar {
	classifier = null

	relocate "org.apache.commons.imaging", "killme.org.apache.commons.imaging"

	dependencies {
		include(dependency(files("lib/commons-imaging-1.0-alpha1.jar")))
		//exclude(dependency(files("lib/CubicChunks-1.12.2-0.0.970.0-SNAPSHOT-all.jar")))
		//exclude(dependency(files("lib/CubicWorldGen-1.12.2-0.0.39.1-SNAPSHOT-all.jar")))
	}
}

sourceCompatibility = targetCompatibility = '1.8' // Need this here so eclipse task generates correctly.
compileJava {
	println "icij"
    sourceCompatibility = targetCompatibility = '1.8'
}

minecraft {
	println "icimc"
    version = "1.12.2-14.23.5.2847"
    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 always work.
    // simply re-run your setup task after changing the mappings to update your workspace.
    mappings = "snapshot_20171003"
    // makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
}

dependencies {
	println "icidp"
    // you may put jars on which you depend on in ./libs
    // or you may define them like so..
    //compile "some.group:artifact:version:classifier"
    //compile "some.group:artifact:version"
      
    // real examples
    //compile 'com.mod-buildcraft:buildcraft:6.0.8:dev'  // adds buildcraft to the dev env
    //compile 'com.googlecode.efficient-java-matrix-library:ejml:0.24' // adds ejml to the dev env

    // the 'provided' configuration is for optional dependencies that exist at compile-time but might not at runtime.
    //provided 'com.mod-buildcraft:buildcraft:6.0.8:dev'

    // the deobf configurations:  'deobfCompile' and 'deobfProvided' are the same as the normal compile and provided,
    // except that these dependencies get remapped to your current MCP mappings
    //deobfCompile 'com.mod-buildcraft:buildcraft:6.0.8:dev'
    //deobfProvided 'com.mod-buildcraft:buildcraft:6.0.8:dev'
	provided files("lib/CubicChunks-1.12.2-0.0.970.0-SNAPSHOT-all.jar")
	provided files("lib/CubicWorldGen-1.12.2-0.0.39.1-SNAPSHOT-all.jar")
	compile files("lib/commons-imaging-1.0-alpha1.jar")

    // for more info...
    // http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
    // http://www.gradle.org/docs/current/userguide/dependency_management.html

}

processResources {
	println "icipr"
    // 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 except the mcmod.info
    from(sourceSets.main.resources.srcDirs) {
        exclude 'mcmod.info'
    }
}

 

It seems to be caused by the "classifier = null" line, assigning classifier to anything causes the above error, however, if I remove that line, the dependency does not appear in my jar file. 

 

(The dependency is Apache's Commons-imaging [org.apache.commons.imaging])

 

All help and answers are appreciated, if you need any more information, let me know.

?

 
Edited by shejan0
Posted

Update to a modern version of Minecraft to receive support. Also read the forge docs about dependencies...

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.