Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-12798] Android: include parameter is assumed relative to CommonJS file directory, causes FileNotFoundException

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2013-03-19T22:57:35.000+0000
Affected Version/sn/a
Fix Version/sRelease 3.1.0, 2013 Sprint 06 Core, 2013 Sprint 06
ComponentsAndroid
Labelsandroid, core, defect, include, qe-port, regression
ReporterShawn Lipscomb
AssigneeAllen Yeung
Created2013-02-20T15:33:31.000+0000
Updated2013-03-21T10:46:23.000+0000

Description

Problem

When a window with a url property is created from within a CommonJS unit, where the CommonJS unit resides in a subdirectory, includes that are within the window's unit (specified in the url property) used to be (2.1.4 and earlier) treated as relative to the Resources directory. Now (3.0.2.GA) it is treated as relative to the directory of the CommonJS file. If the CommonJS file is in a subdirectory, an error (APP PROXY: ti.modules.titanium.app.AppModule) is generated. This breaks a lot of existing code. Note that in the error message, the "ui" subdirectory is doubled: Error while reading asset "Resources/ui/ui/MyInclude.js" Works in 2.1.4.GA Broken in 3.0.2.GA

Testcase

Note in this example that the "MakeWin.js" and "MyInclude.js" files are in a "ui" subdirectory. {panel:title=app.js}
Ti.UI.setBackgroundColor('#000');
require('ui/MakeWin');
{panel} {panel:title=ui/MakeWin.js}
var win1=Ti.UI.createWindow({  
    title:'Window 1',
    backgroundColor:'#fff',
    url:'win1.js'
});
win1.open();
{panel} {panel:title=win1.js}
Ti.include('ui/MyInclude.js');

var winOne = Ti.UI.currentWindow;

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

winOne.add(label1);
{panel} {panel:title=ui/MyInclude.js}
var MyValue=5;
{panel}

Error Log:

[ERROR][TiApplication( 386)] (KrollRuntimeThread) [1417,1417] APP PROXY: ti.modules.titanium.app.AppModule@43e51900 [ERROR][TiAssetHelper( 386)] Error while reading asset "Resources/ui/ui/MyInclude.js": [ERROR][TiAssetHelper( 386)] java.io.FileNotFoundException: Resources/ui/ui/MyInclude.js [ERROR][TiAssetHelper( 386)] at android.content.res.AssetManager.openAsset(Native Method) [ERROR][TiAssetHelper( 386)] at android.content.res.AssetManager.open(AssetManager.java:313) [ERROR][TiAssetHelper( 386)] at android.content.res.AssetManager.open(AssetManager.java:287) [ERROR][TiAssetHelper( 386)] at org.appcelerator.kroll.util.KrollAssetHelper.readAsset(KrollAssetHelper.java:77) [ERROR][TiAssetHelper( 386)] at org.appcelerator.kroll.runtime.v8.V8Runtime.nativeRunModule(Native Method) [ERROR][TiAssetHelper( 386)] at org.appcelerator.kroll.runtime.v8.V8Runtime.doRunModule(V8Runtime.java:140) [ERROR][TiAssetHelper( 386)] at org.appcelerator.kroll.KrollRuntime.handleMessage(KrollRuntime.java:289) [ERROR][TiAssetHelper( 386)] at org.appcelerator.kroll.runtime.v8.V8Runtime.handleMessage(V8Runtime.java:166) [ERROR][TiAssetHelper( 386)] at android.os.Handler.dispatchMessage(Handler.java:95) [ERROR][TiAssetHelper( 386)] at android.os.Looper.loop(Looper.java:123) [ERROR][TiAssetHelper( 386)] at org.appcelerator.kroll.KrollRuntime$KrollRuntimeThread.run(KrollRuntime.java:112)

Comments

  1. Allen Yeung 2013-03-19

    https://github.com/appcelerator/titanium_mobile/pull/3986
  2. Shyam Bhadauria 2013-03-21

    Environment used for verification - Titanium SDK: 3.1.0.v20130320190115 Titanium  Studio:3.0.2.201302151605 Device: LG-P970 Android 2.2.2

JSON Source