[SOLVED] Unsupported class version when exporting my game to android

Hi,

I’m using latest JME3.1 stable release and when trying to export my game to android i’m getting a weird error:

PARSE ERROR:
unsupported class file version 52.0
…while parsing com/jme3/system/jogl/DisplayInfo_Jogl.class
1 error; aborting

I’ve searched over the internet and I found some references related to jdk release and similar but after trying every recommendation the issue persist.

Thanks

mhhh did you compile the engine yourself? Seems it’s been compiled with java 8 which won’t work on android.

1 Like

I had a similar error, you should use Java7 on mobile games as Android does not support newer versions.

@nehon No, I didn’t compile the engine myself.

@aegroto I tried changing all parameters I found related to java release (Sources → Source/binary format, Libraries → Java Platform) but there was no difference :frowning:

Also I tried to create a simple-empty project (tipical BasicGame) and it compiles successfully to android :S

What parts of jME are you importing in your project (desktop, core etc…) ? You are using gradle, aren’t you?

Honestly, I don’t know if the jMonkeyEngine SDK uses ant or gradle but finally I found the where the problem was!!!

I want to publish my project to desktop and android. I’m using jme-jfx libraries (GitHub - empirephoenix/JME3-JFX: JFX Gui bridge for JME with usefull utilities for common usecases) for some aditional GUI features for the desktop release. This library is compiled with jdk8 and uses bytecode version 52 not being compatible with android.

To solve this I’ve used retrolambda (https://github.com/orfjackal/retrolambda) to convert the jdk8 bytecode to jdk7. Well… I had to recompile jme-jfx adding the retrolambda gradle stuff.

Just in case anyone may need this, I’m copying the gradle file here. Just checkout the git repo and overwrite the build.gradle with the following:

import java.text.SimpleDateFormat;

apply plugin: 'com.jfrog.bintray'
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'me.tatarka.retrolambda'


/////////////////git version logic///////////////
def cmd = "git show -s --pretty=format:%ct_%h"//"git rev-parse --short HEAD"
def proc = cmd.execute()
String[] gitInfos = proc.text.trim().split('_')
//allow build with no cmd git installed
if( gitInfos.length < 2 ) {
        gitInfos = [(new Date()).getTime().toString(), "2" ]
}
String gitRevision = gitInfos[1]
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd_HHmmss")
String gitTimestamp = format.format(new Date(Long.parseLong(gitInfos[0])*1000));

def env = System.getenv()
def mainBuildVersion = "2";
//jenkins part
def buildVersion = (env.BUILD_NUMBER) ?
                mainBuildVersion+"."+env.BUILD_NUMBER+"."+gitTimestamp+"-"+gitRevision
                : mainBuildVersion+".dev."+gitTimestamp+"-"+gitRevision
;
print("Build is based on " + buildVersion);
/////////////////git version logic///////////////

sourceCompatibility=JavaVersion.VERSION_1_8
compileJava.options.encoding = 'UTF-8'

if(snapshot.equals("true")){
        version = "2.0.0-Snapshot";
}else{
        version = buildVersion;
}
group = "com.jme3x"


repositories {
        jcenter()
        mavenCentral()
}

configurations { provided }

sourceSets {
        main { compileClasspath += configurations.provided }
        test { compileClasspath += configurations.provided }
}
sourceSets.main.resources.srcDir 'src/main/java'

def v_slf4j = '1.7.7'
def v_jme3 = '3.1.0-beta1'
dependencies {
        compile "org.slf4j:slf4j-api:${v_slf4j}"
        provided "org.lwjgl.lwjgl:lwjgl:2.9.0"
        provided "org.jmonkeyengine:jme3-core:${v_jme3}"
        provided "org.jmonkeyengine:jme3-desktop:${v_jme3}"
        provided "org.jmonkeyengine:jme3-lwjgl:${v_jme3}"
        provided "org.jmonkeyengine:jme3-jogl:${v_jme3}"
        testRuntime "org.slf4j:slf4j-jdk14:${v_slf4j}"
}

task packageSources(type: Jar) {
        from sourceSets.main.allSource
        classifier = 'sources'
}

artifacts {
        archives(packageSources) { type = 'jar' }
}

eclipse {
        classpath {
                plusConfigurations += [configurations.provided]
                noExportConfigurations += [configurations.provided]
        }
}
idea {
        module {
                scopes.PROVIDED.plus += [configurations.provided]
        }
}

buildscript {
        repositories { 
                jcenter() 
                mavenCentral()
        }
        dependencies { classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:0.5' }
        dependencies { classpath 'me.tatarka:gradle-retrolambda:3.7.0' }
}

jar {
        manifest { attributes("Implementation-Version": buildVersion) }
}

retrolambda {
  javaVersion JavaVersion.VERSION_1_7
  defaultMethods false
  incremental true
}

uploadArchives {
        repositories {
                mavenDeployer {
                        repository(url: "$targetRepository/releases") {
                                authentication(userName: targetRepository_user, password: targetRepository_password)
                        }
                }
        }
}


bintray {
        user = targetRepository_user
        key = targetRepository_password

        configurations = ['archives']
        //publications = ['maven'] //When uploading Maven-based publication files
        dryRun = false //Whether to run this as dry-run, without deploying
        publish = true //If version should be auto published after an upload
        pkg {
                repo = 'VGS-OSS-Releases'
                name = project.name
                desc = "JFX Gui bridge for JME with usefull utilities for common usecases."
                websiteUrl = "https://github.com/empirephoenix/JME3-JFX"
                issueTrackerUrl = "https://github.com/empirephoenix/JME3-JFX/issues"
                vcsUrl = "https://github.com/empirephoenix/JME3-JFX.git"
                licenses = ['BSD 3-Clause']
                labels = ['jmonkeyengine', 'gui']
                publicDownloadNumbers = true
        }
}

This solution may work also with other java8 libraries :slight_smile:

3 Likes