Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-24191] Android: Unable to load asset from the resources directory in 6.0.0.GA

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionInvalid
Resolution Date2016-12-05T16:00:27.000+0000
Affected Version/sRelease 6.0.0
Fix Version/sn/a
ComponentsAndroid
Labelsandroid, regression
ReporterJoachim Mollin
AssigneeChristopher Williams
Created2016-12-02T13:33:19.000+0000
Updated2017-10-27T08:45:05.000+0000

Description

I use a web view to load a html file to present a graph. When loading the libraries I get an error in 6.0.0GA but not in 5.5.1GA. [ERROR] : AndroidProtocolHandler: Unable to open asset URL: file:///android_asset/Resources//ui/common/RGraph.common.core.js.lib [ERROR] : AndroidProtocolHandler: Unable to open asset URL: file:///android_asset/Resources//ui/common/RGraph.common.dynamic.js.lib [ERROR] : AndroidProtocolHandler: Unable to open asset URL: file:///android_asset/Resources//ui/common/RGraph.line.js.lib
<!DOCTYPE html>
<html>
	<head>
		<meta name="apple-mobile-web-app-capable" content="yes" />
		<!--Load the AJAX API-->
		<script type="text/javascript" src="RGraph.common.core.js.lib" > </script>
		<script type="text/javascript" src="RGraph.common.dynamic.js.lib" > </script>
		<script type="text/javascript" src="RGraph.line.js.lib" > </script>
 	</head>
	<body>
		<!-- Content -->
	</body>
</html>

