I am making a library. And I am using Hilt. The sample app is done and I am just trying to separate it as module to make it library later.
However, Hilt needs to create Application and set like this:
@HiltAndroidApp
class MyApplication : Application() {
override fun onCreate() {
super.onCreate()
}
}
with HiltAndroidApp.
And my client company just wants to open some activities that I will offer from the library. And if the client company starts using 'hilt' then, the project will need to fix many parts that we don't want to face.
The clients might have or might not have Application file. So, I need to consider both cases.
For example, the client might have
- nothing
- using hilt
- using dagger or other DI.
in their Application file.
Is there any solution that I can still use hilt for library and the clients change nothing?
When I tested, it casues:
Manifest merger failed : Attribute application@name value=(com.example.client.MyApplication) from AndroidManifest.xml:12:9-63
is also present at [:my_sdk] AndroidManifest.xml:18:18-73 value=(com.example.sdk.MyApplication).
Suggestion: add 'tools:replace="android:name"' to <application> element at AndroidManifest.xml:11:5-44:19 to override.
com.example.client.MyApplication is the sample app.
`com.example.sdk.MyApplication' is module.
when I tried with tools:replace="android:name It just literally replaced and didn't solve.