Hello everyone,
I read that several developers has encountered problems compiling and deploying Corona Enterprise Apps from Eclipse.
I found the solution to this issue. It’s simple but it works perfectly. With this solution, you’ll can do this:
* Compile Corona Enterprise from Eclipse
* Edit the Corona Files from Eclipse
* Deploy Corona Enterprise project, from Eclipse (yes, from Eclipse, without any intermediate step) to a real device.
The steps are:
1. If you try to import the App template from Corona Enterprise folder, you’ll see you can’t. The reason is a missing file. You have to create a .project file in the Android template structure with the project nature or isn’t possible to import as an Android Application.
Create a .project file in the same directory where you can find AndroidManifest.xml file. With this content:
<?xml version=“1.0” encoding=“UTF-8”?>
<projectDescription>
_ <name>App</name> _
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.ApkBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
2. Now you can import the Android project in Eclipse. But some libraries are missing so, copy this files from CoronaEnterprise/Corona/android/lib/Corona:
- android-async-http.jar
- Corona.jar
- JNLua.jar
- network.jar
- armeabi-v7a folder (all libraries)
3. Now, you have an Android Project from a Corona Enterprise template, ready for use. Next step can be done by two ways:
- Install the LUA plugin for Eclipse (aka Koneki project)
- Create an empty project (without any nature configuration)
4. Create a project (as LUA project or empty project) named Corona (this is an important step. If you don’t do this, you have to modify several scripts, but could be necessary to maintain more than 1 project at the same time in Eclipse).
5. Copy all content of your Corona project (all lua files, configurations and assets) to this Eclipse Project.
6. Now you have 2 opened projects: Corona project and Android Project.
Let’s go modify some information to compile it
Create a folder named “keystore” in the project and put it in the keystore file to sign your app. (you can use the debug key if you want).
7. Delete build.sh file and create a new build.sh file, with this content (and change the bold content with your own data)
#!/bin/bash
rm -Rf bin/App-release-signed.apk
_ PATH_TO_ANDROID_SDK /platform-tools/adb uninstall package_of_your_app _
checkError() {
if [$? -ne 0]
then
echo “Exiting due to errors (above)”
exit -1
fi
}
SDK_PATH= PATH_TO_ANDROID_SDK /
_CORONA_PATH= PATH_TO_CORONA_ENTERPRISE_SDK/ _
RELATIVE_PATH_TOOL=$CORONA_PATH/Corona/mac/bin/relativePath.sh
CORONA_PATH="$RELATIVE_PATH_TOOL" "$path" "$CORONA_PATH"
“$SDK_PATH/tools/android” update project -p .
checkError
“$SDK_PATH/tools/android” update lib-project -p “$CORONA_PATH/Corona/android/lib/Corona”
checkError
# Uncomment if using facebook
# “$SDK_PATH/tools/android” update lib-project -p “$CORONA_PATH/Corona/android/lib/facebook/facebook”
# checkError
echo “Using Corona Enterprise Dir: $CORONA_PATH”
ant release -D"CoronaEnterpriseDir"="$CORONA_PATH"
_jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore keystore/filename.keystore -keypass password -storepass password bin/App-release-unsigned.apk keystorealias _
_ PATH_TO_ANDROID_SDK /tools/zipalign -v 4 bin/App-release-unsigned.apk bin/App-release-signed.apk_
_ PATH_TO_ANDROID_SDK /platform-tools/adb install bin/App-release-signed.apk_
_ PATH_TO_ANDROID_SDK /platform-tools/adb shell am start -a android.intent.action.MAIN -n package_of_your_app /com.ansca.corona.CoronaActivity_
8. Now, executing the build.sh script, the application will be compiled, linked, signed, aligned and deployed to a real device (if you have a real device connect as debug of course).
9. If you need to launch the script via Play button on Eclipse, just do this:
Go to External Tools Configuration and add the script in this window (change Animal Zombies 2 to your own project name):
Click on Apply and it’s done!
You can execute this Android Project from Eclipse with any command line
I hope you can find this useful.
Dani