javascript Cordova 文件插件永远不会在 Android 中准备就绪
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24438087/
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
Cordova File plugin never becomes ready in Android
提问by SimpleJ
I have a dead simple Cordova app with a single plugin: org.apache.cordova.file.
我有一个简单的 Cordova 应用程序,只有一个插件:org.apache.cordova.file。
When I emulate the app in an android emulator, the deviceready
event is never fired, and I get this as an output:
当我在 android 模拟器中模拟应用程序时,该deviceready
事件永远不会被触发,我将其作为输出:
D/CordovaLog( 1841): file:///android_asset/www/cordova.js: Line 1154 : deviceready has not fired after 5 seconds.
D/CordovaLog( 1841): file:///android_asset/www/cordova.js: Line 1147 : Channel not fired: onFileSystemPathsReady
Some additional information:
一些附加信息:
cordova --version
3.5.0-0.2.4
javac -version
javac 1.7.0_55
java -version
java version "1.7.0_55"
OpenJDK Runtime Environment (IcedTea 2.4.7) (7u55-2.4.7-1~deb7u1)
OpenJDK 64-Bit Server VM (build 24.51-b03, mixed mode)
index.html:
索引.html:
<!doctype html>
<html>
<head>
</head>
<body>
<script src='cordova.js' type='text/javascript'></script>
<script src='index.js' type='text/javascript'></script>
</body>
</html>
index.js:
索引.js:
(function() {
"use strict";
document.addEventListener("deviceready", function() {
console.log("Ready");
}, false);
}());
Is the Cordova File plugin broken? Am I doing something wrong? Has anyone else come across this issue and found a solution?
Cordova 文件插件坏了吗?难道我做错了什么?有没有其他人遇到过这个问题并找到了解决方案?
采纳答案by jeff.d
I ran into the same issue.
我遇到了同样的问题。
What worked for me was using a different version of the File plugin found here: https://github.com/onflapp/cordova-plugin-file
对我有用的是使用此处找到的不同版本的文件插件:https: //github.com/onflapp/cordova-plugin-file
Related topic: Android - Cordova 3.5.0 deviceready not firing after installing media plugin
回答by brickpop
Try installing the 1.1.0 version of the file plugin. Updating to 1.2.0 was a bad idea.
尝试安装 1.1.0 版本的文件插件。更新到 1.2.0 是个坏主意。
cordova plugin add [email protected]
This made the job for me on Android (and on iOS I stopped having other exotic problems).
这让我在 Android 上找到了工作(在 iOS 上我不再遇到其他奇怪的问题)。
回答by kapil
You need to include cordova plugin before closing of body tag , so that cordova gets loaded properly before body loading completes.
<!doctype html>
<html>
<head>
</head>
<body>
<script src='cordova.js' type='text/javascript'></script>
<script src='index.js' type='text/javascript'></script>
</body>
</html>