Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-10783] Android: Window url is assumed relative to calling js file directory, causes FileNotFoundException

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2012-10-02T16:20:38.000+0000
Affected Version/sRelease 3.0.0
Fix Version/sRelease 3.0.0, Sprint 2012-20 Core, 2012 Sprint 20
ComponentsAndroid
Labelscore, module_window, qe-testadded, regression, titanbeta
ReporterShawn Lipscomb
AssigneeOpie Cyrus
Created2012-09-05T11:00:14.000+0000
Updated2013-09-25T05:53:54.000+0000

Description

Problem

When a window is created with the *url* property, that url used to be (2.1.2 and earlier) treated as relative to the Resources directory. Now (2.2.0.v20120904164912) it is treated as relative to the directory of the calling js file. If the calling js file is in a subdirectory, an error (java.io.FileNotFoundException) is generated. This is going to break a lot of existing code. Works in 2.1.2 Broken in 2.2.0.v20120904164912

Testcase

Note in this example that the "loader.js" file is in a "ui" subdirectory. {panel:title=app.js}
 
Ti.UI.setBackgroundColor('#000'); 
Ti.include('ui/loader.js'); 
{panel} {panel:title=ui/loader.js}
 
var win1=Ti.UI.createWindow({ 
    title:'Window 1', 
    backgroundColor:'#fff', 
    url:'win1.js' 
}); 
win1.open(); 
{panel} {panel:title=win1.js}
 
var winOne = Ti.UI.currentWindow; 

var label1 = Ti.UI.createLabel({ 
  color:'#999', 
  text:'I am Window 1', 
  font:{fontSize:20,fontFamily:'Helvetica Neue'}, 
  textAlign:'center', 
  width:'auto' 
}); 

winOne.add(label1); 
{panel}

Error log

... [ERROR][TiAssetHelper( 345)] Error while reading asset "Resources/ui/win1.js": [ERROR][TiAssetHelper( 345)] java.io.FileNotFoundException: Resources/ui/win1.js [ERROR][TiAssetHelper( 345)] at android.content.res.AssetManager.openAsset(Native Method) [ERROR][TiAssetHelper( 345)] at android.content.res.AssetManager.open(AssetManager.java:313) [ERROR][TiAssetHelper( 345)] at android.content.res.AssetManager.open(AssetManager.java:287) [ERROR][TiAssetHelper( 345)] at org.appcelerator.kroll.util.KrollAssetHelper.readAsset(KrollAssetHelper.java:77) [ERROR][TiAssetHelper( 345)] at org.appcelerator.kroll.runtime.v8.V8Runtime.nativeRunModule(Native Method) [ERROR][TiAssetHelper( 345)] at org.appcelerator.kroll.runtime.v8.V8Runtime.doRunModule(V8Runtime.java:140) [ERROR][TiAssetHelper( 345)] at org.appcelerator.kroll.KrollRuntime.handleMessage(KrollRuntime.java:284) [ERROR][TiAssetHelper( 345)] at org.appcelerator.kroll.runtime.v8.V8Runtime.handleMessage(V8Runtime.java:166) [ERROR][TiAssetHelper( 345)] at android.os.Handler.dispatchMessage(Handler.java:95) [ERROR][TiAssetHelper( 345)] at android.os.Looper.loop(Looper.java:123) [ERROR][TiAssetHelper( 345)] at org.appcelerator.kroll.KrollRuntime$KrollRuntimeThread.run(KrollRuntime.java:108) {panel}

Comments

  1. Shawn Lipscomb 2012-09-10

    Helpdesk ticket: [APP-983576](http://support.appcelerator.com/tickets/APP-983576)
  2. Opie Cyrus 2012-09-26

    PR submitted: https://github.com/appcelerator/titanium_mobile/pull/3057
  3. Natalie Huynh 2012-12-05

    Tested with 3.0.0.20121204144658 on Droid 1 2.2.3
  4. Shawn Lipscomb 2013-02-20

    Verified fixed with SDK 3.0.2.v20130124164131. Thanks!

JSON Source