Libathos
Libathos

Reputation: 3362

Extend Application class when developing aar

I have been working on an Android Application, where I extended the Application class as a singleton and used it in various activities inside the app.

Now, I need to make this application into an aar in order to be integrated in another greater application. However, when I try to import the aar of my app (now lib) to the greater application, I get an error because of the class that extends application. Is there a workaround or the only way to continue is to delete the class that extended Application?

Error: Attribute application@name value=(xx.yy.zz.util.ApplicationContextProvider) from [GreaterApp:xx:unspecified] AndroidManifest.xml:13:9-73 is also present at [GreaterApp:myapp:unspecified] AndroidManifest.xml:14:9-84 value=(xx.yy.zz.IdentityManagement). Suggestion: add 'tools:replace="android:name"' to element at AndroidManifest.xml:10:5-49:19 to override.

Upvotes: 0

Views: 469

Answers (1)

RobCo
RobCo

Reputation: 6495

The Application class in the greater app should extend your Application subclass instead of Application directly.
Then they should both work the same as before.

If the greater application does not have a Application class, you can just register your subclass in the manifest, or create a dummy class extending yours.

Upvotes: 1

Related Questions