无法打开资产 URL:file:///android_asset/www/
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21239921/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Unable to open asset URL: file:///android_asset/www/
提问by Pascal
I get some error messages in Logcat when running my Android App, which was built using PhoneGap.
运行使用 PhoneGap 构建的 Android 应用程序时,我在 Logcat 中收到一些错误消息。
E/AndroidProtocolHandler(1475): Unable to open asset URL: file:///android_asset/www/css/mobile2.css
E/AndroidProtocolHandler(1475): Unable to open asset URL: file:///android_asset/www/scripts/custom.js
E/AndroidProtocolHandler(1475): Unable to open asset URL: file:///android_asset/www/scripts/customShare.js
Any ideas on how to fix this?
有想法该怎么解决这个吗?
采纳答案by Joe Packer
Check the path (where you are trying to access it) to insure that it is correct. You could also check the permissions on the file to insure that you can read/ write to the file. Hope this helps.
检查路径(您尝试访问它的位置)以确保它是正确的。您还可以检查文件的权限以确保您可以读/写文件。希望这可以帮助。
回答by mastermind
If this error persist after adding permission then check case of file names
如果添加权限后此错误仍然存在,请检查文件名的大小写
as
作为
file names are Case Sensitive in phonegap app
phonegap 应用程序中的文件名区分大小写
回答by Marcus
In my case the problem was a underscore as a first letter in a folder name. I had:
在我的情况下,问题是文件夹名称中的第一个字母作为下划线。我有:
file:///android_asset/html/_js
which I renamed to:
我重命名为:
file:///android_asset/html/js
That fixed the problem.
这解决了问题。
回答by vbc
I have faced this issue and i have solved first i have placed my new.js file in asset-->www-->js-->new.js
我遇到了这个问题,我首先解决了我将我的 new.js 文件放在asset-->www-->js-->new.js 中
after that i cut that file and placed in asset-->www-->new.jsNow its working fine hope its help for you
之后我剪切了那个文件并放置在asset-->www-->new.js现在它工作正常希望对你有帮助
回答by Ratna Halder
I have faced same problem like you and I could not access and play video file from assets or raw file. After trying many more solution getting online, I could not resolve my problem. But,I have solved my problem by storing video file into mobile storage. Like:
我遇到了和你一样的问题,我无法从资产或原始文件访问和播放视频文件。在尝试了更多在线解决方案后,我无法解决我的问题。但是,我通过将视频文件存储到移动存储中解决了我的问题。喜欢:
<video id="video" autoplay="autoplay" width="640" height="360" controls>
<source src=“file:///storage/emulated/legacy/Video/test.mp4” type="video/mp4" />
</video>
Note: “file:///storage/emulated/legacy/Video/test.mp4”information will be changed as per your storage location.
注意:“file:///storage/emulated/legacy/Video/test.mp4”信息将根据您的存储位置进行更改。
回答by Imaxo
I tried all options above but the issue still persisted.
我尝试了上述所有选项,但问题仍然存在。
Here was the fix that I figured out:
这是我想出的修复方法:
Go to Project -> Properties -> Resource -> Resource Filters and remove the Exclusion filters.
转到项目 -> 属性 -> 资源 -> 资源过滤器并删除排除过滤器。
This should rebuild automatically and you'll be fine.
这应该会自动重建,你会没事的。
If this helped you please up-vote my answer. I need more reputation points to reduce my stack limitations.
如果这对您有帮助,请为我的答案投票。我需要更多的声望点来减少我的堆栈限制。

