[TIMOB-27718] Android: Log build warnings if "res" files have invalid names
GitHub Issue | n/a |
Type | Improvement |
Priority | Medium |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2020-01-30T21:14:40.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 9.0.0 |
Components | Android |
Labels | android, build, resources |
Reporter | Joshua Quick |
Assignee | Joshua Quick |
Created | 2020-01-16T01:31:23.000+0000 |
Updated | 2020-01-30T21:14:40.000+0000 |
Description
*Preface:*
An Android APK's "res" files (such as drawables) have the following restictions:
* File names can only have lower-case letters, numbers, or underscores.
* File names cannot start with a number.
* Cannot be placed in subdirectories.
The above limitations are by Google's design, because the Android build system turns "res" file names into Java constants under the generated R
class. Violating the above will result in a build failure.
However, Titanium allows app developers to violate the above rules and will lower-case the file name and replace illegal characters and directory separators with '_'
underscores.
*App Changes for Titanium 9.0.0:*
For app builds, we want to maintain backward compatibility. This means allowing app developer to continue to violate Google's "res" file naming rules, but we should log a build +WARNING+ for every "res" file in violation to compel app developer's to follow Google's best-practices. This will also help minimize confusion when attempting to access a "res" file via native Java APIs using the illegal name, which won't work.
*Module Changes for Titanium 9.0.0:*
Native modules built with Titanium 9.0.0 and higher will no longer be allowed to violate Google's "res" file naming rules. This is because we're now building a native module to an AAR library which packages the module's "res" files. So, illegal "res" file names will cause a build failure just like how it works in Android Studio.
*Test:*
The attached [^Resources.zip] contains a directory tree of image files which violate Google's "res" naming conventions.
Attachments
PR (master): https://github.com/appcelerator/titanium_mobile/pull/11438
FR passed, Waiting on Jenkins build.
merged to master for 9.0.0
Verified the fix with SDK 9.0.0.v20200130075800. Closing.