Comments

  1. Hans Knöchel 2016-12-02

    [~cwilliams] Could this be caused by the require-changes in 6.0.0? If so, we could look into this for 6.0.1. Thx!
  2. Hans Knöchel 2016-12-02

    [~mollin] Can you upload the used JS files for us? Then I'll attach them to the ticket to have a 1:1 use-case. Thx!
  3. Abir Mukherjee 2016-12-02

    I tried to reproduce the issue with this environment: NPM Version: 2.15.9 Node Version: 4.5.0 Mac OS: 10.12.1 Appc CLI: 6.0.0 Appc CLI NPM: 4.2.8 Titanium SDK version: 6.0.0GA Appcelerator Studio, build: 4.8.0.201611121409 Xcode 8.1 GM I did not see the error with 5.5.1 GA, however, I was also not able to reproduce the error messages using 6.0.0 GA as reported in the ticket. Here is the code I used: app.js:
       var win = Ti.UI.createWindow({
           backgroundColor: '#fff'
       });
       
       var webView = Ti.UI.createWebView({
           url: "myLocalWebView.html"
       });
       win.add(webView);
       win.open();
       
    myLocalWebView.html:
       <!DOCTYPE html>
       <html>
       	<head>
       		<title>A test app</title>
       		<meta name="apple-mobile-web-app-capable" content="yes" />
       		<!--Load the AJAX API-->
       		<script type="text/javascript" src="RGraph.common.core.js.lib" > </script>
       		<script type="text/javascript" src="RGraph.common.dynamic.js.lib" > </script>
       		<script type="text/javascript" src="RGraph.line.js.lib" > </script>
        	</head>
       	<body>
       		<!-- Content -->
       	</body>
       </html>
       
    Located in Resources folder: myLocalWebView.html RGraph.common.core.js.lib RGraph.common.dynamic.js.lib RGraph.line.js.lib The RGraph js files were downloaded from the RGraph website, and I added the .lib to the file names to match the names in the html file.
  4. Joachim Mollin 2016-12-02

    My lib files are locates in Resources/ui/common. It happens only for Android *HTML file*:
       <!DOCTYPE html>
       <html>
       	<head>
       		<title>line</title>
       		<meta name="viewport" content="user-scalable=yes, width=device-width, initial-scale = 1.0, minimum-scale = 1.0, maximum-scale = 10.0" /> <meta name="apple-mobile-web-app-capable" content="yes" />
       		<!--Load the AJAX API-->
       		<script type = "text/javascript" src = "RGraph.common.core.js.lib" > </script>
       		<script type = "text/javascript" src = "RGraph.common.dynamic.js.lib" > </script>
       		<script type = "text/javascript" src = "RGraph.line.js.lib" > </script>
       		<script type = "text/javascript"> 
       		Ti.App.addEventListener('app:renderChart', function(chartData) {
       		    document.getElementById("line1").width = chartData.width;
       	        
       	        var line1 = new RGraph.Line('line1', chartData.lo, chartData.hi, chartData.y); 
       	            line1.Set('chart.title', chartData.title);
       	            line1.Set('chart.title.vpos', 0.5);
       	            line1.Set('chart.colors', ['#ff0000','#ff0000', '#0000ff']); 
       	            line1.Set('chart.tickmarks', 'circle'); 
       	            line1.Set('chart.linewidth', 1);
       	            line1.Set('chart.scale.decimals',1);
       	            //line1.Set('chart.tooltips',chartData.y);
       	            //line1.Set('chart.background.barcolor1', 'white');
       	            //line1.Set('chart.background.barcolor2', 'white');
       	            line1.Set('chart.background.grid', true);
       	            line1.Set('chart.background.grid.autofit', true);
       	            line1.Set('chart.background.grid.autofit.numhlines', chartData.count);
       	            //line1.Set('chart.filled', true);
       	            //line1.Set('chart.fillstyle', '#fcc000');
       	            line1.Set('chart.labels', chartData.x); 
       	            line1.Set('chart.text.angle',20);
       	            line1.Set('chart.gutter.left', 95);
       	            line1.Set('chart.gutter.bottom', 55);
       	            //line1.Set('chart.ylabels.count', chartData.count);
       	            //line1.Set('chart.ylabels.specific', chartData.label);
       	            line1.Set('chart.yaxispos', 'left');
       	            line1.Set('chart.ymin', chartData.min);
       	            line1.Set('chart.ymax', chartData.max);
       	            line1.Set('chart.outofbounds', true);
       	            line1.Set('chart.zoom.factor', 4);
       	            line1.Set('chart.numyticks', 20);
       	            //line1.Set('chart.title.xaxis', '');
       	            line1.Set('chart.title.yaxis', chartData.unit);
       	            line1.Set('chart.title.xaxis.pos', 2.5);
       	            line1.Set('chart.title.yaxis.pos', 0.5);
       	            //line1.Set('chart.shadow',true);
       	            line1.Set('chart.events.click', fnClick); 
           			line1.Draw();
       	        });
       	        
       	        function fnClick(){
       	        	Ti.App.fireEvent('app:closeChart', {
       				});
       	        }
       		</script>
       </head>
       <body>
           <div>
           	<canvas id="line1" height="300" width="600" border="1">[Please wait...]</canvas>    
           </div>   
       </body>
       </html>
       
    *Setup WebView*:
       	if (epr.android) {
       		var url = 'line_chart.html';
       	} else {
       		var url = 'ui/common/line_chart.html';
       	}
       		
       	var wvChart = Titanium.UI.createWebView({
       		    borderRadius: 1,
       		    height:300,
       		    left:0, 
       		    top:70,
       		    borderRadius:0,
       		    zIndex:99999,
       		    url:url
       	});
       
    *If loaded, fire event*:
       	wvChart.addEventListener('load',function(e){
       	    if (line.title == undefined || line.min>line.max || line.min == 'NaN' || line.max == 'NaN'){
       	    	Ti.App.fireEvent(
       					'app:closeChart', {});
       	    }
       
       		var w = labResultShow[0].getContentWidth();
       		if (w < epr.maxX || w == null){
       			w = epr.maxX;
       		}
       		
       		Ti.App.fireEvent(
       			'app:renderChart', {
       				y: line.y,
       				x: line.x, 
       				label: line.yValue,
       				count: line.count,
       				title: line.title,
       				max:line.max,
       				min:line.min,
       				hi:line.hi_bound,
       				lo:line.lo_bound,
       				unit:line.par_unit,
       				width:w,
       		    	height:300		    
       		});    
       	});	
       
  5. Christopher Williams 2016-12-05

    I'm also unable to reproduce this error. I don't think this is an SDK bug. If I look at the code you mention above:
       if (epr.android)
       { var url = 'line_chart.html'; }
       else
       { var url = 'ui/common/line_chart.html'; }
       
    It looks to me like on Android you're loading web view content at /Resources/line_chart.html, while on other platforms (iOS), it's at <app>/Resources/ui/common/line_chart.html. Given the JS script references are relative, that means that <app>/Resources/ui/common/line_chart.html will load the JS files inside <app>/Resources/ui/common fine; whereas <app>/Resources/line_chart.html would expect them to live inside <app>/Resources/
  6. Christopher Williams 2016-12-05

    Marking as invalid for now until we can see a reproducible case of this. QE and two SDK engineers were all unable to reproduce.
  7. Joachim Mollin 2016-12-05

    Hallo Chris, you might be right. But the example was working since 5.5.1GA. I didn’t change anything at that point. But it doesn’t work if i use the same url as for iOS. Please tell me what the correct url ist? Regards Joachim
  8. Joachim Mollin 2016-12-05

    HI, you are right. It works with /ui/common/line_chart.html. Thanks for your help. Then it must be a bug in older version as it works with 5.5.1GA
  9. Lee Morris 2017-03-21

    Closing ticket as invalid.
  10. Marian Kucharcik 2017-10-27

    Hi guys, I have similar problem - I have webview.html in Resources folder and inside it I link webview.js via
        <script src="webview.js" type="text/javascript" charset="utf-8"></script>
        
    it throws me error: AndroidProtocolHandler: Unable to open asset URL: file:///android_asset/Resources//webview.js I'm using Ti.SDK 6.2.2GA on macOS Sierra and Nexus5x@Android 7.1 Can you please help me? Thanks
  11. Marian Kucharcik 2017-10-27

    Hi guys, I found solution - problem was, that I created Ti.UI.webview from socket.js file which is required in app.js. I moved Ti.UI.webview to app.js and now it's working without that error.

JSON Source