Using Jar with Corona

Hello There,

I am using Corona from last 5-6 years, i know almost all basics of Corona except this Enterprise Version.

I am trying to do something new in Corona now in Enterprise.

Problem: I have written a very small and basic code in Eclipse that simply Plays  click sound. I click export there and make a jar file. Now i want to use it somehow in Corona which i am not getting how to use.

Please someone help me try to do this, I just want to make sure this jar can work in Corona then i will make a more complex piece of code.

Thanks in Advance,

Sahil sharma

That’s not quite how Corona works.  

  1. Corona Native requires you to use Android Studio to build/compile your app. This involves copying the default “App” template that we provide and loading it in Android Studio. You can copy your existing Corona simulator code to the Corona folder of that project. At that point, you have access to the various Java activities and you can call code when Corona starts, setup up functions that can be called from Corona, etc. See: https://docs.coronalabs.com/native/index.html and look at the Android section on bridging between Lua and native.  

  2. You can build a jar file, but you will likely want to make a plugin that bridges between your native .jar and your app.  

  3. Plugins still require you to use Android Studio to build your app and test it on a device or Android Emulator.  You can’t use the simulator to use your .jar files.  If simulator builds are important to you and you want to access your plugins, you can purchase our “Self-hosted plugins” feature and then you can do this. You would still need to build your plugin using Corona Native and Android Studio.  See: https://coronalabs.com/blog/2018/01/24/introducing-the-self-hosted-plugins-plan/

Rob

Hello Mr Rob,

I have successfully run the sample project from Native folder. I copied app and run android with Android Studio.

So for my target app i have modified the show function in plugin/luaLoader and write something like:

MediaPlayer pl = MediaPlayer.create(CoronaEnvironment.getCoronaActivity(), R.raw.shiv);
pl.setLooping(true);
pl.start();
return 0;

This is working successfully and playing my audio file shiv which is located in res/raw.

Issue i am facing is when i press the homeButton, the music keeps playing for just 3-4 seconds and then stops.

I think i need to make a service which will keep playing in the background but don’t know how to make that in Native for Corona.

I have done an app in Unity which is working successfully but i want to port from Unity to Corona because i personally like Corona and not Unity.

If Corona can please provide me the support with Native, it would be best and i would be very thankful.

Thanks,

Sahil sharma

I’m glad you have this working. 

Please see our support information page regarding native support:  https://coronalabs.com/support/

Rob

That’s not quite how Corona works.  

  1. Corona Native requires you to use Android Studio to build/compile your app. This involves copying the default “App” template that we provide and loading it in Android Studio. You can copy your existing Corona simulator code to the Corona folder of that project. At that point, you have access to the various Java activities and you can call code when Corona starts, setup up functions that can be called from Corona, etc. See: https://docs.coronalabs.com/native/index.html and look at the Android section on bridging between Lua and native.  

  2. You can build a jar file, but you will likely want to make a plugin that bridges between your native .jar and your app.  

  3. Plugins still require you to use Android Studio to build your app and test it on a device or Android Emulator.  You can’t use the simulator to use your .jar files.  If simulator builds are important to you and you want to access your plugins, you can purchase our “Self-hosted plugins” feature and then you can do this. You would still need to build your plugin using Corona Native and Android Studio.  See: https://coronalabs.com/blog/2018/01/24/introducing-the-self-hosted-plugins-plan/

Rob

Hello Mr Rob,

I have successfully run the sample project from Native folder. I copied app and run android with Android Studio.

So for my target app i have modified the show function in plugin/luaLoader and write something like:

MediaPlayer pl = MediaPlayer.create(CoronaEnvironment.getCoronaActivity(), R.raw.shiv);
pl.setLooping(true);
pl.start();
return 0;

This is working successfully and playing my audio file shiv which is located in res/raw.

Issue i am facing is when i press the homeButton, the music keeps playing for just 3-4 seconds and then stops.

I think i need to make a service which will keep playing in the background but don’t know how to make that in Native for Corona.

I have done an app in Unity which is working successfully but i want to port from Unity to Corona because i personally like Corona and not Unity.

If Corona can please provide me the support with Native, it would be best and i would be very thankful.

Thanks,

Sahil sharma

I’m glad you have this working. 

Please see our support information page regarding native support:  https://coronalabs.com/support/

Rob