Command Line Android Deployment

Hey Monkey Community! I am new to the engine, but I have a lot of programming experience. I been developing my app for desktop and it’s been running amazing, thanks to the great documentation and other posts, but android deployment becomes a little difficult. I have been creating my game using the command line and utilizing the correct jar files during compilation and running. I have created android apps using the command line just fine, even able to make android games using other engines the same way. So now onto the problems…

Using the jme3 stable 3.1 jars I get the following error when I run the apk

06-22 18:12:55.064 25867 25867 E AndroidRuntime: FATAL EXCEPTION: main
06-22 18:12:55.064 25867 25867 E AndroidRuntime: Process: com.marcus.base, PID: 25867
06-22 18:12:55.064 25867 25867 E AndroidRuntime: java.lang.ExceptionInInitializerError
06-22 18:12:55.064 25867 25867 E AndroidRuntime: at com.jme3.system.AppSettings.(AppSettings.java:150)
06-22 18:12:55.064 25867 25867 E AndroidRuntime: at com.jme3.app.AndroidHarness.onCreate(AndroidHarness.java:223)

This error can be solved by going into AppSettings and returning a generic string in the method referred to in the AppSettings class. Then after that it points to two other classes, that’s also fixed by returning strings in place of build number and another string value that should be found in version.properties file (which exists) but is not being read I believe.

However the issue that really has me at a standstill is the application throwing an exception and saying it cannot find /Interface/Fonts/Default.fnt. However that file is found in the appropriate location in the jme3-core jar. I’ve read other forum posts about this issue on jme 3.0, but saw that it was supposed to be fixed in 3.1.

Anyone with information please help me fix this issue and get my app running from the command line. My suspicion is that my application may not be search on the device properly. I remember seeing an error saying that a locator was not registered to AssetManager. So I tried registering AndroidLocator to the assetManager defined in DesktopAssetManager and the assetManager referred to in ImplHandler, however, I either get compile errors when using gradle or if I do it using javac and pointing the classpath to the libs it compiles but I get nulls at runtime.

Thank you to anyone who assist with this. Definitely the best game engine I’ve had the experience to use.

Edit 1:
Additional Info that may help is i’m testing on a device running Android 7.1.2

1 Like

/Interface/Fonts/Default.fnt.

This error if I recall is caused by many different things. Usually trying to restart an instance of the application when it’s already running.

Have you tried specifying whether your game is landscape or portrait in the manifest?

1 Like

Yup I tried that. I think I learned that from your compiled posts to help android users, thanks for that by the way!

java.lang.ExceptionInInitializerError
E AndroidRuntime: at com.jme3.system.AppSettings.(AppSettings.java:150)

Is the initial error that I used dirty solutions to solve (replacing strings), so i’m willing to take another shot in the dark and say it’s just struggling to initialize properly. I can’t understand why when all of the jar files are in the correct places and I’m able to completely compile the java code and create an apk.

1 Like

Can I see your manifest and MainActvity.

I’ve yet to be beat by the default font error and I hope I can help you.

1 Like

Here's my Manifest file:

   <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="com.marcus.base"
        versionCode="1"
        versionName="1.0">
        <uses android:minSdkVersion="16"/>
        <application android:label="Black Adam" 
                android:theme="@style/CustomStyle">
                <activity android:name=".Driver"
                        android:screenOrientation="landscape">
                        <intent-filter>
                                <action android:name="android.intent.action.MAIN"/>
                                <category android:name="android.intent.category.LAUNCHER"/>
                        </intent-filter>
                </activity>
        </application>
</manifest>

Here’s my Main Activity that extends Android Harness:

package com.marcus.base;
import android.os.Bundle;
import com.jme3.app.AndroidHarness;

public class Driver extends AndroidHarness
{
        public Driver()
        {       
                appClass = "com.marcus.base.Test";
        }

        public void onCreate(Bundle savedInstanceState)
        {       
                super.onCreate(savedInstanceState);
        }
}
1 Like

I just gave moving appClass line before super.onCreate() and I was still prompted with the initial error of:

06-25 11:04:13.423 25404 25404 E AndroidRuntime: FATAL EXCEPTION: main
06-25 11:04:13.423 25404 25404 E AndroidRuntime: Process: com.marcus.base, PID: 25404
06-25 11:04:13.423 25404 25404 E AndroidRuntime: java.lang.ExceptionInInitializerError
06-25 11:04:13.423 25404 25404 E AndroidRuntime: 	at com.jme3.system.AppSettings.<clinit>(AppSettings.java:150)
06-25 11:04:13.423 25404 25404 E AndroidRuntime: 	at com.jme3.app.AndroidHarness.onCreate(AndroidHarness.java:223)
06-25 11:04:13.423 25404 25404 E AndroidRuntime: 	at com.marcus.base.Driver.onCreate(Driver.java:16)

Could you please give more insight into referencing the Activity lifecycle or an example.

1 Like

Thank you so much for that diagram! My code is almost identical just that line change.

package com.marcus.base;

import android.os.Bundle;
import com.jme3.app.AndroidHarness;

public class Driver extends AndroidHarness
{
    public Driver()
    {
            //appClass = "com.marcus.base.Test";
    }

    public void onCreate(Bundle savedInstanceState)
    {
            appClass = "com.marcus.base.Test";
            super.onCreate(savedInstanceState);
    }
}
1 Like

I don’t use any IDEs. just vim, and prefer to keep my development command line based.

1 Like

I was initially using API 25 and recently switched to 26 with no difference. Yeah I definitely consider these problems weird, cause I replicate the same compilation and apk build process with other apps with no problems. Closest I came to this issue was another library shaders weren’t being found just like this /Interface/Fonts/Default.fnt isn’t being found so I moved the shaders to an asset folder and called it within the application and it worked.

I just want to say thank you so much for all of the tips you’ve provided, and the flow chart is greatly appreciated!

Edit:
Other library as in another engine I was using.

1 Like

Hey,

If you hadn’t solved this try adding this method to your main activity

@Override
public void onDestroy() {
    super.onDestroy();
    System.runFinalization();
    android.os.Process.killProcess(android.os.Process.myPid());
}
1 Like

Unfortunately, that still didn’t solve it for me.

1 Like