Titanium JIRA Archive
Appcelerator Community (AC)

[AC-5198] baseUrl not working: Android Marshmallow and Oreo

GitHub Issuen/a
TypeBug
Priorityn/a
StatusClosed
ResolutionNeeds more info
Resolution Date2017-11-03T20:38:50.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsTitanium SDK & CLI
Labels6.2.2, Android, baseurl, webview
Reporterios.admin@investis.com
AssigneeShak Hossain
Created2017-09-15T05:19:27.000+0000
Updated2019-02-24T13:04:23.000+0000

Description

*+{color:red}baseURL{color}+* property is not working in android application. As a result of it, my application is unable to render/ show styles and images stored at local paths.

Comments

  1. Hans Knöchel 2017-09-15

    Thank you for reporting the two issues! Like for the other one, please provide a reproducible test-case and error-logs first, thank you!
  2. ios.admin@investis.com 2017-09-15

    While accessing the Webpage in android webview, all the external resources linked in html page, won't able to load in webview. Used baseUrl with setHTML method as below: $.webView.setHtml(htmlContent, { baseURL : path + "/" }); And in console it gives following errors: [ERROR] :AndroidProtocolHandler: Unable to open asset URL: file:///android_asset/jquery.js [ERROR] : AndroidProtocolHandler: Unable to open asset URL: file:///android_asset/Resources/images/banner.jpg
  3. ios.admin@investis.com 2017-09-20

    Any Update on above?
  4. Hans Knöchel 2017-09-20

    The test-case provided won't help to reproduce the issue, you will need to provide a test-case that can be dropped into a project, including your assets. If you can, just upload a test-project and we come back to you asap.
  5. Sharif AbuDarda 2017-10-18

    Hello, Please provide a sample code that can be dropped into a project, including your assets. If you can, just upload a test-project and we come back to you asap. Or else we will be closing this ticket. Thanks.
  6. Joshua Quick 2019-02-22

    I've confirmed that the WebView.setHtml() method's 2nd argument is being ignored on Android as of Titanium 6.1.0. This changed happened in the link below. I think there was confusion at the time on whether or not it was an officially documented feature. https://github.com/appcelerator/titanium_mobile/pull/8854 But I agree, the "baseURL" setting is definitely needed on both Android and iOS. Especially when using an iframe, such as an embedded YouTube video. The below can reproduce this issue.
       var htmlText =
       		'<!DOCTYPE html>' +
       		'<html>' +
       		'	<body>' +
       		'		<iframe width="560" height="315" src="https://www.youtube.com/embed/dQw4w9WgXcQ" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen/>' +
       		'	</body>' +
       		'</html>';
       
       var window = Ti.UI.createWindow();
       var webView = Ti.UI.createWebView();
       //webView.html = htmlText;
       webView.setHtml(htmlText, { baseURL: "https://www.youtube.com" });
       window.add(webView);
       window.open();
       
  7. Joshua Quick 2019-02-22

    This issue was written up here: [TIMOB-26848]

JSON Source