Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-6495] Android: Can't include file names longer than 100 characters in Resources

GitHub Issuen/a
TypeBug
PriorityLow
StatusOpen
ResolutionUnresolved
Affected Version/sRelease 1.7.5, Release 3.1.0
Fix Version/sn/a
ComponentsAndroid
LabelsRTN, cb-tooling, core
ReporterJon Alter
AssigneeEric Merriman
Created2011-12-06T19:21:26.000+0000
Updated2020-01-09T19:49:52.000+0000

Description

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_'

Attachments

FileDateSize
aHR0cDovL21tYXBwY21zLmNvbS9kZW1vL3NpdGVzL2RlZmF1bHQvZmlsZXMvc3R5bGVzL2dhasbGxlcnlfZnVsbC9wdWJsaWMvaG92011-12-06T19:21:26.000+000058627

Comments

  1. jithinpv 2013-04-26

    issue reproduces Tested with Titanium Studio, build: 3.0.1.201212181159 Titanium SDK version: 3.1.0 Android Emulator: Android SDK version: 2.2
  2. Chris Barber 2016-08-22

    Confirmed with Titanium SDK 6.1.0 (master):
       [INFO]  Packaging application: /opt/android-sdk/build-tools/24.0.0-preview/aapt "package" "-f" "-m" "-J" "/Users/chris/appc/workspace/testapp/build/android/gen" "-M" "/Users/chris/appc/workspace/testapp/build/android/AndroidManifest.xml" "-A" "/Users/chris/appc/workspace/testapp/build/android/bin/assets" "-S" "/Users/chris/appc/workspace/testapp/build/android/res" "-I" "/opt/android-sdk/platforms/android-23/android.jar" "-F" "/Users/chris/appc/workspace/testapp/build/android/bin/app.ap_" "--auto-add-overlay" "--extra-packages" "ti.modules.titanium.ui:android.support.v7.appcompat:android.support.v7.cardview" "-S" "/var/folders/wx/j1v32g355xj28rnt9yb_6hfm0000gn/T/116722-44830-1fygspp/res" "-S" "/var/folders/wx/j1v32g355xj28rnt9yb_6hfm0000gn/T/116722-44830-175ary1/res" "-S" "/var/folders/wx/j1v32g355xj28rnt9yb_6hfm0000gn/T/116722-44830-ksms2m/res"
       [ERROR] Failed to package application:
       [ERROR]   
       [ERROR] /Users/chris/appc/workspace/testapp/build/android/bin/assets/Resources/aHR0cDovL21tYXBwY21zLmNvbS9kZW1vL3NpdGVzL2RlZmF1bHQvZmlsZXMvc3R5bGVzL2dhasbGxlcnlfZnVsbC9wdWJsaWMvaG9.txt: error: Invalid filename.  Unable to add.
       
    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.

JSON Source