Corona Enterprise + Android SDK : This application failed to load and execute main.lua

We have been trying since last week But couldn’t integrate Corona enterprise with native android. We tried all the sample apps but all apps are throwing the same error “This application failed to load and execute main.lua”.

What we have tried:

  1. Like for example we started by creating the local.properties in “/Applications/CoronaEnterprise/Samples/SimpleLuaExtension/android” using “Building with Ant” using steps provided in "http://docs.coronalabs.com/daily/native/android/index.html"

  2. We imported the project in android sdk, which was then throwing the reference error for including Corona library. We included the library from “/Applications/CoronaEnterprise/Corona/android/lib/Corona”. (Let me know if that is what should or shouldn’t be added as library as it itself looks like a project.)

  3. We built the app for simulator and device, but they both are crashing with “This application failed to load and execute main.lua” as error in console.

Possible reason is we are not including main.lua file anywhere manually. We don’t know if it is called manually or automatically by the sdk.

So the first and foremost question is how and where to call the main.lua file?

I only compile from the command line using build.sh.

I always modify the original build.sh and add a variable ANDROID_BUILD_TARGET=android-16 at the top of the script.

Then I append --target $ANDROID_BUILD_TARGET to *all* lines where update project is called.

If I do this on the sample project you mentioned (SimpleLuaExtension) and then run ./build.sh the app compiles successfully, and produces an APK in the bin folder. I sign the app and then install. The app runs and prints the output as expected without error.

NOTE: You’ll need to have the Android SDK (API level 16) installed when you do this.

Hi ingemar, I know this is too much to ask but can you please guide me step by step on how to integrate corona with android sdk. As the tutorial on the Corona blog is not really basic as stated on it. Sample app is supposed to be just imported and run as it is.

Also main.lua looks for the library plugin. How does that work? Do we have to create a plugin file and then copy the file to corona folder or something else?

First we’ll need to get the sample app up and running to confirm that your setup is OK.

What happens when you compile SimpleLuaExtension using build.sh?

Also, The following info will help.

  1. Which Android API versions do you have installed?

  2. What version of OSX are you on?

When I was compiling the app before using build.sh I was getting 3 errors, but miraculously the build was successful this time. May be because android sdk was running at the time of previous try and it was close this time.

Terminal says:

release:

BUILD SUCCESSFUL

As for android, Api sdk is level 16 and my osx version is 10.8.5

Successful build sounds good.  :slight_smile:

Go to the bin directory, sign the app and then install it on device.

Do you still get an error?

A few questions…

  1. Should I sign this apk from eclipse or terminal?

  2. If I am importing this project into eclipse, in that case it is showing a reference library error in properties. It is asking to import a corona library. So I am importing it from “/Applications/CoronaEnterprise/Corona/android/lib/Corona”.

Is this what I am supposed to do?

  1. Try the command line.

  2. Sorry, I don’t use Eclipse or any other IDE. I only use the command line.

I found this “SimpleLuaExtension-release-unsigned.apk” in bin directory. I believe I have to sign this unsigned apk. Can you please tell me the commands to use for signing the apk via terminal?

There are 2 commands you’ll need to run.

I always sign with my release key.

(You can create a script so you don’t need to type everything every time)

In the command below you’ll need to replace the following with your own values:

• /path-to-your-keystore    (point to your own keystore)

• your-keystore-password    (keystore password)

• app.apk    (app to sign)

• store-alias    (keystore alias)

jarsigner -verbose -sigalg MD5withRSA -digestalg SHA1 -keystore /path-to-your-keystore -storepass your-keystore-password app.apk store-alias zipalign -v 4 app.apk signed-app.apk

Have you checked out this Enterprise tutorial?

http://coronalabs.com/blog/2014/04/01/tutorial-corona-enterprise-quickstart-android/

It can guide you through the necessary steps.

(Although it doesn’t use Eclipse)

Seriously you taught me more than this tutorial above… I have already studied that tutorial and all build failed… Finally my signed up app is working on my device by following your steps. If you dont mind can you guide me through ios process too?

For iOS it should just be a matter of opening the .xcodeproj file, selecting your device from the dropdown list(*) at the top left (after you’ve connected it to your Mac) and running the project. You can also select a simulator to run the project on.

(*) Your device must be enabled for development. To do this, you can open up the Organizer (Window->Organizer). In the devices tab you should see your connected devices with a green dot when they’re available. A grey dot will appear if it’s available but not assigned for development. To assign it for development, select the device and click the “Use for development” button and follow the instructions.

You might have already seen this also, but I’ll include it here for completeness’ sake  :wink:

http://coronalabs.com/blog/2014/03/18/tutorial-corona-enterprise-quickstart-ios/

One more thing :slight_smile:   

If you’re going to be developing with Corona Enterprise I’d say that the following book is a must-have item.

Especially Section IV (The C API) should be understood before embarking on any bigger projects.

http://www.lua.org/pil/

Thanks, I will have a look at it and keep you posted. Thanks for all your help till now.

No problem. Glad to be of help  :slight_smile:

So ios app built successfully too… I have started another thread for another problem… can you please look into it too here… http://forums.coronalabs.com/topic/47921-how-to-pass-variables-from-native-android-and-ios-to-corona/

I only compile from the command line using build.sh.

I always modify the original build.sh and add a variable ANDROID_BUILD_TARGET=android-16 at the top of the script.

Then I append --target $ANDROID_BUILD_TARGET to *all* lines where update project is called.

If I do this on the sample project you mentioned (SimpleLuaExtension) and then run ./build.sh the app compiles successfully, and produces an APK in the bin folder. I sign the app and then install. The app runs and prints the output as expected without error.

NOTE: You’ll need to have the Android SDK (API level 16) installed when you do this.