I’m making couple of Android library apps for a project. To simplify the question, let’s say I have two libraries(utilLib, screenLib) in this project(now will be referred to as app).
There’s String resource with the same name inside each project but with different values. Like this:
utilLib
<string name="app_version">1.0</string>
<string name="hello">UtilLib Hello</string>
screenLib
<string name="app_version">0.7a</string>
<string name="hello">ScreenLib Hello</string>
app
<string name="app_version">0.1</string>
I realized that I can refer to the string using com.package.R but what if my code looks like this what will show up?
<!-- language: java -->
import com.app.R;
...
private void checkValue(){
String version = getString(R.app_version);
Log.d(TAG, "version: " + version); // 0.1 show be here
String hello = getString(R.hello);
Log.d(TAG, "Hello: " + hello); // <---- ? ('UtilLib Hello' or 'ScreenLib Hello')
}
I am trying to make modular build here but don’t fully understand how Android prioritize its R.java to use. Has anyone had experienced with this?
Reason quoting from official dev guide Managing Projects – Library Projects:
This is determined by library project priority.
Quoting from official dev guide Managing Project -Library Projects:
Quoting from official dev guide From Eclipse with ADT – Referencing a library project:
Quoting from official dev guide From the Command Line – Referencing a Library Project:
I can’t find any word that can explain this more clear than official dev guide.