Implementing OpenSSL plugin in Enterprise?

When using Pro we just included the plugin in our build.settings file.

I’m aware that this doesn’t work in enterprise, and that we would need to include the .jar file for android and a .a file for iOS.

How can we go about getting these files for the OpenSSL plugin?

You can get them on the enterprise download page: http://developer.coronalabs.com/downloads/enterprise-daily-builds

With each release of enterprise, there is also a .tgz which has all the binaries for the plugin.

Do we need to do anything in particular with them? I assumed they could just be dropped into the project’s “libs” folder, but when I try that in my project I get:

module ‘plugin.openssl’ not found:resource (plugin.openssl.lu) does not exist in archive
no field package.preload[‘plugin.openssl’]
no file ‘(null)/plugin.openssl.lua’
no file ‘(null)/plugin.openssl.lua’
no file ‘/data/app-lib/com.mycompany.myapp-1/libplugin.openssl.so’
no file ‘./plugin.openssl.so’
no file ‘(null)/plugin.openssl.so’
no file ‘/data/app-lib/com.mycompany.myapp-1/libplugin.so’
no file ‘./plugin.so’
no file ‘(null)/plugin.so’
stack traceback:
[C]: in function ‘require’
?: in function ‘require’
?: in main chunk
 

The only time I’ve used the plugins in Enterprise was when I was making one, so I had the src/plugin/LuaLoader file when building it directly into an app, and then downloaded the plugin from Corona to test using it once it had been compiled.

I’m probably being really simple, but what step have I missed?

You need to put it into “libs/armeabi-v7a/”.  You also have to call http://developer.android.com/reference/java/lang/System.html#loadLibrary(java.lang.String)

with name = “plugin.bit”.  The reason is because this is a native library.

Sorry it’s taken me so long to reply, I had to switch to another part of the project. The last past you mentioned:

"You also have to call http://developer.android.com/reference/java/lang/System.html#loadLibrary(java.lang.String)

with name = “plugin.bit”.  The reason is because this is a native library."

Where would this be done? Although we are using Enterprise, we haven’t actually had any need to touch any of the java code yet, mostly we’ve been using it for offline building.

I’m guessing it’s probably in the CoronaApplication.java file, but not 100% certain of that, or where in that file it should go.

And can I check that you did mean “plugin.bit” and not “plugin.openssl”, is the openssl plugin reliant on the bit plugin or was that a typo?

You can get them on the enterprise download page: http://developer.coronalabs.com/downloads/enterprise-daily-builds

With each release of enterprise, there is also a .tgz which has all the binaries for the plugin.

Do we need to do anything in particular with them? I assumed they could just be dropped into the project’s “libs” folder, but when I try that in my project I get:

module ‘plugin.openssl’ not found:resource (plugin.openssl.lu) does not exist in archive
no field package.preload[‘plugin.openssl’]
no file ‘(null)/plugin.openssl.lua’
no file ‘(null)/plugin.openssl.lua’
no file ‘/data/app-lib/com.mycompany.myapp-1/libplugin.openssl.so’
no file ‘./plugin.openssl.so’
no file ‘(null)/plugin.openssl.so’
no file ‘/data/app-lib/com.mycompany.myapp-1/libplugin.so’
no file ‘./plugin.so’
no file ‘(null)/plugin.so’
stack traceback:
[C]: in function ‘require’
?: in function ‘require’
?: in main chunk
 

The only time I’ve used the plugins in Enterprise was when I was making one, so I had the src/plugin/LuaLoader file when building it directly into an app, and then downloaded the plugin from Corona to test using it once it had been compiled.

I’m probably being really simple, but what step have I missed?

You need to put it into “libs/armeabi-v7a/”.  You also have to call http://developer.android.com/reference/java/lang/System.html#loadLibrary(java.lang.String)

with name = “plugin.bit”.  The reason is because this is a native library.

I hate having to bump topics, but I’m still hoping to get some guidance on including libraries into enterprise projects.

Having searched, I’ve found that apparently I include the native plugins like this:

