Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-16788] Android: WebView cannot find assets in ApplicationData directory

GitHub Issuen/a
TypeBug
PriorityLow
StatusOpen
ResolutionUnresolved
Affected Version/sRelease 3.2.2
Fix Version/sn/a
ComponentsAndroid
Labelsandroid, parity, webview
ReporterFokke Zandbergen
AssigneeUnknown
Created2014-03-27T10:53:31.000+0000
Updated2018-02-28T20:03:57.000+0000

Description

Attachments

FileDateSize
device-2014-03-27-115312.png2014-03-27T10:53:32.000+000048156
iOS-simulatorschermafbeelding 27 mrt. 2014 11.52.46.png2014-03-27T10:53:32.000+000068433
wvr.zip2014-03-27T10:53:32.000+0000260368

Comments

  1. Fokke Zandbergen 2014-03-27

    A terrible, but functioning workaround is to copy the web-app to the resource directory *after* Alloy and the Titanium CLI are done with compiling, but before packaging:
       exports.cliVersion = '>=3.2';
       
       var path = require("path"),
         wrench = require('wrench');
       
       exports.init = function(logger, config, cli, appc) {
       
         if (cli.argv.platform !== 'android') {
       
           cli.addHook('build.post.compile', function(build, finished) {
       
             logger.log("======= COPYING 'WWWW' =======");
       
             var source = path.join(build.projectDir, "www");
             var destination = path.join(build.xcodeAppDir, "www");
       
             wrench.copyDirSyncRecursive(source, destination, {
               forceDelete: true,
               preserveFiles: false
             });
       
             finished();
           });
       
         } else {
       
           cli.addHook('build.android.writeAndroidManifest', function(opts, finished) {
       
             logger.log("======= COPYING 'WWWW' =======");
       
             var source = path.join(opts.ctx.projectDir, "www");
             var destination = path.join(opts.ctx.buildDir, "bin", "assets", "Resources", "www");
       
             wrench.copyDirSyncRecursive(source, destination, {
               forceDelete: true,
               preserveFiles: false
             });
       
             finished();
           });
       
         }
       };
       
  2. Ritu Agrawal 2014-03-31

    Moving this ticket to engineering as I can reproduce the issue with the provided test case.
  3. Emilio Rodriguez 2014-04-29

    A better workaround we just came across is using *Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory).getNativePath()* when building the webView url instead of using only *Ti.Filesystem.applicationDataDirectory* It works but still, a proper fix would be nice.
  4. Michiel van Eerd 2016-06-23

    I used the approach of Fokke and it works for development and app store builds for iOS, but fails when doing an ad-hoc build as you get the error: Failed to verify code signature of /some/path/myapp.app : 0xe8008017 (A signed resource has been added, modified, or deleted.) I guess it is because you add something to the build after some signing has been done. If someone knows a workaround for this, I'll be glad to hear!

JSON Source