androidandroid-gradle-pluginsugarorm

Cannot add tools:replace="name" to application tag (Sugar Orm application error)


I've imported a new lib to my proejct. Unfortunetely it is making an error with SugarOrm's lib.

When I try to run my proejct I have the following gradle error:

9-42 Error:
Attribute application@name value=(com.orm.SugarApp) from AndroidManifest.xml:47:9-42
is also present at AndroidManifest.xml:47:9-42 value=(com.myproject.application.app.MyApplication).
Suggestion: add 'tools:replace="android:name"' to <application> element at AndroidManifest.xml:43:5-263:19 to override.

I try to add the replace line to my manifest's application tag:

<application
    android:name=".app.MyApplication"
    android:allowBackup="true"
    tools:replace="android:name"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme">

However, I got the very same error.

My application class looks like this:

public class MyApplication extends SugarApp{


@Override
protected void attachBaseContext(Context base) {
    super.attachBaseContext(base);
    MultiDex.install(this);
}


}

I've tried the following:

Invalidage caches, restart, rebuild, clean, reordering gradle lib import

Please help if you can.

E D I T:

Clarification: I would like to use multidex on Android 4.4 (API 19) with Sugar ORM. Later versions have multidex by default but on 4.4 I have to import it in gradle, and have to make install it inside Application code.

So basically I have to set my manifest's application to my application class which also handles Sugar ORM's stuff, and the multidex instalaltion.

And this causes the error.

Versions:


Solution

  • I had to delete the generated manifest file located at:

    C:\my_projects_dir\app\src\debug
    

    And now everything is fine. Maybe it was an Android Studio bug with re-generation.