在cordova官网,下载插件"cordova-sms-plugin" ,网址 https://www.npmjs.com/package/cordova-sms-plugin然后按照网址 http://doc.wex5.com/?p=2910 方法,往Wex5添加该插件。
添加完成后,在打包调试包的时候在WeX5的cordova插件界面已经能够正常发现该 SMS插件
但是在最后编译的打包就会出现错误。
错误如下:
- D:\WeX5\WeX5_V3.5\model\Native\test\build\src\platforms\android\src\com\cordova\plugins\sms\Sms.java:56:错误: 找不到符号
- return cordova.hasPermission(android.Manifest.permission.SEND_SMS)
- ^
- 符号: 方法 hasPermission(String)
- 位置: 类型为CordovaInterface的变量 cordova
- D:\WeX5\WeX5_V3.5\model\Native\test\build\src\platforms\android\src\com\cordova\plugins\sms\Sms.java:60 错误: 找不到符号
- cordova.requestPermission(this, SEND_SMS_REQ_CODE, android.Manifest.permission.SEND_SMS)
- ^
- 符号: 方法 requestPermission(Sms,int,String)
- 位置: 类型为CordovaInterface的变量 cordova
- 注: 某些输入文件使用或覆盖了已过时的 API。
- 注: 有关详细信息, 请使用 -Xlint:deprecation 重新编译。
- 注: 某些输入文件使用了未经检查或不安全的操作。
- 注: 有关详细信息, 请使用 -Xlint:unchecked 重新编译。
- 2 个错误
-
- FAILURE: Build failed with an exception.
-
- * What went wrong:
- Execution failed for task ':compileDebugJavaWithJavac'.
- > Compilation failed; see the compiler error output for details.
-
- * Try:
- Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
- :compileDebugJavaWithJavac FAILED
-
- BUILD FAILED
-
- Total time: 12.874 secs
- ERROR building one of the platforms: Error: cmd: Command failed with exit code 1
- You may not have the required environment or OS to build this project
-
- D:\WeX5\WeX5_V3.5\model\Native\test\build\src\platforms\android\cordova\node_modules\q\q.js:126
- throw e;
- ^
- Error code 1 for command: cmd with args: /s /c "D:\WeX5\WeX5_V3.5\model\Native\test\build\src\platforms\android\gradlew cdvBuildDebug -b D:\WeX5\WeX5_V3.5\model\Native\test\build\src\platforms\android\build.gradle -Dorg.gradle.daemon=true --offline"
- Error: cmd: Command failed with exit code 1
- ****ERROR****: 子任务 "exec" 执行失败。
- ****ERROR****: 任务 "buildAndroid" 执行失败。
- ****ERROR****: 执行出错:
- ****ERROR****: 错误信息: exec returned: 1
- ****ERROR****: 如不能确定具体问题,可参考常见问题: http://bbs.wex5.com/thread-82002-1-1.html
复制代码
查看了github的issue list人家也谈及这个问题: https://github.com/cordova-sms/cordova-sms-plugin/issues?q=is%3Aissue+is%3Aclosed+sms+label%3A%22sms+undefined%22
不过人家说的是插件名字的问题,而我项目中的插件名字是按照WeX5的教程修改的。因此,我觉得不应该是这个原因造成的。
还有另外一种可能是版本的问题。https://github.com/cordova-sms/cordova-sms-plugin
引用github的FAQ:
sms is undefinedPlease go through all the closed issues about this subject. The issue is mostly coming from the way you installed the plugin, please double check everything before opening another issue. When building my project for android I get the following error: cannot find symbol: cordova.hasPermission(string)You need to update cordova-android to the latest version (recommended), or at least to the version 5.1.1. cordova platform update android or cordova platform update android@5.1.1
请问一下,我该如何才能在WeX5中正常使用这个插件呢?
|