【问题标题】:net::ERR_FILE_NOT_FOUND file:///android_asset/www/index.html was not foundnet::ERR_FILE_NOT_FOUND 文件:///android_asset/www/index.html 未找到
【发布时间】:2015-06-21 07:43:40
【问题描述】:

我有一个 cordova 应用程序(我正在为 Android 构建),我使用命令行上的 keytools 对其进行了签名并将其安装到我的 Android 设备上。

每当我在手机上打开应用程序时,我都会收到以下错误:

Application Error
net::ERR_FILE_NOT_FOUND (file:///android_asset/www/index.html)

我的手机有互联网连接,因此有一个有效的移动互联网连接 - 谁能帮助调试问题?

我遇到了一些与移动远程资产相关的修复,但是我在我的应用程序中看不到我有任何指向远程 URL 的链接。

有没有一种方法可以让我进行“堆栈跟踪”,让我能够准确指出此应用程序错误在我的应用程序中引发的确切点?

任何提示将不胜感激

--更新-- 这是在模拟器中生成的adb日志

对于其他可能有帮助的人,我使用以下命令将模拟器日志输出到文件:-(需要双 >> 将数据附加到文件)

adb -e logcat >> emulator.log

https://gist.github.com/anonymous/e53abb7eb089950ac4e5

--更新-- 我的 AndroidManifest.xml 文件如下所示:

<?xml version='1.0' encoding='utf-8'?>
<manifest android:hardwareAccelerated="true" android:versionCode="1" android:versionName="0.0.1" package="com.myapp" 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" />
<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="10" android:targetSdkVersion="21" />
</manifest>

--更新-- 在我的平台 'android' 文件夹中是一个 'assets' 文件夹 - 它具有以下结构:

www/
_where-is-www.txt
  www/css
  www/img
  www/js
  www/res
  www/app.html
  www/cordova.js
  www/cordova_plugins.js
  www/index.php

似乎没有 index.html - 即使 cordova 设置声明了 index.html 文件...我不明白为什么会这样做。

注意: 我正在创建一个 Cordova 应用程序,添加一个 Android 平台,然后从现有应用程序的另一个目录中复制我现有的 www 文件夹(已开发并发布到 Play 商店,所以工作正常) - 然后最后进行构建。不知道为什么 index.html 应该显示...有什么想法吗??

【问题讨论】:

  • 你能发布调试日志吗?使用 ADB 在 CLI 中使用:adb logcat CordovaLog:D *:S 查看调试日志。或者,如果您的设备具有 Anrdoid 4.4+(Kitkat 或更高版本)-developer.chrome.com/devtools/docs/remote-debugging,您可以使用 Chrome 的远程调试 WebView 工具
  • 添加了日志文件 - 老实说不知道这意味着什么 :) 我希望一些 Android/Cordova 专家可以帮助我
  • 您能否检查一下&lt;uses-permission android:name="android.permission.INTERNET"/&gt; 是否已添加到您的config.xml 文件中?
  • 嗯,这应该可以工作。如果您从 CDN 加载任何 javascript,则仅当没有互联网连接时才会出现错误。但你也有权限。
  • 这真的很奇怪......我会坚持下去,最终会发现问题,但感谢您的建议

标签: android cordova android-sdk-tools


【解决方案1】:

您应该在cordova run android 之前运行cordova build android,或者通过运行cordova build android &amp;&amp; cordova run android --device 来简化操作
PS:如果你在 mac 上工作,别忘了sudo

【讨论】:

    猜你喜欢
    • 2017-10-24
    • 2016-07-20
    • 1970-01-01
    • 2015-02-14
    • 2019-09-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多