Cordova application cannot upload files to assets / www (only index.html)

I am building a very simple Cordova application and deploying it on Android. I want to test the smoothness of jQuery Mobile on different Android devices, so I am building an application with the contents of the jQuery Mobile demo folder.

I created a new Cordova project and placed the contents of the jQuery Mobile demo folder in my www folder.

Then I used the Cordova binary to add the Android platform, run the cord assembly, and finally cordova run android .

The application is open on my phone, but files other than index.html will not be downloaded. I connected the application to the Chrome Inspector debugger to see what is not loading, here is what I saw:

Debugger Errors

All files that Cordoba cannot find exist in platforms/android/assets/www . Cordoba can find index.html only find, but it can not load anything.

If I open this folder in a web browser, everything will load fine.

Does anyone know what could be causing this problem, or what steps can I take to further fix and fix the problem? I have been working for several hours and I canโ€™t find anyone who is facing a situation like this. For other people, this is an index.html file that doesnโ€™t load, or just forgot to add the files that they want to the www folder. In my case, index.html loads fine, but nothing else will happen (see screenshot above).

Here is my config.xml (basically just the default default):

 <?xml version='1.0' encoding='utf-8'?> <widget id="com.rand.jqmdemo" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0"> <name>jqmdemo</name> <description> A sample Apache Cordova application that responds to the deviceready event. </description> <author email=" dev@cordova.apache.org " 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="com.elliot.jqmdemo" xmlns:android="http://schemas.android.com/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.com/duFSLT5T

+6
source share
2 answers

I finally figured it out. This is a Cordova issue when deploying with Android. Any folders starting with an underline are omitted without warning. It seems that the error has existed for more than 5 years and without signs of an early correction:

https://code.google.com/p/android/issues/detail?id=5343

+7
source

If your files are in documents-> jqdemo-> www, as you show on cardboard.co, then your files are in the wrong place.

They must be in:

your_cordova_project-> platforms-> android-> assets-> WWW

For this:

Include the assets, index.html, js, only in the root folder of your cordova project, and then create a cord and do not change your platform www-folder yourself.

If you are coding, not just testing, the best way is to have symbolic links or preliminary scripts that perform the copy job. Therefore, you do not need to call every time you build a cord.

jQuery Mobile: it works very well on mobile devices , if you know what you are doing. Otherwise, it is very easy to slow down the application. So be careful!

Update:

An interesting problem, and I remain on it that the path is wrong, perhaps not solvable. So try the following:

  • Create a new css file, name test.css and contents:

 body { background-color: red !important; font-size: 3em !important; } 

Put this file in the root folder of your www, put it in your html file and create a cord. Do you see the file in the www folder of the platform?

How does this affect your device?

0
source

All Articles