Which is the minimum SDK Version to build JME for mobile?

Hello,

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

1 Like

Which bullet physics library are you using ?

2 Likes

Do not know exactly. In Libaries booth are added:
jme3-bullet-native-3.3.0-stable.jar
jme3-bullet-3.3.0-stable.jar

In the code I import com.jme3.bullet.BulletAppState
Where can I see something meaningful to answer your question?

1 Like

jme3-bullet-native-3.3.0-stable.jar

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).

1 Like

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’”

I’ve replaced jme3-bullet-native-3.3.0-stable.jar with

I will update this thread after testing on the AVD

1 Like

“BasicGame-on-Gradle” is a desktop-only project, not a mobile project. Sorry!

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:

assets.jar                                   jme3-core-3.3.0-stable.jar        jutils-1.0.0.jar
crash.jar                                    jme3-effects-3.3.0-stable.jar     lwjgl-2.9.3.jar
gson-2.8.1.jar                               jme3-jogg-3.3.0-stable.jar        lwjgl-platform-2.9.3-natives-linux.jar
jinput-2.0.5.jar                             jme3-lwjgl-3.3.0-stable.jar       lwjgl-platform-2.9.3-natives-osx.jar
jinput-platform-2.0.5-natives-linux.jar      jme3-networking-3.3.0-stable.jar  lwjgl-platform-2.9.3-natives-windows.jar
jinput-platform-2.0.5-natives-osx.jar        jme3-niftygui-3.3.0-stable.jar    nifty-1.4.3.jar
jinput-platform-2.0.5-natives-windows.jar    jme3-plugins-3.3.0-stable.jar     nifty-default-controls-1.4.3.jar
jme3-android-3.3.0-stable.jar                jme3-terrain-3.3.0-stable.jar     nifty-style-black-1.4.3.jar
jme3-android-native-3.3.0-stable.jar         jme3-testdata.jar                 xpp3-1.1.4c.jar
jme3-bullet-3.3.0-stable.jar                 j-ogg-all-1.0.0.jar
jme3-bullet-native-android-3.3.0-stable.jar  jsr305-2.0.2.jar

which jar has to be replaced too?

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 reporting the issue.

2 Likes

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?

You may use this template

There is one pending PR, I hope @Pavl_G integrates that soon :slightly_smiling_face:

1 Like

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!

2 Likes

Hi there !

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…

1 Like