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:
jme3-android-native-3.3.0-stable.jar
jme3-android-3.3.0-stable.jar
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
long com.jme3.bullet.PhysicsSpace.createPhysicsSpace(float,
float, float, float, float, float, int, boolean) (tried Java_com_jme3_bullet_PhysicsSpace_createPhysicsSpace and Java_com_jme3_bullet_PhysicsSpace_createPhysicsSpace__FFFFFFIZ)
com.jme3.bullet.PhysicsSpace.createPhysicsSpace(Native Method)
at
com.jme3.bullet.PhysicsSpace.create(PhysicsSpace.java:242)
at
com.jme3.bullet.PhysicsSpace.<init>(PhysicsSpace.java:235)
at
com.jme3.bullet.BulletAppState.startPhysics(BulletAppState.java:249)
at
com.jme3.bullet.BulletAppState.stateAttached(BulletAppState.java:320)
at
com.jme3.app.state.AppStateManager.attach(AppStateManager.java:148)
at
de.hc.jme.scene.MainScene.simpleInitApp(MainScene.java:142)
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).
I Do following steps from the README.md of the āBasicGame-on-Gradleā Repository to uptate to 3.6.0-beta2.
āThis problem was resolvedā doesnāt appear, instead an erreordialog āCannot load BasicGame-on-Gradle. MissingPropertyException: Could not get unknown propertie ācompileConfigurationNameāā
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:
com.jme3.asset.DesktopAssetManager.loadLocatedAsset(DesktopAssetManager.java:260) at
com.jme3.asset.DesktopAssetManager.loadAsset(DesktopAssetManager.java:374)
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.
Note:
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.
I tried this, it solved the issue in my test. I plan to cherry-pick it from the master branch to the v3.6 branch and include it in the next beta release.
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?
I downloaded and installed the 3.5.2 as .sh. Do I have to do something else, or can I simply convert all sounds to OGG and simply switch the jars in the Android Studio project?
In your gradle build dependencies simply change JME version from 3.5.2-stable to 3.6.0-beta3. Gradle will automatically download the new jars for you in Android Studio.
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.
@Ali_RS
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ā¦