Are there any Android experts who can give me a clue how to fix this please?
So my first release of my Playstore boxer app worked fine.
Then I did a few ‘tweeks’, and updated Android Studio for the second release.
And it’s not working fine any more.
In Android Studio, if I run the debug variant, it works.
In Android Studio, if I run the release variant, it crashes.
After finding out how to turn on logging for the release variant…
I found that the crash is very basic, even before my app starts.
Seems that the JmeAndroidSystem cannot be found.
2023-05-12 12:54:58.383 7837-7837 com.jme3.s…JmeSystem com.tharg.boxer
E SEVERE Failed to create JmeSystem delegate: {0}
java.lang.NoSuchMethodException: com.jme3.system.android.JmeAndroidSystem. []
at java.lang.Class.getConstructor0(Class.java:2363)
at java.lang.Class.getDeclaredConstructor(Class.java:2201)
at com.jme3.system.JmeSystem.tryLoadDelegate(JmeSystem.java:238)
at com.jme3.system.JmeSystem.checkDelegate(JmeSystem.java:250)
at com.jme3.system.JmeSystem.showSettingsDialog(JmeSystem.java:226)
at com.jme3.app.SimpleApplication.start(SimpleApplication.java:120)
at com.tharg.boxer.AndroidHarness.onCreate(AndroidHarness.java:264)
at com.tharg.boxer.MainActivity.onCreate(MainActivity.java:67)
at android.app.Activity.performCreate(Activity.java:8591)
at android.app.Activity.performCreate(Activity.java:8570)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1384)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:4150)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4325)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:101)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2574)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:226)
at android.os.Looper.loop(Looper.java:313)
at android.app.ActivityThread.main(ActivityThread.java:8757)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067)
The full logcat’s of both the debug variant (working) and distribution (crashes) are here:
Hi Pavl_G, I don’t know if I’m using a trivial AndroidHarness or not. It is based on one I copied from the IALON project shared on github by Cédric de Launois. It has always worked in the past, and still works for the debug variant. Following your tip I have tried adding
Since I don’t know if there are changes or not, it might be better to use the official AndroidHarness or JmeSurfaceView; because we are somewhat better aware of the official codebase rather than trivial implementations.
I have gone back to android-studio-2022.1.1.19-windows.exe from android-studio-2022.2.1.19-windows.exe Android Studio version. About to try going back in gradle plugin versions too
Here’s the crash using the official AndroidHarness:
E FATAL EXCEPTION: main
Process: com.tharg.boxer, PID: 18437
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.tharg.boxer/com.tharg.boxer.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method ‘android.opengl.GLSurfaceView com.jme3.system.android.OGLESContext.createView(android.content.Context)’ on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:4169)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4325)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:101)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2574)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:226)
at android.os.Looper.loop(Looper.java:313)
at android.app.ActivityThread.main(ActivityThread.java:8757)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067)
Thanks for testing, I fear there is something related to java reflection restrictions that were lately causing problems on Android releases, you can open an issue, so we could investigate into this.
FYI, the Ialon version was slightly modified to support the Android “immersive” mode, i.e. display under the notch, until the related ticket is closed.
I don’t think it has anything to do with the problem, but yes it is better to reproduce the problem using the original code
I used the debugger (once I figured out how to turn it on for the release variant).
The ‘get constructor’ of JmeAndroidSystem fails in the release variant.
But works in the debug variant.
The code that does the actual ‘getting’ is native.
I’m not sure how to step into that.
Maybe JmeAndroidSystem has not been put on whatever list the native code is looking at?
I don’t know.
Android API 33, extension level 3 Platform
Class.java
...
DEBUG VARIANT: VALUES FROM THE DEBUGGER are my comments //
private Constructor<T> getConstructor0(Class<?>[] parameterTypes,
int which) throws NoSuchMethodException
{
if (parameterTypes == null) {
parameterTypes = EmptyArray.CLASS;
}
for (Class<?> c : parameterTypes) {
if (c == null) {
throw new NoSuchMethodException("parameter type is null");
}
}
Constructor<T> result = getDeclaredConstructorInternal(parameterTypes); //RESULT: "public com.jme3.system.android.JmeAndroidSystem()"
if (result == null || which == Member.PUBLIC && !Modifier.isPublic(result.getAccessFlags())) { //WHICH=1**
throw new NoSuchMethodException(getName() + ".<init> "
+ Arrays.toString(parameterTypes)); //PARAMETER TYPES: Class[0]@22734
}
return result; //RESULT: "public com.jme3.system.android.JmeAndroidSystem()"
}
RELEASE VARIANT: //parameterTypes= Class[0]@22733 //RESULT IS NULL.
@FastNative
private native Constructor<T> getDeclaredConstructorInternal(Class<?>[] args);
//note getDeclaredConstructorInternal is native, can't step in :-(