Running Android Error :java.lang.NoClassDefFoundError: sun/misc/BASE64Encoder

I am using jMonkeyEngine SDK v3.6.0-stable 64bit on windows 10 with android tools_r25.2.5-windows I could build mobile example project but tying to run it from jMonkeyEngine I encountered this error:

Creating jMonkeyEngine Test Applications-debug-unaligned.apk and signing it with a debug key...
C:\Users\HP\Documents\JmonkeyEngine Game Projects\JME3TestsAndroid_1\nbproject\mobile-impl.xml:8: The following error occurred while executing this line:
G:\Developments\Android\tools_r25.2.5-windows\tools\ant\build.xml:958: The following error occurred while executing this line:
G:\Developments\Android\tools_r25.2.5-windows\tools\ant\build.xml:969: The following error occurred while executing this line:
G:\Developments\Android\tools_r25.2.5-windows\tools\ant\build.xml:312: 
java.lang.NoClassDefFoundError: sun/misc/BASE64Encoder
	at com.android.sdklib.internal.build.SignedJarBuilder.<init>(SignedJarBuilder.java:177)
	at com.android.sdklib.build.ApkBuilder.init(ApkBuilder.java:446)
	at com.android.sdklib.build.ApkBuilder.<init>(ApkBuilder.java:394)
	at com.android.ant.ApkBuilderTask.execute(ApkBuilderTask.java:334)
	at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
	at jdk.internal.reflect.GeneratedMethodAccessor378.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:99)
	at org.apache.tools.ant.Task.perform(Task.java:350)
	at java.base/java.util.Vector.forEach(Vector.java:1365)
	at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:67)
	at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
	at jdk.internal.reflect.GeneratedMethodAccessor378.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:99)
	at org.apache.tools.ant.Task.perform(Task.java:350)
	at org.apache.tools.ant.taskdefs.MacroInstance.execute(MacroInstance.java:391)
	at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
	at jdk.internal.reflect.GeneratedMethodAccessor378.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:99)
	at org.apache.tools.ant.Task.perform(Task.java:350)
	at java.base/java.util.Vector.forEach(Vector.java:1365)
	at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:67)
	at com.android.ant.IfElseTask.execute(IfElseTask.java:124)
	at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
	at jdk.internal.reflect.GeneratedMethodAccessor378.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:99)
	at org.apache.tools.ant.Task.perform(Task.java:350)
	at java.base/java.util.Vector.forEach(Vector.java:1365)
	at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:67)
	at com.android.ant.IfElseTask.execute(IfElseTask.java:124)
	at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
	at jdk.internal.reflect.GeneratedMethodAccessor378.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:99)
	at org.apache.tools.ant.Task.perform(Task.java:350)
	at java.base/java.util.Vector.forEach(Vector.java:1365)
	at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:67)
	at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
	at jdk.internal.reflect.GeneratedMethodAccessor378.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:99)
	at org.apache.tools.ant.Task.perform(Task.java:350)
	at org.apache.tools.ant.taskdefs.MacroInstance.execute(MacroInstance.java:391)
	at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
	at jdk.internal.reflect.GeneratedMethodAccessor378.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:99)
	at org.apache.tools.ant.Task.perform(Task.java:350)
	at org.apache.tools.ant.Target.execute(Target.java:449)
	at org.apache.tools.ant.Target.performTasks(Target.java:470)
	at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1391)
	at org.apache.tools.ant.helper.SingleCheckExecutor.executeTargets(SingleCheckExecutor.java:36)
	at org.apache.tools.ant.Project.executeTargets(Project.java:1254)
	at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:437)
	at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
	at jdk.internal.reflect.GeneratedMethodAccessor378.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:99)
	at org.apache.tools.ant.Task.perform(Task.java:350)
	at org.apache.tools.ant.Target.execute(Target.java:449)
	at org.apache.tools.ant.Target.performTasks(Target.java:470)
	at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1391)
	at org.apache.tools.ant.Project.executeTarget(Project.java:1364)
	at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
	at org.apache.tools.ant.Project.executeTargets(Project.java:1254)
	at org.apache.tools.ant.module.bridge.impl.BridgeImpl.run(BridgeImpl.java:261)
	at org.apache.tools.ant.module.run.TargetExecutor.run(TargetExecutor.java:573)
	at org.netbeans.core.execution.RunClassThread.doRun(RunClassThread.java:132)
	at org.netbeans.modules.openide.util.GlobalLookup.execute(GlobalLookup.java:45)
	at org.openide.util.lookup.Lookups.executeWith(Lookups.java:287)
	at org.netbeans.core.execution.RunClassThread.run(RunClassThread.java:81)