public class CoronaApplication extends android.app.Application { /\*\* Called when your application has started. \*/ @Override public void onCreate() { com.ansca.corona.CoronaEnvironment.addRuntimeListener(new CoronaApplication.CoronaRuntimeEventHandler()); } static { //load library here System.loadLibrary("plugin.openssl"); } private class CoronaRuntimeEventHandler implements com.ansca.corona.CoronaRuntimeListener { //other functions } }

Firstly, is that the correct place to do it, and will I need to do anything else for my require in my lua code to work?

Secondly, how about jar libraries? Do we use System.loadLibrary, or import the package name for each plugin, or something else entirely?  

Lastly, what is the process for including plugins on iOS? The “analytics-provider” sample looks like it just includes .h and .mm in its Plugin folder, is that all there is to it?

I’m struggling to find much in the way of documentation for doing this in Enterprise, I presume most Enterprise users are already experienced native android/ios developers, but as a newbie it’s not quite so straightforward.

You just need to call system.loadLibrary before you try to use the plugin.  The place you’re calling it should be fine.

You don’t need to do anything explicit to use jar files.

plugin.bit was a type.  It should have been plugin.openssl.

iOS should be something like this: https://developer.apple.com/library/ios/recipes/xcode_help-project_editor/Articles/AddingaLibrarytoaTarget.html

I’d managed to get it working just as your reply pinged in my inbox, but thank you for confirming that I’ve done it properly. When I posted I hadn’t tested the build with just the loadLibrary for the native libraries, I’d assumed that the jar files would have to be required somehow manually, and then finally decided to comment out all of my “imports” and it worked. 

The ios stuff will be handy when I move onto that shortly.

Thanks again  :slight_smile:

It turned out I didn’t have it 100% fixed, as I also had to add intent-filter/services/etc to the AndroidManifest.xml file, which I mostly have working now.

I have the facebook, flurry, vungle and google play game services plugins working, but I’m struggling to get google IAP working when I build with Enterprise (it works when I build from simuator). When I call store.purchase() nothing happens, I don’t get any errors or any reply at all.

I’m using the plugin.google.iap.v3.jar, and my manifest file has the com.android.vending.BILLING permission and the following:

\<receiver android:name="com.ansca.corona.purchasing.GoogleStoreBroadcastReceiver"\> \<intent-filter\> \<action android:name="com.android.vending.billing.IN\_APP\_NOTIFY" /\> \<action android:name="com.android.vending.billing.RESPONSE\_CODE" /\> \<action android:name="com.android.vending.billing.PURCHASE\_STATE\_CHANGED" /\> \</intent-filter\> \</receiver\>

Is there something else I’m missing? I’m guessing you’ll spot something straight away Danny.

Similarly, I’m not sure how to integrate google play licensing when building with Enterpise. I have the com.android.vending.CHECK_LICENSE permission, and I see there is a google play licensing plugin included with corona enterprise (just called classes.jar), but I’m not sure how I’m supposed to use it.

For the most part we’re using enterprise to do offline building and building multiple apks at once from the command line, so any of the native java stuff isn’t second nature to me yet as we haven’t had to use it.

If anyone can point me in the right direction for these things it would be greatly appreciated. 

Have you checked the log to see if any error messages show up there?

The licensing plugin is just like any other plugin, its just named differently.  You just have to put it in the libs directory along with the other jar files.  After that in your lua code you would call the licensing library like normal.

http://docs.coronalabs.com/daily/api/library/licensing/init.html

I had the log set to look for “Corona” tags, I’ll double check the whole log and then get back to you (the galaxy s4 fills the log like crazy).

With regards to the licensing plugin, when we’ve built in the simulator we have something like this in config.lua:

license = { google = { key = "aMassiveLongString", policy = "serverManaged", }, },

Is that not necessary? And if it is, where would we put that “key” string when building for enterprise? Or will it still be pulled from config.lua (I know that most stuff in build.settings is ignored when building with enterprise, not sure about config.lua).

Thanks

While build.settings is ignored for Android Enterprise, config.lua is not ignored.  The plugin will read those values from config.lua.

Ok cool. Now that I think about it, if config.lua was ignored all the image scaling would have been messed up.

I probably won’t get to rebuild the project and check the IAP logs until the morning now, but I’ll update this post with my findings once I have.

Sorry it’s taken me so long to reply, I had to switch to another part of the project. The last past you mentioned:

"You also have to call http://developer.android.com/reference/java/lang/System.html#loadLibrary(java.lang.String)

with name = “plugin.bit”.  The reason is because this is a native library."

Where would this be done? Although we are using Enterprise, we haven’t actually had any need to touch any of the java code yet, mostly we’ve been using it for offline building.

I’m guessing it’s probably in the CoronaApplication.java file, but not 100% certain of that, or where in that file it should go.

And can I check that you did mean “plugin.bit” and not “plugin.openssl”, is the openssl plugin reliant on the bit plugin or was that a typo?

I hate having to bump topics, but I’m still hoping to get some guidance on including libraries into enterprise projects.

Having searched, I’ve found that apparently I include the native plugins like this:

public class CoronaApplication extends android.app.Application { /\*\* Called when your application has started. \*/ @Override public void onCreate() { com.ansca.corona.CoronaEnvironment.addRuntimeListener(new CoronaApplication.CoronaRuntimeEventHandler()); } static { //load library here System.loadLibrary("plugin.openssl"); } private class CoronaRuntimeEventHandler implements com.ansca.corona.CoronaRuntimeListener { //other functions } }

Firstly, is that the correct place to do it, and will I need to do anything else for my require in my lua code to work?

Secondly, how about jar libraries? Do we use System.loadLibrary, or import the package name for each plugin, or something else entirely?  

Lastly, what is the process for including plugins on iOS? The “analytics-provider” sample looks like it just includes .h and .mm in its Plugin folder, is that all there is to it?

I’m struggling to find much in the way of documentation for doing this in Enterprise, I presume most Enterprise users are already experienced native android/ios developers, but as a newbie it’s not quite so straightforward.

You just need to call system.loadLibrary before you try to use the plugin.  The place you’re calling it should be fine.

You don’t need to do anything explicit to use jar files.

plugin.bit was a type.  It should have been plugin.openssl.

iOS should be something like this: https://developer.apple.com/library/ios/recipes/xcode_help-project_editor/Articles/AddingaLibrarytoaTarget.html

I’d managed to get it working just as your reply pinged in my inbox, but thank you for confirming that I’ve done it properly. When I posted I hadn’t tested the build with just the loadLibrary for the native libraries, I’d assumed that the jar files would have to be required somehow manually, and then finally decided to comment out all of my “imports” and it worked. 

The ios stuff will be handy when I move onto that shortly.

Thanks again  :slight_smile: