【发布时间】:2016-03-20 08:20:37
【问题描述】:
我正在编译一个非常简单的 Cordova 应用程序并在 Android 上进行部署。我想在各种 Android 设备上测试 jQuery Mobile 的流畅度,所以我正在用 jQuery Mobile 演示文件夹的内容编译一个应用程序。
我创建了一个新的 Cordova 项目并将 jQuery Mobile 演示文件夹的内容放入我的 www 文件夹中。
然后我使用 Cordova 二进制文件添加了 android 平台,运行了 cordova build,最后是 cordova run android。
应用程序在我的手机上打开,但不会加载除 index.html 之外的文件。我将应用程序连接到 Chrome Inspector 调试器以查看未加载的内容,这是我看到的内容:
Cordova 找不到的所有文件都存在于platforms/android/assets/www 中。 Cordova 可以找到 index.html 只是找到,但它无法加载其他任何内容。
如果我在网络浏览器中打开该文件夹,一切都会正常加载。
任何人都知道可能导致此问题的原因或我可能会采取哪些步骤来进一步排除故障和隔离问题?我已经在 Google 上搜索了几个小时,但我找不到其他人面临这种情况.对于其他人来说,是 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>
这是我的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>
这是我的index.html 文件:http://pastebin.com/duFSLT5T
【问题讨论】:
-
这不是科尔多瓦问题,这是您的应用程序的问题。请出示您的 HTML 文件。
-
@Joerg 感谢您的帮助。这是我的 index.html 文件:pastebin.com/duFSLT5T 它未从 jQuery Mobile 演示文件夹中修改。包含的所有相关文件均有效,并且 index.html 确实可以在常规 Web 浏览器中正确加载。
-
附带说明;我之前使用过带有 Phonegap / Cordova 的 jQuery Mobile,它不是很糟糕,但仍然很糟糕,尤其是对于旧手机(~岁)。我不会再在我的任何项目中使用 jQuery Mobile,但我真的很喜欢英特尔 AppFramework。
-
您确定目录_assets 存在吗?不重要,但是为什么要用js和_assets/js呢?
-
@Joerg 是的,它们确实存在,这是我的 www 文件夹的屏幕截图:pasteboard.co/26GVqv3.png(文件确实存在于该文件夹中)。我无法评论为什么它的结构是这样的,因为我只是复制并粘贴了 jQuery Mobile 的演示文件夹的内容。
标签: javascript android cordova jquery-mobile