Closed Leif-W closed 2 years ago
Thanks for pointing this out! R.java is what the app's code uses to access a resource, which means it should only contain the base version of that resource. The specific version/configuration is decided by Android at run time.
This has now been fixed: https://github.com/jbendtsen/tiny-android-template/commit/7d26cfdb0844666ce647a85270f4cab05caf830a
res/values*:
relevant R.txt:
relevant R.java:
relevant link.pl output:
How do we handle support for more than one version of Android? This built as-is with a "minimalist" (bloated) gradle on the device itself using Termux as proof of concept. Now I want absolute minimalism, but correctness.
Thanks for this project. Interesting idea.
Possibly relevant docs:
https://developer.android.com/guide/topics/resources/providing-resources#AlternativeResources
At the end of table 2, the API version qualifiers, i.e. folders of the format
res/defaultname-qualifier
used to specify default and alternate resources to be chosen at runtime to support multiple devices (layouts and API levels).In my case, the default style (values) is API v11, and a more modern style requires API v21 so values-v21 overrides the default.
The docs don't make clear exactly what the actual resultant code in R.java ought look like for alternate resource qualifiers, e.g. style and style_v21, and item and item_v21, for example.
Example docs of my correct usage of (regexp)
/values(|-v\d+)/
folder for alternate resources.https://developer.android.com/develop/ui/views/theming/themes#Versions
This tutorial indicates something interesting:
http://www.java2s.com/Tutorials/Android/Android_Tutorial/0080__Android_Resources_Configuration.htm
R.java should have one identifier for the base name, not for each alternate resource qualifier.
Does it mean that gen_proj_rtxt should only generate identifiers for resource base names, not additional qualifiers?
If yes, then this line maybe the problem?
if ($dir =~ /values/) {
The regexp probably ought to be explicitly bounded by start and end.
/^values$/
A more generalized solution needs to be devised for all base resource names and qualifiers. Assuming base names never have a hyphen (-), this is easier, perhaps
/^[^-]+$/
or something?Either fix the glob
foreach my $dir (<res/*>) {
(tricky glob syntax? I forget...) or (more simply but less elegant) filter hyphenated folders at the beginning of the loop or something?I'm not sure, but I guess the Android system does magic, so as long as alternate resource folders are in the .apk, they'll be found and used? I may be wrong. It feels wrong. Like, they should be explicitly referenced somewhere? I have no idea...