3

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.

Community
  • 1
  • 1
f3d0r
  • 541
  • 3
  • 12
  • 27

1 Answers1

3

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

public class MyApplication extends MultiDexApplication {
    @Override
    public void onCreate() {
    super.onCreate();

    Configuration config = new Configuration.Builder(this)
    .setDatabaseName("mydb.db")
    .setDatabaseVersion(1)
    .create();
    ActiveAndroid.initialize(config);
    }
}

In your manifest,

<application android:name=".MyApplication">
Adam Kimi
  • 46
  • 4