Cordova app无法加载assets/www中的任何文件(仅限index.html)

Ran*_*444 7 javascript android jquery-mobile cordova

我正在编译一个非常简单的Cordova应用程序并在Android上进行部署.我想在各种Android设备上测试jQuery Mobile的流畅度,所以我正在使用jQuery Mobile演示文件夹的内容编译应用程序.

我创建了一个新的Cordova项目,并将jQuery Mobile demo文件夹的内容放入我的www文件夹中.

然后我使用Cordova二进制文件添加android平台,运行cordova构建,最后cordova run android.

应用程序在我的手机上打开,但没有其他文件index.html会加载.我将应用程序连接到Chrome Inspector调试器以查看未加载的内容,这是我看到的内容:

调试器中的错误

Cordova找不到的所有文件都存在于platforms/android/assets/www.Cordova可以找到index.html,但它不能加载任何其他东西.

如果我在网络浏览器中打开该文件夹,一切都加载正常.

任何人都知道可能导致此问题的原因或我可能采取哪些步骤来进一步排除故障并隔离问题?我用谷歌搜索了几个小时,我找不到任何其他人面对这样的情况.对于其他人来说,这是index.html无法加载的文件,或者他们只是忘了将他们想要的www文件添加到文件夹中.在我的情况下,index.html加载正常,但没有别的(见上面的截图).

这是我的config.xml(大多数只是标准默认值):

<?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>
Run Code Online (Sandbox Code Playgroud)

这是我的AndroidManifest.xml档案:

<?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>
Run Code Online (Sandbox Code Playgroud)

这是我的index.html文件:http://pastebin.com/duFSLT5T

Ran*_*444 9

我最终想出来了.使用Android进行部署时,这是一个Cordova问题.任何以下划线开头的文件夹都会被省略而不会发出警告.看起来这个bug已经存在了5年多,并且没有任何迹象表明很快就会被修复:

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