我将连接的手机用作ADB设备。
→phonegap -v 3.1.0-0.15.0
我的index.html中几乎没有任何内容
<script type="text/javascript" src="phonegap.js"></script>
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="js/jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<script type="text/javascript" src="js/angular.min.js"></script>
<script type="text/javascript" src="js/main.js"></script>
</body>
当我跑步时
→ phonegap local run android
[phonegap] compiling Android...
[phonegap] successfully compiled Android app
[phonegap] trying to install app onto device
[phonegap] successfully installed onto device
我可以看到我的应用程序运行,之前没有注意到控制台中的错误。然后我尝试了更复杂的东西,如ngRoute,但它没有用。我决定将所有数据删除到几乎为空的项目,如您所见(确保其他内容不会导致此错误)。
然后我通过以下方式检查了控制台:
adb logcat | grep -i console
我明白了:
I/Web Console( 3946): Could not find cordova.js script tag. Plugin loading may
fail.:1511
E/Web Console( 3946): Uncaught module cordova/plugin_list already defined:76
I/Web Console( 4329): exception firing pause event from native:1
I/Web Console( 4329): Could not find cordova.js script tag. Plugin loading may fail.:1511
I/Web Console( 4329): Could not find cordova.js script tag. Plugin loading may fail.:1511
I/Web Console( 5006): Could not find cordova.js script tag. Plugin loading may fail.:1511
E/Web Console( 5006): Uncaught module cordova/plugin_list already defined:76
I/Web Console( 5476): Could not find cordova.js script tag. Plugin loading may fail.:1511
I/Web Console( 5949): Could not find cordova.js script tag. Plugin loading may fail.:1511
E/Web Console( 5949): Uncaught module cordova/plugin_list already defined:76
I/Web Console( 6374): Could not find cordova.js script tag. Plugin loading may fail.:1511
E/Web Console( 6374): Uncaught module cordova/plugin_list already defined:76
I/Web Console( 6762): exception firing pause event from native:1
I/Web Console( 6762): Could not find cordova.js script tag. Plugin loading may fail.:1511
I/Web Console( 7141): exception firing pause event from native:1
I/Web Console( 7141): Could not find cordova.js script tag. Plugin loading may fail.:1511
E/Web Console( 7141): Uncaught module cordova/plugin_list already defined:76
I/Web Console( 7267): exception firing pause event from native:1
I/Web Console( 7267): Could not find cordova.js script tag. Plugin loading may fail.:1511
I/Web Console( 7383): exception firing pause event from native:1
I/Web Console( 7383): Could not find cordova.js script tag. Plugin loading may fail.:1511
I/Web Console( 7557): exception firing pause event from native:1
I/Web Console( 7557): Could not find cordova.js script tag. Plugin loading may fail.:1511
I/Web Console( 7697): exception firing pause event from native:1
I/Web Console( 7697): Could not find cordova.js script tag. Plugin loading may fail.:1511
I/Web Console( 7998): exception firing pause event from native:1
I/Web Console( 7998): Could not find cordova.js script tag. Plugin loading may fail.:1511
I/Web Console( 8156): exception firing pause event from native:1
I/Web Console( 8156): Could not find cordova.js script tag. Plugin loading may fail.:1511
E/Web Console( 8156): Uncaught ReferenceError: angular is not defined:10
I/Web Console( 8491): exception firing pause event from native:1
I/Web Console( 8491): Could not find cordova.js script tag. Plugin loading may fail.:1511
E/Web Console( 8491): Uncaught module cordova/plugin_list already defined:76
但它没有成功。我在index.html中有这个脚本标记,你可以看到+这个文件存在于:
platforms/android/assets/www/
我还将此文件复制到我的普通www目录中。
请问有什么问题?
答案 0 :(得分:6)
尝试删除该行:
<script type="text/javascript" src="phonegap.js"></script>
来自index.html
的。如果仔细查看,您会发现phonegap.js
和cordova.js
的大小相同。由于遗留支持原因,显然存在phonegap.js
,但您应该只使用cordova.js
。
这是评论中引用的GitHub Issue中实际建议的内容,它为我做了诀窍,我停止收到Could not find cordova.js script tag
消息。
答案 1 :(得分:3)
我将phonegap.js
替换为cordova.js
并且它有效,如下所述:https://github.com/phonegap/phonegap-cli/issues/134#issuecomment-22035314
从index.html
:
<script type="text/javascript" src="phonegap.js"></script>
并添加:
<script type="text/javascript" src="cordova.js"></script>
答案 2 :(得分:2)
我已经通过完全重新安装所有内容并重新设置环境解决了这个问题,但现在BY CORDOVA TERMINAL COMMANDS不是phonegap。