Android - Activity and Application


I’m trying to integrate ACRA lib into an Extension but I’ve found a big issuer for my poor Android knowledge.
ACRA need to integrate some code into an extended Application class. Looking at template used by lime to generate android apks, i’ve found no trace about a “MainApplication” or so on.

Is there a way to try to add or use an extended Application class to lime or to reach “MainApplication” from main Activity?

Thanks, David.


Oh, just read that you want to make an Extension.

Probably there is no way to add custom application class from extension (moreover I believe that it is bad idea to modify application class from extension).

Previous answer:

OpenFL / Lime didn’t use custom application class. You should create it by yourself.

  1. Override android template, to do it put
<template path="templates" />

inside project.xml

  1. inside templates folder create following folders: android/template/app/src/main/java/org/haxe/lime

  2. copy AndroidManifest.xml from Lime ( to templates/android/template/app/src/main

  3. create inside templates/android/template/app/src/main/java/org/haxe/lime/

  4. Project structure should be like that:

|- ...
|- templates/
|  |- android/
|     |- template/
|        |- app/
|           |- src/
|              |- main/
|                 |- java/
|                 |  |- org/
|                 |  |  |- haxe/
|                 |  |  |  |- lime/
|                 |  |  |  |  |-
|                 |- AndroidManifest.xml
|- project.xml
  1. in AndroidManifest.xml find <application ...> tag, and add android:name=".MainApplication" somewhere:
<application android:name=".MainApplication" ...>
  1. open, and put following inside:
package org.haxe.lime;

import android.content.Context;
import org.acra.*;
import org.acra.annotation.*;

@ReportsCrashes(formUri = "")
public class MainApplication extends Application {
    protected void attachBaseContext(Context base) {

P. S. I didn’t test it, but I believe that it should work.

Extension for Deep Links on Android (Solved with example)

Really thanks about your kindly and complete response. I’m going to try to integrate it into my projects.


I updated answer, TL;DR - probably it is impossible if you want to make an extension.

But if you just want to integrate ACRA into application, my answer should help :slight_smile:


It’s a chance. I’m not sure ACRA can really help with NDK applications buy I’m going to try in next days. But your response can be really useful to expand openfl/lime limits with Android.

Thanks again, David.


I recently implemented ACRA myself, and I used pretty much the same implementation Restorer suggested. Sadly, ACRA doesn’t seem to report C++ crashes, so I’m not expecting to get a whole lot out of it.


Thanks a lot @player_03 I’m going to waste my time to try to produce a crashlytics working on Android side. Main issue in this task is the absolute strange and non-comprensible documentation and a strange way to share knowledge, almost for an old programmer :smiley: