fedorp1 fedorp1 - 1 year ago 118
Java Question

Using ActiveAndroid and MultiDexApplication

I'm having trouble initializing ActiveAndroid in my project. It is state that the application tag in the manifest needs to be like so:

<application android:name="com.activeandroid.app.Application" ...>

Unfortunately, I have it already as this

<application android:name="android.support.multidex.MultiDexApplication">

It says you can fix the problem by having the class that is in the application tag be a sub-class of ActiveAndroid.

Notice also that the application name points to the ActiveAndroid application class. This step is required for ActiveAndroid to work. If you already point to a custom Application class, just make that class a subclass of com.activeandroid.app.Application.

If you are using a custom Application class, just extend com.activeandroid.app.Application instead of android.app.Application

public class MyApplication extends com.activeandroid.app.Application { ...

Is there a way for me to remedy this problem? I can't change the code to the MultiDexApplication class because it is part of the Android SDK.

Answer Source

MultiDexApplication is Application subclass (MultiDexApplication), so extends and configure ActiveAndroid.

public class MyApplication extends MultiDexApplication {
    public void onCreate() {

    Configuration config = new Configuration.Builder(this)

In your manifest,

<application android:name=".MyApplication">
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download