1. Due to functional requirements, android app needs to be set as a system application;
2. To set it as a system application, I need to add android:shareduserid = "android.uid.system" in AndroidManifest.xml, but JME initialization fails after setting it as a system application; The log is as follows:
com.jme3.app.AndroidHarnessFragment: 严重 Exception thrown in Thread[GLThread 165,5,main]
com.jme3.asset.AssetNotFoundException: Interface/Fonts/Default.fnt
at com.jme3.asset.DesktopAssetManager.loadAsset(DesktopAssetManager.java:385)
at com.jme3.asset.DesktopAssetManager.loadFont(DesktopAssetManager.java:434)
at com.jme3.app.SimpleApplication.loadGuiFont(SimpleApplication.java:193)
at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:201)
at com.jme3.app.AndroidHarnessFragment.initialize(AndroidHarnessFragment.java:555)
at com.jme3.system.android.OGLESContext.onDrawFrame(OGLESContext.java:342)
at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1546)
at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1257)
Hi welcome to jme community, why you want to use the app as a system app ?
Some functions may not work properly when the app is a system app including the android application files reader used by jme, so its not recommended to do so, there would be adverse effects, and doing so in Manifest won’t make the app “a system app”.
That would probably mean that if you have changed the user app ID, then you cannot access the game package resources & files which in turn would violate the use of Assets & AssetManager.
BTW, app can be settled as system app easily through rooted devices, but that also disrupts the behavior of the app, as setting the app as a system app does nothing but copying the package to the system !
How to deal with this :
remove the uid flag.
Better use the Android Intents, Services, ContentProviders & JobSchedulers to communicate with other apps & system apps within your app, w/o changing your user id or setting the app as system app.
It is set as a system application because some functions can only be completed after obtaining permissions, which are only owned by the system application;
AFAIK, you will build a bloatware if this can take place & the app is on Google play, but for custom usages you can achieve this through being a superuser(aka using root permission) & running the command “reboot” through a ProcessBuilder.
any other Linux native command. May be running a shell script.
You cannot ask a user to control his device power(haven’t seen a permission like this before), but you can ask him for superuser permissions, that would control the device power.
For example, if I found an app on my phone that could turn it off then I’d reset to factory settings and report it to the google store. Like any other malicious software.
I wrote a test demo and added it in androidmanifest. XML
android:shareduserid = "android.uid.system".
You can use
android.content.res.AssetManager
to load resource files normally, which indicates that assetmanager can work normally. Why can’t it work in jmonkeyengine;
Jmonkeyengine uses the android.Resources class, the Android AssetManager is a low level APi a byte level, and the rest of calls is handled by the jme DesktopAssetManager.
Idk from where the problem is, but all I know that google android developer has warned from the instability behavior resulted from setting shared user id as a system app, besides the feature got deprecated since API level 29, for me I use APi 30, so I cannot go back and test a deprecated feature, sorry.
What do you mean by the source code address of Android ? The android.jar & other androids dependencies can be found on google repositories as well as AOSP.