Mesosfer and Cubeacon Initialization in Application onCreate()

Home - Mesosfer and Cubeacon Initialization in Application onCreate()

Andrew Chandra asked 3 years ago

I have a question about the initialization in application onCreate().
I know we initalize it in Application class to make it initialized globally, but I have an issue…I need to use MultiDexApplication and onCreate() is not called when app launch, so Mesosfer and Cubeacon is not initialized.
This is what I have done :

  1. In build gradle add “multiDexEnabled true” and dependencies compile ‘′”
  2. in manifest, in application tag I add android:name=””
  3. in my custom MultiDexApplcation class, I use extends MultiDexApplication ie. public class MyApplication extends MultiDexApplication { … }

I also tried to add Multidex.install(this) in attachBaseContext method, but it doesn’t work. I know this is not a Mesosfer specific issue, but if you can help me please answer it.

2 Answers
Alann Maulana Staff answered 3 years ago

Hi Andrew,
By using custom application class on your Android project, make sure that you define it in AndroidManifest.xml within application tag. Taking from Mesosfer-Cubeacon project for Android, here is the code : (refers to this link)

public class MesosferApp extends Application {
    public void onCreate() {

        // initialize Mesosfer SDK
        Mesosfer.initialize(this, "YOUR-APP-ID-HERE", "YOUR-CLIENT-KEY-HERE");

        // initialize Cubeacon SDK

AndroidManifest.xml (refers to this link)


FYI, Application#onCreate() called when the application is starting, before any activity, service, or receiver objects (excluding content providers) have been created. Implementations should be as quick as possible (for example using lazy initialization of state) since the time spent in this function directly impacts the performance of starting the first activity, service, or receiver in a process. If you override this method, be sure to call super.onCreate()
You can refers to Android Developer page.

Andrew Chandra answered 3 years ago

Thank you for the reply…Actually I found the issue, I should use my custom Application name in the application name’s Manifest instead of “”
So this issue is resolved

Your Answer