I'm having problems deploying to Android

I have my latest target SDKS installed but whenever i try to build an APK, i get this error:

C:\Users\MOSES\AppData\Local\Android\android-sdk\tools\ant\build.xml:958: The following error occurred while executing this line:
C:\Users\MOSES\AppData\Local\Android\android-sdk\tools\ant\build.xml:969: The following error occurred while executing this line:
C:\Users\MOSES\AppData\Local\Android\android-sdk\tools\ant\build.xml:312: 
java.lang.NoClassDefFoundError: Could not initialize class sun.security.x509.X500Name
	at com.android.sdklib.internal.build.SignedJarBuilder.writeSignatureBlock(SignedJarBuilder.java:384)
	at com.android.sdklib.internal.build.SignedJarBuilder.close(SignedJarBuilder.java:273)
	at com.android.sdklib.build.ApkBuilder.sealApk(ApkBuilder.java:795)
	at com.android.ant.ApkBuilderTask.execute(ApkBuilderTask.java:371)
	at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:293)
	at sun.reflect.GeneratedMethodAccessor86.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
	at org.apache.tools.ant.Task.perform(Task.java:348)
	at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:68)
	at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:293)
	at sun.reflect.GeneratedMethodAccessor86.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
	at org.apache.tools.ant.Task.perform(Task.java:348)
	at org.apache.tools.ant.taskdefs.MacroInstance.execute(MacroInstance.java:396)
	at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:293)
	at sun.reflect.GeneratedMethodAccessor86.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
	at org.apache.tools.ant.Task.perform(Task.java:348)
	at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:68)
	at com.android.ant.IfElseTask.execute(IfElseTask.java:124)
	at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:293)
	at sun.reflect.GeneratedMethodAccessor86.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
	at org.apache.tools.ant.Task.perform(Task.java:348)
	at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:68)
	at com.android.ant.IfElseTask.execute(IfElseTask.java:124)
	at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:293)
	at sun.reflect.GeneratedMethodAccessor86.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
	at org.apache.tools.ant.Task.perform(Task.java:348)
	at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:68)
	at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:293)
	at sun.reflect.GeneratedMethodAccessor86.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
	at org.apache.tools.ant.Task.perform(Task.java:348)
	at org.apache.tools.ant.taskdefs.MacroInstance.execute(MacroInstance.java:396)
	at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:293)
	at sun.reflect.GeneratedMethodAccessor86.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
	at org.apache.tools.ant.Task.perform(Task.java:348)
	at org.apache.tools.ant.Target.execute(Target.java:435)
	at org.apache.tools.ant.Target.performTasks(Target.java:456)
	at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1405)
	at org.apache.tools.ant.Project.executeTarget(Project.java:1376)
	at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
	at org.apache.tools.ant.Project.executeTargets(Project.java:1260)
	at org.apache.tools.ant.module.bridge.impl.BridgeImpl.run(BridgeImpl.java:286)
	at org.apache.tools.ant.module.run.TargetExecutor.run(TargetExecutor.java:555)
	at org.netbeans.core.execution.RunClassThread.run(RunClassThread.java:153)
BUILD FAILED (total time: 1 minute 7 seconds)

Please how can i fix this and deploy my project to Android?

I’m using jMonkeyEngine SDK 3.2.1-stable-sdk3.

Are you building against java 1.7? If not you should be. I very rarely use OpenJDK, but google informs me that Oracle JDK is required, too.

On desktop I have no issues with recent jME and OpenJDK. Not an Android dev though, so I wouldn’t know if there are issues with OpenJDK (it would surprise me though - modern Oracle JDK is basically just a pretty-packaged OpenJDK).

1 Like

I’m using JDK1.8.0_102

thanks.
that means I should downgrade to JDK 7?

Yes same here, I had no issues deploying to desktops,
the only issue now is Android.

GREAT!!! It’s now FIXED!!!:grin:
I’m now building without errors.
It was all my fault I found out I haven’t installed the required Android SDK Tools to work with JME3 so I started Android SDK Manager and installed the required SDK Tools as shown in the JME Android help section.

Now I can deploy to Android Without any errors.

But my new Problem now is:

I can’t install the APK on my Android Device.
Whenever I try to install the APK, I get Error message on Android dialog:

Parse error
There was a problem parsing the package.

So what may be the problem now?

That’s probably because the .apk is not properly signed or you’re using a minSdkVersion bigger than your current phone’s android version.

For the first case use this to sign your .APK’s if you have trouble signing them.

For the latter, check your current Android version and the SDK version you installed and go here to ensure the SDK version you installed is not bigger than your current Android version. In case it is, you need to install a lower SDK version and compile your project using the lower SDK.

I’m not expert in Android but from the few stuff I know, I believe it’s a good practice to set the minSdkVersion to a somewhat lower Android version (like 4.4), and targetSdkVersion to a bigger version (like 6, 7, or 8 already).

1 Like

There are a plethaura of potentials that can cause that message to appear. Unfortunately due to the vague nature of the issue you’re going to have to go through them all. Googling the exact error will bring up the things you should try.

Note also that all of these issues are Android itself and not jme3.

2 Likes

MANY THANKS!!! after signing MyGame with the app u showed me it worked :relaxed:. The game Renders FAST!!

1 Like

I think JME needs a plugin so users can easily sign their apps using the Game Engine.
Because this might make other people give up along the way.
I know how I felt and I really think this should be worked on (if such time exists for the developers😃).

THANKS @Ev1lbl0w and @jayfella

I’M BOOKMARKING THIS PAGE ASAP🙋

I feel this is more like Android itself and its quirky nature, hence the Google hint. And if you read the never ending docs it shows you how to do all of this via gradle and make your life even easier.

2 Likes

@jayfella is totally right. @Kling you need to understand and learn Android development way deeper. The solution I gave you is a quick dirty way to make it work, so don’t take it for granted. If you publish your game later, you need to know how to properly sign your game. This page explain more in detail what is and how to properly do that.

2 Likes

I understand. I’ll recheck the Android Docs again. Thanks!

1 Like