Android Studio Integration

Setup/Preparation

Notes
  • This guide assumes that you have already set up a development environment for Corona Enterprise. If not, please see the Corona Enterprise — Android Setup and return to this guide once you've finished installing the Android Tools.

  • Before starting, download and install Android Studio. Run Android Studio for the first time and set it up (select a theme, update the Android SDK as desired, etc.).

  1. If you haven't already, copy the CoronaEnterprise/ProjectTemplates/App/ project directory to the desired location on your machine.

  2. Open the [PATH_TO_PROJECT_TEMPLATE]/App/ project directory in Finder and rename the android directory to android_old. This is so the old Ant version stays out of the way.

  3. From with Android Studio, select Start a new Android Studio project.

  4. Specify an Application name that describes your project. If you already have an Android package name (and a keystore), make sure to specify the correct values. Also make sure that Project location is exactly [PATH_TO_PROJECT_TEMPLATE]/App/android/ this is so you just replace the Android structure of the Corona Enterprise project without breaking other portions.

  1. When finished, click Next.

  2. On the next screen, in the Phone and Tablet section, choose a Minimum SDK version of API 15: Android 4.0.3 (IceCreamSandwich). Specifying an SDK version lower than 15 is unsupported.

  1. When ready, click Next.

  2. On the next screen, select Add No Activity and then click Finish. Android Studio will then create your project.

  1. Now that the new android directory is created, open the Terminal application and cd to the [PATH_TO_PROJECT_TEMPLATE]/App/android/ directory. Then, make a symbolic link to CoronaEnterprise directory:
cd [PATH_TO_PROJECT_TEMPLATE]/App/android/
ln -s /Applications/CoronaEnterprise CoronaEnterprise
  1. Verify that your symbolic link works by cd-ing into it. You should see the Corona folder icon in the title bar of the Terminal application.

Project Configuration

  1. Return to Android Studio and open the Project sidebar on the left. Expand the app and Gradle Scripts modules:
  1. Delete everything in the appjava modules.
  1. You'll need to add a sub-project for the plugin. Select FileNewNew Module and choose Android Library, then click Next to continue.
  1. On the next screen, Application/Library name and Module name must be exactly plugin. Package name should be in format of how a user would add the plugin to their build.settings, for example plugin.flashlight. For this project, enter simply plugin.library and click Finish. You can ignore the warning about the casing of the application name.
  1. In the Project sidebar, locate the pluginjava module and delete plugin.library (androidTest) and plugin.library (test) module.
  1. Now you need to create a LuaLoader.java file for the plugin. From within Finder, copy the file from [PATH_TO_PROJECT_TEMPLATE]/App/android_old/src/plugin/library and paste it into this directory:

    [PATH_TO_PROJECT_TEMPLATE]/App/android/plugin/src/main/java/plugin/library

  1. While still in Finder, delete the androidTest and test directories from both app/src/ and plugin/src/ since you don't need them.