admin管理员组文章数量:1254577
I'm piling a very simple Cordova app and deploying on Android. I want to test the smoothness of jQuery Mobile on various Android devices, so I'm piling an app with the contents of the jQuery Mobile demo folder.
I created a new Cordova project and placed the contents of jQuery Mobile demo folder into my www
folder.
I then used the Cordova binary to add the android platform, ran cordova build, and finally cordova run android
.
The application opened on my phone, but no files other than the index.html
will load. I connected up the app to the Chrome Inspector debugger to see what wasn't loading, here's what I saw:
All of the files that Cordova can't find, do exist in platforms/android/assets/www
. Cordova can find index.html
just find, but it cannot load anything else.
If I open that folder in a web browser, everything loads just fine.
Anyone know what could be causing this issue or what steps I might take to further troubleshoot and isolate the issue? I've Googled for hours and I cannot find anyone else facing a situation quite like this. For other people, it's the index.html
file that won't load or they simply forgot to add the files they want into the www
folder. In my case, index.html
loads fine, but nothing else will (see screenshot above).
Here is my config.xml
(mostly just the standard default):
<?xml version='1.0' encoding='utf-8'?>
<widget id=".rand.jqmdemo" version="0.0.1" xmlns="" xmlns:cdv=".0">
<name>jqmdemo</name>
<description>
A sample Apache Cordova application that responds to the deviceready event.
</description>
<author email="[email protected]" href="">
Apache Cordova Team
</author>
<content src="index.html" />
<plugin name="cordova-plugin-whitelist" spec="1" />
<access origin="*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<platform name="android">
<allow-intent href="market:*" />
</platform>
<platform name="ios">
<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />
</platform>
<engine name="android" spec="~4.1.1" />
</widget>
Here is my AndroidManifest.xml
file:
<?xml version='1.0' encoding='utf-8'?>
<manifest android:hardwareAccelerated="true" android:versionCode="1" android:versionName="0.0.1" package=".elliot.jqmdemo" xmlns:android="">
<supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<application android:hardwareAccelerated="true" android:icon="@drawable/icon" android:label="@string/app_name" android:supportsRtl="true">
<activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="@string/activity_name" android:launchMode="singleTop" android:name="MainActivity" android:theme="@android:style/Theme.Black.NoTitleBar" android:windowSoftInputMode="adjustResize">
<intent-filter android:label="@string/launcher_name">
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="22" />
</manifest>
Here is my index.html
file:
I'm piling a very simple Cordova app and deploying on Android. I want to test the smoothness of jQuery Mobile on various Android devices, so I'm piling an app with the contents of the jQuery Mobile demo folder.
I created a new Cordova project and placed the contents of jQuery Mobile demo folder into my www
folder.
I then used the Cordova binary to add the android platform, ran cordova build, and finally cordova run android
.
The application opened on my phone, but no files other than the index.html
will load. I connected up the app to the Chrome Inspector debugger to see what wasn't loading, here's what I saw:
All of the files that Cordova can't find, do exist in platforms/android/assets/www
. Cordova can find index.html
just find, but it cannot load anything else.
If I open that folder in a web browser, everything loads just fine.
Anyone know what could be causing this issue or what steps I might take to further troubleshoot and isolate the issue? I've Googled for hours and I cannot find anyone else facing a situation quite like this. For other people, it's the index.html
file that won't load or they simply forgot to add the files they want into the www
folder. In my case, index.html
loads fine, but nothing else will (see screenshot above).
Here is my config.xml
(mostly just the standard default):
<?xml version='1.0' encoding='utf-8'?>
<widget id=".rand.jqmdemo" version="0.0.1" xmlns="http://www.w3/ns/widgets" xmlns:cdv="http://cordova.apache/ns/1.0">
<name>jqmdemo</name>
<description>
A sample Apache Cordova application that responds to the deviceready event.
</description>
<author email="[email protected]" href="http://cordova.io">
Apache Cordova Team
</author>
<content src="index.html" />
<plugin name="cordova-plugin-whitelist" spec="1" />
<access origin="*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<platform name="android">
<allow-intent href="market:*" />
</platform>
<platform name="ios">
<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />
</platform>
<engine name="android" spec="~4.1.1" />
</widget>
Here is my AndroidManifest.xml
file:
<?xml version='1.0' encoding='utf-8'?>
<manifest android:hardwareAccelerated="true" android:versionCode="1" android:versionName="0.0.1" package=".elliot.jqmdemo" xmlns:android="http://schemas.android./apk/res/android">
<supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<application android:hardwareAccelerated="true" android:icon="@drawable/icon" android:label="@string/app_name" android:supportsRtl="true">
<activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="@string/activity_name" android:launchMode="singleTop" android:name="MainActivity" android:theme="@android:style/Theme.Black.NoTitleBar" android:windowSoftInputMode="adjustResize">
<intent-filter android:label="@string/launcher_name">
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="22" />
</manifest>
Here is my index.html
file: http://pastebin./duFSLT5T
- That is not an cordova issue, that is an issue of your app. Please show your HTML file. – Joerg Commented Dec 14, 2015 at 18:36
- @Joerg Thanks for helping. This is my index.html file: pastebin./duFSLT5T it is unmodified from the jQuery Mobile demos folder. All of the relative file includes are valid and the index.html does load properly in a regular web browser. – Randall444 Commented Dec 14, 2015 at 18:41
- On a side note; I have used jQuery Mobile with Phonegap / Cordova before at it was not HORRIBLY bad, but still pretty bad, especially with older phones (~year old). I would not use jQuery Mobile on any of my projects anymore, but instead I really like Intel AppFramework. – Swiffy Commented Dec 14, 2015 at 18:52
- Are you sure, that the directory _assets exists? Not important, but why do you use js and _assets/js? – Joerg Commented Dec 14, 2015 at 18:53
- @Joerg Yep, they do exist, here's a screenshot of my www folder: pasteboard.co/26GVqv3.png (the files do exist within that folder). I can't ment on why it's structured that way because I'm merely copied and pasted the contents of jQuery Mobile's demo folder. – Randall444 Commented Dec 14, 2015 at 19:03
2 Answers
Reset to default 11I eventually figured this out. It's a Cordova issue while deploying with Android. Any folders that begin with an underscore are omitted without warning. It looks like the bug has been around for over 5 years and with no sign of getting fixed soon:
https://code.google./p/android/issues/detail?id=5343
If your files are in documents->jqdemo->www , like you show on pasteboard.co, then your files are in the wrong place.
They have to be in:
your_cordova_project->platforms->android->assets->www
To do so:
Include the assets, index.html, js only in the root folder of your cordova project and then do a cordova build and don't change the platform www folder by yourself.
If you are coding and not just testing, the better way is to have symlinks or pre-scripts, which do the copy job. So you don't have to call every time cordova build.
jQuery Mobile: It runs very well on mobile devices, if you know what you are doing. Otherwise it is very easy to slow down your app. So, be careful!
Update:
Interesting problem and I stay on it, that the path is not correct, maybe not resolvable. So, try this things:
- Create a new css file, name test.css and content:
body {
background-color: red !important;
font-size: 3em !important;
}
Put this file in the root of your www folder, link it in your html-file and make a cordova build. Do you see the file in the platform www-folder?
How does it affect on your device?
本文标签: javascriptCordova app cannot load any files in assetswww (only indexhtml)Stack Overflow
版权声明:本文标题:javascript - Cordova app cannot load any files in assetswww (only index.html) - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1740808199a2289370.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论