I have an Android app that uses a library and both have string resources with identical names (but with different values). Apps will override and use the app’s version and ignore the library’s version if names are identical as far as I know.
From the app:
<string name="hello">Hello from App</string>
From the library:
<string name="hello">Hello from Library</string>
I have code in the library that calls context.getString(R.string.hello)
and when the App is run I want it to take the value from the library (Hello from Library
) instead of the App’s version of the value. However, I only get the app’s version.
How do I ensure the library uses ONLY the library’s version?
I have tried using the same namespace
in build gradle (under the android section) and package in the library’s manifest
android {
namespace = "com.library.ui"
}
and
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.library.ui">
</manifest>
Is there a way I can achieve this without having to manually adding a prefix to all string resources in the library?