Using OpenSSL Plugin in Corona Enterprise

Hello,

We are trying to include a native JAR-library into our existing App, developed with Corona pro SDK.
Everything worked fine so far, but now I am trying to include the openssl Plugin into the application.

Therefore I copied the ‘libplugin.openssl.so’ to the project’s ‘android/libs/armeabi-v7a’ folder and added the following code into the Java-File ‘android/src/<project-path>/CoronaApplication.java’
 

static { System.loadLibrary("plugin.openssl"); }

As suggested in the following post : http://forums.coronalabs.com/topic/43731-implementing-openssl-plugin-in-enterprise/

When I build the project everything works fine, but when I execute the App on the Device I get the following error :

java.lang.UnsatisfiedLinkError: Cannot load library: soinfo_link_image(linker.cpp:1673): could not load library “liblua.so” needed by “libplugin.openssl.so”;

caused by load_library(linker.cpp:771): library “liblua.so” not found
E/AndroidRuntime(29227): at java.lang.Runtime.loadLibrary(Runtime.java:371)
E/AndroidRuntime(29227): at java.lang.System.loadLibrary(System.java:535)

Then I tried to put the ‘liblua.so’ library in the same folder as the ‘libplugin.openssl.so’, but now the build failed with the following mesage :

/Applications/androidSDK/tools/ant/build.xml:313: com.android.sdklib.build.DuplicateFileException: Duplicate files at the same path inside the APK
at com.android.sdklib.build.ApkBuilder.doAddFile(ApkBuilder.java:821)
at com.android.sdklib.build.ApkBuilder.addNativeLibraries(ApkBuilder.java:716)

I read the following articles :

http://docs.coronalabs.com/native/plugin/
http://docs.coronalabs.com/daily/plugin/openssl/

but I could not figure out what is causing the problem. Am I missing something? Could anybody give me some advice what might be the issue here?

Tank you very much.

One possible issue could be that you’re trying to load the open ssl library too soon.  If you have an instance of the CoronaRuntimeListener somewhere, you can try loading the library inside this call: http://docs.coronalabs.com/native/android/html/com/ansca/corona/CoronaRuntimeListener.html#onLoaded(com.ansca.corona.CoronaRuntime)

At this stage, liblua.so should already have been loaded.

That was the problem.

I put the System#loadLibrary call to CoronaRuntimeListener#onLoaded and now everything works fine.

Thank you very much dchan.

One possible issue could be that you’re trying to load the open ssl library too soon.  If you have an instance of the CoronaRuntimeListener somewhere, you can try loading the library inside this call: http://docs.coronalabs.com/native/android/html/com/ansca/corona/CoronaRuntimeListener.html#onLoaded(com.ansca.corona.CoronaRuntime)

At this stage, liblua.so should already have been loaded.

That was the problem.

I put the System#loadLibrary call to CoronaRuntimeListener#onLoaded and now everything works fine.

Thank you very much dchan.