Minie - Problem generating Android signed bundle

Hello Guys,
While trying to generate Android signed bundle (Google doesn’t allow publishing regular APKs anymore…),
I’m getting this error:

Execution failed for task ':app:packageReleaseBundle'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
   > File 'root/lib/armeabi-v7a/empty' uses reserved file or directory name 'lib'.

This happens only with Minie dependency (implementation ‘com.github.stephengold:Minie:4.6.1’)
Generating regular APK works fine.
Does anyone knows how to overcome this issue?
@sgold What do you think?

Thanks!

2 Likes

The “empty” files in Minie are just placeholders for Git. You could delete those files without any consequences.

Based on the error message, however, I expect bundle creation would still fail on the native library (“lib/armeabi-v7a/libbulletjme.so”) which is essential for Minie to work on Android.

Does anyone knows how to overcome this issue?

Perhaps you can relocate the native physics libraries. If you do, you’ll need to extract and load them yourself. I’m not sure how Android apps extract their native libraries. Androids load their native physics libraries at line 34 of “JmeAndroidSystem.java”.

2 Likes

OK. Thanks, I’ll try following your suggestions and report the solution.
It’s a critical issue.

1 Like

I’ve modified the Minie build scripts to exclude the placeholder files from the next release.

I also found a question at Stack Overflow that looks relevant:

2 Likes

Any news regarding this issue?

been on vacation this weekend. I’ll be back dealing with it in a few days. I have to find some kind of solution for this. I guess anyone uses Minie and deploying for Android will encounter the same problem sooner or later therefor it’s so critical issue.

1 Like

HI Stephen. What do you mean relocate the native library? will I see it somewhere in the Minie repo? (I see there is a libbulletjme project in your github - did you mean modifying that project?) If I change its location how will that affect the /empty reserved directory?

1 Like

What do you mean relocate the native library?

I meant putting them at different locations in the classpath. For instance, “jme3-android” expects to find the native library for ARMv7 at “lib/armeabi-v7a/libbulletjme.so” on the classpath. If Android regards “lib” as a reserved directory, you could relocate the native library (to something like “native/armeabi-v7a/libbulletjme.so”) and add Java code to extract it from there.

will I see it somewhere in the Minie repo?

No, in the Minie JARs. For instance using the JAR command from a Unix shell:

$ jar tf Minie-4.6.1.jar | grep .so
com/jme3/bullet/animation/TorsoLink.class
com/jme3/bullet/animation/TorsoLink$1.class
lib/x86/libbulletjme.so
lib/arm64-v8a/libbulletjme.so
lib/armeabi-v7a/libbulletjme.so
lib/x86_64/libbulletjme.so
native/linux/x86/libbulletjme.so
native/linux/arm32/libbulletjme.so
native/linux/arm64/libbulletjme.so
native/linux/x86_64/libbulletjme.so
$ 

I see there is a libbulletjme project in your github - did you mean modifying that project?

No.

If I change its location how will that affect the /empty reserved directory?

There’s no /empty directory in Minie. Certain directories in the project have empty files for placeholders, so that the build scripts don’t have to create the directories they’re in. (Only files can be committed to Git, not directories.)


However, based on the Stack Overflow information, I now think the issue is that Android doesn’t want native libraries to appear in JARs, only in AARs. So I now suspect that relocating the native libraries won’t help.

I suspect that converting the Minie JAR to an AAR will provide the solution. I don’t know anything about AAR files. It might be a simple matter of renaming, or you might have to extract files from the JAR and use some Android tool to archive the extracted files into an AAR.

1 Like

Thanks a lot! I will read the Stack Overflow post again to better understand what are the differences between AAR & JAR

1 Like

The first thing that I need to try is either to convert Minie jar to aar or compile it from the source to aar. it might be enough for making the whole thing work.

1 Like

Did that make it work?

Hi Stephen. So far I didn’t manage to make the gradle build an AAR instead of jar.
I tried simply change the file extension - didn’t work - there is a missing android manifest file
I tried adding android plugin to the gradle file but it didn’t work.
Next, I will try building an aar project from scratch see how they target the gradle to build aar file and try to apply it on the Minie gradle file

1 Like

I found a list of what AAR files must/may contain: https://www.dynamsoft.com/codepool/build-so-aar-android-studio.html

It appears to be a wrapper around the class JAR that segregates any assets and native libraries from the classes…

