Multiple application android:name tags in manifest

2019-02-18 07:44发布

问题:

I am using two libraries(SUGAR ORM and Instabug). They both require me to use the android:name tag of the application in my manifest. However, it seems you cannot have duplicates.Is there a way around this?

My manifest:

 <application
        android:allowBackup="true"
        android:label="@string/app_name"
        android:icon="@drawable/runrouter_biggest"
        android:theme="@style/MyTheme"
        tools:replace="android:icon"
        android:name="com.orm.SugarApp"
        //I need to declare a second android:name here>

Thanks, Matt

回答1:

You seem to be out of luck. You can have only one instance of application class so you can specify only one android:name there.

However, you are actually not out of luck. Instabug does not require you to use their application class, all they need is to call Instanbug.initialize(...)... which you can easily do in your application class derived from SugarApp:

class MyApplication extends SugarApp
{
    @Override
    void onCreate()
    {
        super.onCreate();
        Instabug.initialize(this)
            .setAnnotationActivityClass(InstabugAnnotationActivity.class)
            .setShowIntroDialog(true)
            .setEnableOverflowMenuItem(true);
    }
}

And define this application class in android:name.