I currently have shared Java libraries added to my Android build, following the same structure as defined here:
- https://cs.android.com/android/platform/superproject/main/+/main:device/sample/frameworks/PlatformLibrary/README.txt
- https://source.android.com/docs/setup/build/java-library
These work and can be accessed by apps using uses-library in their Manifest. What I now want to do is add resources (strings, drawables etc) also to the system so that they can be referenced by these libraries.
These are Java libraries though so they cannot include resources, the README for the PlatformLibrary says:
if you need any resources for the library, such as drawables or layout files, you will need to add these to the core framework resources under frameworks/base/res.
So I have added a new file: frameworks/base/core/res/res/values/my_strings.xml. Building frameworks/base/res generates a new framework-res.apk file which includes my new Strings, which I can see in the resources.arsc when viewing the APK in Android Studio..
But I cannot seem to access these strings in my library code:
src/com.example.lib/MyClass.java:9: error: cannot find symbol
public static int MY_INT = android.R.myString;
^
symbol: variable myString
location: class R
1 error
17:53:18 ninja failed with: exit status 1
How can I add resources to the system and be able to access them?