Caused by: java.lang.ClassNotFoundException: sun.misc.BASE64Encoder
	at org.apache.tools.ant.AntClassLoader.findClassInComponents(AntClassLoader.java:1383)
	at org.apache.tools.ant.AntClassLoader.findClass(AntClassLoader.java:1338)
	at org.apache.tools.ant.AntClassLoader.loadClass(AntClassLoader.java:1093)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
	... 82 more
BUILD FAILED (total time: 11 seconds)

Can you send this ant configuration file?

EDIT:
Or may be those lines of error, we are not going to swipe over 1000 config lines.

EDIT2:
And, what type of jdk are you using?

jdk 1.8

 <!-- compilation options -->
    <property name="java.encoding" value="UTF-8" />
    <property name="java.target" value="1.8" />
    <property name="java.source" value="1.8" />
    <property name="java.compilerargs" value="" />
    <property name="java.compiler.classpath" value="" />

 <target name="-package" depends="-dex, -package-resources">
        <!-- only package apk if *not* a library project -->
        <do-only-if-not-library elseText="Library project: do not package apk..." >
            <if condition="${build.is.instrumented}">
                <then>
                    <package-helper>
                        <extra-jars>
                            <!-- Injected from external file -->
                            <jarfile path="${emma.dir}/emma_device.jar" />
                        </extra-jars>
                    </package-helper>
                </then>
                <else>
                    <package-helper />
                </else>
            </if>
        </do-only-if-not-library>
    </target>
 <apkbuilder
                    outfolder="${out.absolute.dir}"
                    resourcefile="${resource.package.file.name}"
                    apkfilepath="${out.packaged.file}"
                    debugpackaging="${build.is.packaging.debug}"
                    debugsigning="${build.is.signing.debug}"
                    verbose="${verbose}"
                    hascode="${manifest.hasCode}"
                    previousBuildType="${build.last.is.packaging.debug}/${build.last.is.signing.debug}"
                    buildType="${build.is.packaging.debug}/${build.is.signing.debug}">
                <dex path="${intermediate.dex.file}"/>
                <sourcefolder path="${source.absolute.dir}"/>
                <jarfile refid="project.all.jars.path" />
                <nativefolder path="${native.libs.absolute.dir}" />
                <nativefolder refid="project.library.native.folder.path" />
                <nativefolder refid="project.rs.support.libs.path" />
                <nativefolder path="${out.rs.libs.absolute.dir}" />
                <extra-jars/>
            </apkbuilder>

By the way, an off-topic question:

Any reason you are not using android gradle template? I think fewer people use ant build these days.

OK how I do that??? any docs link ?? will be great.
With new project from the SDK program Menu-New Project-> JME3 there Basic Game(With Gradle) BUT not mobile?? there is mobile JME3 Test witch I choosed???
android gradle template indeed is a good start .

Here are some links:

You can find many other resources if your search the forum for ā€œandroid gradle templateā€.

3 Likes

Thanks indeed I am going to test it right now.

1 Like

Indeed jmeinitializer make it an easy start and concentrate on programming the game , nice add really .Thanks for all tying to help.

4 Likes