Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-16678

Android: File.read() of JS files under Resources directory returns empty string for device/production builds

    Details

    • Story Points:
      3
    • Sprint:
      2018 Sprint 15 SDK, 2018 Sprint 16 SDK, 2016 Sprint 17 SDK, 2018 Sprint 18 SDK, 2018 Sprint 19 SDK

      Description

      Summary:
      File.read() is unable to read encrypted assets such as .js files. This only happens when doing a device build or production build. It can only read .js files from the "Resources" directory when building for the Android Emulator (aka: "development" build) since .js files are not encrypted in this case.

      iOS is able to successfully read encrypted assets such as .js.

      Steps to Reproduce:

      1. Create a Titanium app with the below code for it's "app.js".
      2. Build and run on the Android emulator.
      3. Notice that the alert dialog displays the "app.js" code. (This is good.)
      4. Build and run on a physical Android device.
      5. Notice that the alert dialog on startup is empty. (This is bad. Failed to read "app.js".)

      var file = Ti.Filesystem.getFile("app.js");
      alert(file.read().text);
      

      Expected Result:
      Android should be able to read encrypted .js files just like iOS.


      Original description from Alejandro:
      You have a .js file at Resources/lib named library.js with content:

      var a = "hello world";
      

      if you try read the file like a text plain file

      var value = Ti.Filesystem.getFile(Ti.Filesystem.getResourcesDirectory(), "lib/library.js").read().toString();
      

      value should be var a = \"hello world\";, but value is empty -> "".
      if you change library.js to library.lib or other extension is fine.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                jquick Joshua Quick
                Reporter:
                afcarrera Alejandro F. Carrera
                Reviewer:
                Gary Mathews
                Tester:
                Lokesh Choudhary
              • Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Backbone Issue Sync

                  • Titanium SDK/CLI <> Titanium Mobile
                    Synced with:
                    TIMOB-18509
                    Sync status:
                    ERROR
                    Last received:
                    Last sent:

                    Git Source Code