What’s inside aar file?

    /AndroidManifest.xml (mandatory)
    /classes.jar (mandatory)
    /res/ (mandatory)
    /R.txt (mandatory)
    /assets/ (optional)
    /libs/*.jar (optional)
    /jni//*.so (optional)
    /proguard.txt (optional)
    /lint.jar (optional)

The structure of aar is similar to apk.
1 Like

Yes, it makes sense. I guess APK and AAR are pretty much the same - contain the AndroidManifest.xml , same structure etc. for some reason It’s hard to convert Minie’s gradle to produce AAR using the com.android.library plugin. maybe because it has a lot of Win/Linux sub projects stuff. I’m trying to remark all the non-Android stuff and see if it works… So far no success.
I’m also looking for friends/connections who might know how to manipulate the Gradle file (because I don’t have a lot of experience with it)
And last - if I see I’m investing too much time , I’ll look for professional assistance because this thing must be solved…

1 Like

I don’t know what is the solution for this, but i know something that may help you :slight_smile: :

the lib folder on android apk file is reserved for *.so files or native object files which are generated when compiling any native project using android clang++ toolchains, so if you have a jar file (that has a directory named lib and this directory contains the compiled arm object files), you can add it easily as a dependency using : implementation files('libs/Arithmos/dependencies/android-natives-21.jar') for instance…

This is an example of a native dependency on android that is compiled externally (directly using clang++) and packaged into a .jar file :

image

But, i haven’t tried generating an app bundle for this…and i think jmonkeyengine is doing the same internally…which may point us to the underlying problem.

And, i found this on output/debug/app-debug.aab which appears to be an unsigned app bundle file, it contains similar structure to the real apk, all .class files inside jars (which are added by gradle) are compiled into dex code and packaged into ./dex/classes.dex and other native files are added directly to the root dir . :

i think you don’t need to do this, as .AAR files are just some jars with an AndroidManifest file like an apk but more like android library file, all jmonkeyengine libs are added as jars and they work fine, so Minie should work fine too with jar.

As you can see here all androidx libs are .AAR files which contains some jars with AndroidManifest.xml file that specify the target and min sdk versions :
image

Out of curiosity, if you want to try the AAR file, simply create an android library module and add the jars to it as dependencies then add this module to your root module.

For example this is my lib (Android module in nature with some java code/jars/or whatever and jars can have some native files) :

2 Likes

Thanks a lot! You gave me a few directions. I’ll try & report if it helps

2 Likes

Update - With the assistance of @sgold we have now a working solution for Android signed bundles Which uses the Minie physics.
All you have to do in order to use Minie in your Android apps is adding these 2 lines in the Gradle build file:

implementation "com.github.stephengold:Minie:4.7.1+bare"
implementation "com.github.stephengold:Minie:4.7.1+ano"

the first line, adds Minie without any native “.so” libraries
the second line adds only the Android native (".so") libs

Thank you for the great support!

4 Likes

Great News !!

Testing this now, i got this exception :

E/pers.hellomini: No implementation found for int com.jme3.bullet.util.NativeLibrary.countThreads() (tried Java_com_jme3_bullet_util_NativeLibrary_countThreads and Java_com_jme3_bullet_util_NativeLibrary_countThreads__)
E/AndroidRuntime: FATAL EXCEPTION: GLThread 7771
    Process: com.scrappers.hellominie, PID: 22408
    java.lang.UnsatisfiedLinkError: No implementation found for int com.jme3.bullet.util.NativeLibrary.countThreads() (tried Java_com_jme3_bullet_util_NativeLibrary_countThreads and Java_com_jme3_bullet_util_NativeLibrary_countThreads__)
        at com.jme3.bullet.util.NativeLibrary.countThreads(Native Method)
        at com.jme3.bullet.BulletAppState.<init>(BulletAppState.java:141)
        at com.scrappers.hellominie.MyGame.simpleInitApp(MyGame.java:42)
        at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:240)
        at com.jme3.view.surfaceview.JmeSurfaceView.initialize(JmeSurfaceView.java:294)
        at com.jme3.system.android.OGLESContext.onDrawFrame(OGLESContext.java:344)
        at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1573)
        at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1272)

Something with the new minie multi-threading i guess, is there a separate module for that ?

1 Like

This is the exact problem I have faced recently. I consulted with Stephen and his guess was that for some reason maybe the native “.so” files were not loaded and/or not bundled in the .aar
Can u share the gradle file that you are using for this test?

1 Like