App will not build successfully when including a file with a name longer than 100 characters in Resources. This works fine on iOS, tested with the same SDK versions.
Use Case:
You may ask yourself why would anyone want to include a file with more than 100 characters.
Using base64 to encode remote file path for caching image locally and shipping the cached images with the app. This works fine when you create the files on the device but when you try to grab the cached images and include them in the build, the build fails.
Workaround:
Use a file name that is 100 characters or less.
Steps to reproduce:
Step 1: create an app
Step 2: move a file into the Resources directory of the app
Step 3: rename that file to "aHR0cDovL21tYXBwY21zLmNvbS9kZW1vL3NpdGVzL2RlZmF1bHQvZmlsZXMvc3R5bGVzL2dhasbGxlcnlfZnVsbC9wdWJsaWMvaG9" or just download the attached file. (the name is 101 chars long).
Step 4: run the run the application
Step 5: see the error in the console log below
Step 6: rename the file and remove one char.
Step 7: do a clean build
Step 8: notice that there is no error
Console log
[INFO] Titanium SDK version: 1.8.0.1 (11/30/11 10:44 c058ed0...)
[INFO] Fastdev server running, deploying in Fastdev mode
[INFO] Copying project resources..
[INFO] Detected tiapp.xml change (or assets deleted), forcing full re-build...
[INFO] Force including all modules...
[INFO] Force including all modules...
[INFO] Compiling Javascript Resources ...
[INFO] Copying platform-specific files ...
[INFO] Compiling localization files
[INFO] Waiting for SDCard to become available..
[INFO] Compiling Android Resources... This could take some time
[ERROR] /Users/jalter/Documents/Titanium Studio Workspace2/Test7/build/android/bin/assets/Resources/aHR0cDovL21tYXBwY21zLmNvbS9kZW1vL3NpdGVzL2RlZmF1bHQvZmlsZXMvc3R5bGVzL2dhasbGxlcnlfZnVsbC9wdWJsaWMvaG9: error: Invalid filename. Unable to add.
[ERROR] Exception occured while building Android project:
[ERROR] Traceback (most recent call last):
[ERROR] File "/Users/jalter/Library/Application Support/Titanium/mobilesdk/osx/1.8.0.1.v20111130104443/android/builder.py", line 2027, in <module>
[ERROR] s.build_and_run(False, avd_id, debugger_host=debugger_host)
[ERROR] File "/Users/jalter/Library/Application Support/Titanium/mobilesdk/osx/1.8.0.1.v20111130104443/android/builder.py", line 1896, in build_and_run
[ERROR] launched, launch_failed = self.package_and_deploy()
[ERROR] File "/Users/jalter/Library/Application Support/Titanium/mobilesdk/osx/1.8.0.1.v20111130104443/android/builder.py", line 1438, in package_and_deploy
[ERROR] unsigned_apk = self.create_unsigned_apk(ap_)
[ERROR] File "/Users/jalter/Library/Application Support/Titanium/mobilesdk/osx/1.8.0.1.v20111130104443/android/builder.py", line 1336, in create_unsigned_apk
[ERROR] resources_zip = zipfile.ZipFile(resources_zip_file)
[ERROR] File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/zipfile.py", line 699, in __init__
[ERROR] self.fp = open(file, modeDict[mode])
[ERROR] IOError: [Errno 2] No such file or directory: '/Users/jalter/Documents/Titanium Studio Workspace2/Test7/build/android/bin/app.ap_'
issue reproduces Tested with Titanium Studio, build: 3.0.1.201212181159 Titanium SDK version: 3.1.0 Android Emulator: Android SDK version: 2.2
Confirmed with Titanium SDK 6.1.0 (master):
We have 4 options: 1. We stop the build as soon as we detect a file name that is too long. 2. We wait for the new Titanium build and we either force encryption of files with long filenames. 3. We wait for the new Titanium build and we allow the encryption storage system to support unencrypted files. 4. We do nothing and let the Android tools break the build. Option 1 is better than option 4, but we still won't be able to support long filenames. Option 2 and 3 won't happen anytime soon and depends on Ti.Filesystem also supporting the encryption storage engine, which I believe it will have to anyways.