[TIMOB-16788] Android: WebView cannot find assets in ApplicationData directory
| GitHub Issue | n/a |
|---|---|
| Type | Bug |
| Priority | Low |
| Status | Open |
| Resolution | Unresolved |
| Affected Version/s | Release 3.2.2 |
| Fix Version/s | n/a |
| Components | Android |
| Labels | android, parity, webview |
| Reporter | Fokke Zandbergen |
| Assignee | Unknown |
| Created | 2014-03-27T10:53:31.000+0000 |
| Updated | 2018-02-28T20:03:57.000+0000 |
Description
Attachments
| File | Date | Size |
|---|---|---|
| device-2014-03-27-115312.png | 2014-03-27T10:53:32.000+0000 | 48156 |
| iOS-simulatorschermafbeelding 27 mrt. 2014 11.52.46.png | 2014-03-27T10:53:32.000+0000 | 68433 |
| wvr.zip | 2014-03-27T10:53:32.000+0000 | 260368 |
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(); }); } };Moving this ticket to engineering as I can reproduce the issue with the provided test case.
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.
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!