简体   繁体   中英

Uncaught Error: Couldn't load file:///android_asset/www/less/app.less (200) at file:///android_asset/www/js/lib/less.js:15

I am getting following error while trying to run this phonegap 1.4/adnroid 8 app on my dev machine:

Uncaught Error: Couldn't load file:///android_asset/www/less/app.less (200) at file:///android_asset/www/js/lib/less.js:15

And this android/phonegap app is "running on emulator/phone" but shows up with NO styling(because it is not able to load less.js i guess).

Both the files are part of the app directory structure and so I am not loading anything from internet(because I can see these 2 files under www).

Most of the solutions on internet talk about internet connectivity but these files are present locally but for some reason app is not able to load! Also to make sure these files not loading anything from internet I added proxy, and "uses-permission android:name="android.permission.INTERNET" is present in AndroidManifest.xml.

Are there any other settings I should check? Any hints? Thanks in advance!

解决方法:将.less文件编译为CSS文件,并将其直接包含在HTML页面中。

Modify less js source file, add this line:

href = href.replace( "file:///android_asset/www/", "");

inside loadStyleSheet function, before calling xhr function (somewhere around #4150 ).

That should work. Tested on Less 1.3.3

Less is using absolute path when doing ajax call to get Less files defined in 'link' tags. We just made that absolute link - relative.

Do not convert your stylesheet extension , keep it as same (eg:styles.css) but not styles.less

and follow the same

<link href="styles.css" rel="stylesheet/less" type="text/css" />

I got same problem while using less-1.3.3 version!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM