With an Android Studio template project and Android 8 SDK (API level 26) I wanted to run from a JME project as an APK.
This has worked several times in the past on other projects.
The jme-android library currently adds these two jars for this:
The build in Andrid Studio started without any problems, but when I ran the APK on an Android 8 AVD I got this error:
E FATAL EXCEPTION: GLThread 208
Process: de.hc.crash, PID: 5234
java.lang.UnsatisfiedLinkError: No implementation found for
float, float, float, float, float, int, boolean) (tried Java_com_jme3_bullet_PhysicsSpace_createPhysicsSpace and Java_com_jme3_bullet_PhysicsSpace_createPhysicsSpace__FFFFFFIZ)
Do I need a more up-to-date SDK now, or does the error have another cause
This JAR contains the desktop natives for Bullet and serves no purpose on Android.
Replacing it with “jme3-bullet-native-android-3.3.0-stable.jar” should solve the UnsatisfiedLinkError.
Two years ago, JMonkeyEngine stopped supporting native Bullet (“jme3-bullet”). If you ever upgrade to a recent Engine release (such as 3.5.2-stable or 3.6.0-beta2) you’ll need to transition to a different physics library. The main alternatives are “jme3-jbullet” and Minie, both of which are nearly compatible with “jme3-bullet”. Of the two, I recommend Minie (because I maintain it).
with the change of the jar, the NiftyGui starts at least once, but the screen of the AVD goes black as soon as the game is started. The reason for this could be that the app cannot find the sound assets (they are all under assets/Sounds). However, a warning comes and is caused by:
Caused by: java.lang.UnsupportedOperationException: Cannot load audio files from classpath.Place your audio files in Android's assets directory
Since the class “DesktopAssetManager” appears in the trace, I assume that I still have to adapt something for Android:
Here is a list of the current jars in the Android Studio project:
DesktopAssetManager is used both on desktop and android. It is a misnomer!
these might be related:
I have not read those threads thoroughly so I am not sure what actually causes the UnsupportedOperationException on android when loading Ogg files outside of android’s assets directory (‘src/main/assets’ ,located in your app’s project) but it works fine with other assets. It probably is a limitation in android NativeVorbisLoader.
I have recently updated jme3-android to use OGGLoader from jme3-jogg instead of NativeVorbisLoader for loading ogg audio which might solve this issue.
You need to build the engine from the master branch if you are interested to give it a try. Please let me know if it solves the issue.
Thanks for the tip about OGG. I actually had an OGG file included. All other effects were WAV. Since the background melody doesn’t take up that much disk space, I converted it to OGG. I took this out as a test for the Android Studio. The APK now works in the AVD. I will probably convert the OGG as a WAV. Thanks!
Addendum: Apparently there are no sound effects anymore. But I noticed that the shadow cast can now also be activated in the app, which was not possible at the time of my first JME → APK migratin two years ago. Even workarounds, which I built into JME at the time because some things looked different under Android, are now superfluous. But I guess I have to convert all sounds to OGG and solve the actual problem that OGGs are searched for in Android Assets folders. Can I just copy the OGG files to a folder in the Android Studio project, or does it get more complicated?
You can put the sounds in your assets directory just like you do for a desktop JME app, that is where you have put all your other assets, like textures, models, wav files,… more specifically put sounds inside assets/Sounds.
I think I use a different template for the Android Studio project than you (I found it on the internet about 2 years ago and used it at the time). Maybe I have so many problems because the template is outdated. Since I have no real idea about Android Studio, I can’t say that badly. I’ll see if I can find a newer template on the Internet, which is also a little documented.
On Github “jMonkeyEngine-Templates/basic-android-studio-template” is a much slimmer template than my current one. This also has the mentioned JME version references in gradle. Is there a step-by-step guide for people like me who don’t know anything about Android Studio?
I was looking for something like that back then. I’ll try my next project, which should also be for Android. But right now I’m lazy. I created an asset folder in the Android Studio project and copied the assets into it and deleted the asset.jar from the libraries. The APK now works with sound and shadows. With the template it will certainly be much easier next time (I hope…). Thank you for helping me!
If you guys think this template is useful, i will create a forum thread for it to discuss various features, so for example, i plan to make a simple android guide on this repository and some helper gradle tasks that may enable us to run emulators and install the application via adb through command-line tools that may be good for people who don’t use android studio and for those who use jme-sdk netbeans you could use it normally as a gradle project…