[Android] How to edit/override MainActivity.java

To implement some verification code for a business partner, I need to make changes to MainActivity.java, specifically adding to or overriding the onCreate and onDestroy methods. How would I do this cleanly with openFL?


  1. Create a “templates” folder (or similar)
  2. Add <template path="to/your/templates/folder" /> to your project.xml (with the absolute or relative path to your new folder)
  3. Mirror the Lime template directory structure up to and including the file/directory you would like to override
  4. (In this case) You should duplicate the following file into your own “templates/android/MainActivity.java” file:

Thanks for the help. I couldn’t get anything to work with just <template path="templates"/>

but was able to do what I needed with the rename attribute:

<template path="templates/android/MainActivity.java" rename="app/src/main/java/com/okshur/enchantedCave2/MainActivity.java"/>

1 Like