Propagandian
Propagandian

Reputation: 452

Adding device-specific files as a codenameone native lib

I want to add native code specific to a device to my native android libs.

So, in other words, I have a folder full of *.so files: SO File List

I then have a seperate CN1Lib app with native code contianing several libs. The example app showes this folder being added alongside normal .jar libs, so I did the same with codenameone: native libs

The soFoldercontaining all the so files (named correctly as per example android app).

I then build this CN1Lib, and add it to the main project under the lib folder, which works. However, when I inspect the codenameone APK and compare it to the example android app, the .so files sit in different locations. The example app has it under a lib folder in its root, and the codenameone app has it under the assets folder. This causes the device that requires these files to not be able to find them.

Example app vs Codenameone Structure

The example app being on the left, and the codenameone app being on the right.

Is there any way to get the so folder under a lib folder in the apk file using codenameone?

Assistance is appreciated.

Upvotes: 2

Views: 118

Answers (2)

Mucking aFazing
Mucking aFazing

Reputation: 46

If you don't want to go through the trouble of creating an AAR there is a semi-solution.

You could create a normal android library project, and after building it, manually open the archive and just drop the lib folder in there. You then add this jar file as a native android dependency.

When the build returns from codenameone, the folder should be sitting in the apk file :)

The correct way is most likely the AAR approach, but its not as straight-forward to do for a once-off solution.

Upvotes: 2

Shai Almog
Shai Almog

Reputation: 52760

I haven't worked on this much so I'm not a big expert here but as far as I understand you need to create an AAR file in Android Studio and use that. Based on the developer guide section here.

Upvotes: 1

Related Questions