Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-27718] Android: Log build warnings if "res" files have invalid names

GitHub Issuen/a
TypeImprovement
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2020-01-30T21:14:40.000+0000
Affected Version/sn/a
Fix Version/sRelease 9.0.0
ComponentsAndroid
Labelsandroid, build, resources
ReporterJoshua Quick
AssigneeJoshua Quick
Created2020-01-16T01:31:23.000+0000
Updated2020-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

FileDateSize
Resources.zip2020-01-17T03:08:36.000+000018370

Comments

  1. Joshua Quick 2020-01-17

    PR (master): https://github.com/appcelerator/titanium_mobile/pull/11438
  2. Samir Mohammed 2020-01-21

    FR passed, Waiting on Jenkins build.
  3. Christopher Williams 2020-01-23

    merged to master for 9.0.0
  4. Lokesh Choudhary 2020-01-30

    Verified the fix with SDK 9.0.0.v20200130075800. Closing.

JSON Source