jsms@1.1.5版本

jsms
标签: #<Tag:0x00007fb83cfba490>

(Laijuncheng) #1

安卓无法执行代码,iOS正常

  window.jsms.getSmsCode(function (uuid) {
    console.log(uuid)
  }, function (errorCode) {
    console.log(errorCode)
  },phonenum, '1')

(12) #2

你这是用的插件吗?什么插件?

提供一下客户端日志信息


(Laijuncheng) #3

这个忘记说了cordova-plugin-jsms@1.1.5


(Josh Lipan) #4

打开配置文件plugin.xml,将箭头指向的jsms改成cordova/sms,再重新add到项目里试试:


(Laijuncheng) #5
06-25 17:29:55.571 20215-20384/com.gxgh.yuejuguihai W/IInputConnectionWrapper: beginBatchEdit on inactive InputConnection
06-25 17:29:55.572 20215-20384/com.gxgh.yuejuguihai W/IInputConnectionWrapper: getTextBeforeCursor on inactive InputConnection
06-25 17:29:55.573 20215-20384/com.gxgh.yuejuguihai W/IInputConnectionWrapper: endBatchEdit on inactive InputConnection
06-25 17:30:04.989 20215-20462/com.gxgh.yuejuguihai W/System.err: java.lang.ClassNotFoundException: cn.jiguang.cordova.sms.JSMSPlugin
06-25 17:30:04.989 20215-20462/com.gxgh.yuejuguihai W/System.err:     at java.lang.Class.classForName(Native Method)
06-25 17:30:04.989 20215-20462/com.gxgh.yuejuguihai W/System.err:     at java.lang.Class.forName(Class.java:400)
06-25 17:30:04.989 20215-20462/com.gxgh.yuejuguihai W/System.err:     at java.lang.Class.forName(Class.java:326)
06-25 17:30:04.989 20215-20462/com.gxgh.yuejuguihai W/System.err:     at org.apache.cordova.PluginManager.instantiatePlugin(PluginManager.java:489)
06-25 17:30:04.989 20215-20462/com.gxgh.yuejuguihai W/System.err:     at org.apache.cordova.PluginManager.getPlugin(PluginManager.java:169)
06-25 17:30:04.990 20215-20462/com.gxgh.yuejuguihai W/System.err:     at org.apache.cordova.PluginManager.exec(PluginManager.java:122)
06-25 17:30:04.990 20215-20462/com.gxgh.yuejuguihai W/System.err:     at org.apache.cordova.CordovaBridge.jsExec(CordovaBridge.java:57)
06-25 17:30:04.990 20215-20462/com.gxgh.yuejuguihai W/System.err:     at org.apache.cordova.engine.SystemExposedJsApi.exec(SystemExposedJsApi.java:41)
06-25 17:30:04.990 20215-20462/com.gxgh.yuejuguihai W/System.err:     at org.chromium.base.SystemMessageHandler.nativeDoRunLoopOnce(Native Method)
06-25 17:30:04.990 20215-20462/com.gxgh.yuejuguihai W/System.err:     at org.chromium.base.SystemMessageHandler.handleMessage(SystemMessageHandler.java:41)
06-25 17:30:04.990 20215-20462/com.gxgh.yuejuguihai W/System.err:     at android.os.Handler.dispatchMessage(Handler.java:102)
06-25 17:30:04.990 20215-20462/com.gxgh.yuejuguihai W/System.err:     at android.os.Looper.loop(Looper.java:185)
06-25 17:30:04.990 20215-20462/com.gxgh.yuejuguihai W/System.err:     at android.os.HandlerThread.run(HandlerThread.java:61)
06-25 17:30:04.990 20215-20462/com.gxgh.yuejuguihai W/System.err: Caused by: java.lang.ClassNotFoundException: Didn't find class "cn.jiguang.cordova.sms.JSMSPlugin" on path: DexPathList[[zip file "/data/app/com.gxgh.yuejuguihai-1/base.apk"],nativeLibraryDirectories=[/data/app/com.gxgh.yuejuguihai-1/lib/arm64, /data/app/com.gxgh.yuejuguihai-1/base.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64]]
06-25 17:30:04.990 20215-20462/com.gxgh.yuejuguihai W/System.err:     at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
06-25 17:30:04.990 20215-20462/com.gxgh.yuejuguihai W/System.err:     at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
06-25 17:30:04.990 20215-20462/com.gxgh.yuejuguihai W/System.err:     at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
06-25 17:30:04.990 20215-20462/com.gxgh.yuejuguihai W/System.err: 	... 13 more
06-25 17:30:04.990 20215-20462/com.gxgh.yuejuguihai I/System.out: Error adding plugin cn.jiguang.cordova.sms.JSMSPlugin.
06-25 17:30:04.991 20215-20462/com.gxgh.yuejuguihai W/System.err: java.lang.NullPointerException: Attempt to invoke virtual method 'void org.apache.cordova.CordovaPlugin.privateInitialize(java.lang.String, org.apache.cordova.CordovaInterface, org.apache.cordova.CordovaWebView, org.apache.cordova.CordovaPreferences)' on a null object reference
06-25 17:30:04.991 20215-20462/com.gxgh.yuejuguihai W/System.err:     at org.apache.cordova.PluginManager.getPlugin(PluginManager.java:171)
06-25 17:30:04.991 20215-20462/com.gxgh.yuejuguihai W/System.err:     at org.apache.cordova.PluginManager.exec(PluginManager.java:122)
06-25 17:30:04.991 20215-20462/com.gxgh.yuejuguihai W/System.err:     at org.apache.cordova.CordovaBridge.jsExec(CordovaBridge.java:57)
06-25 17:30:04.991 20215-20215/com.gxgh.yuejuguihai D/SystemWebChromeClient: file:///android_asset/www/js/utility.js: Line 728 : true
06-25 17:30:04.991 20215-20462/com.gxgh.yuejuguihai W/System.err:     at org.apache.cordova.engine.SystemExposedJsApi.exec(SystemExposedJsApi.java:41)
06-25 17:30:04.991 20215-20462/com.gxgh.yuejuguihai W/System.err:     at org.chromium.base.SystemMessageHandler.nativeDoRunLoopOnce(Native Method)
06-25 17:30:04.991 20215-20462/com.gxgh.yuejuguihai W/System.err:     at org.chromium.base.SystemMessageHandler.handleMessage(SystemMessageHandler.java:41)
06-25 17:30:04.991 20215-20462/com.gxgh.yuejuguihai W/System.err:     at android.os.Handler.dispatchMessage(Handler.java:102)

(Josh Lipan) #6

老版本配置路径问题,插件配置文件中这两个位置要对应,需要你自己手动修改下:


(Laijuncheng) #7

上下都要改成cn/jiguang/cordova/sms对吗?还有,这样是不是得在Git下载zip包,本地修改,然后再add


(Laijuncheng) #8
:compileDebugJavaWithJavac/Users/Wilon/Desktop/myappName/platforms/android/src/cn/jiguang/jsms/JSMSPlugin.java:22: 错误: 类重复: cn.jiguang.jsms.JSMSPlugin
public class JSMSPlugin extends CordovaPlugin {
       ^
注: 某些输入文件使用或覆盖了已过时的 API。
注: 有关详细信息, 请使用 -Xlint:deprecation 重新编译。
注: 某些输入文件使用了未经检查或不安全的操作。
注: 有关详细信息, 请使用 -Xlint:unchecked 重新编译。
1 个错误
 FAILED

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.

* Get more help at https://help.gradle.org

BUILD FAILED in 5s
38 actionable tasks: 36 executed, 2 up-to-date
(node:38817) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: /Users/Wilon/Desktop/myappName/platforms/android/gradlew: Command failed with exitcode 1 Error output:
注: 某些输入文件使用或覆盖了已过时的 API。
注: 有关详细信息, 请使用 -Xlint:deprecation 重新编译。
/Users/Wilon/Desktop/myappName/platforms/android/src/cn/jiguang/jsms/JSMSPlugin.java:22: 错误: 类重复: cn.jiguang.jsms.JSMSPlugin
public class JSMSPlugin extends CordovaPlugin {
       ^
注: 某些输入文件使用或覆盖了已过时的 API。
注: 有关详细信息, 请使用 -Xlint:deprecation 重新编译。
注: 某些输入文件使用了未经检查或不安全的操作。
注: 有关详细信息, 请使用 -Xlint:unchecked 重新编译。
1 个错误

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.

* Get more help at https://help.gradle.org

BUILD FAILED in 5s
(node:38817) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

(12) #9

Android 工程里面找到这个包名下的这个类删除,重复了


(Laijuncheng) #10


06-26 10:50:14.902 10028-10154/com.gxgh.yuejuguihai W/System.err: java.lang.ClassNotFoundException: cn.jiguang.cordova.sms.JSMSPlugin
06-26 10:50:14.903 10028-10154/com.gxgh.yuejuguihai W/System.err:     at java.lang.Class.classForName(Native Method)
06-26 10:50:14.903 10028-10154/com.gxgh.yuejuguihai W/System.err:     at java.lang.Class.forName(Class.java:400)
06-26 10:50:14.903 10028-10154/com.gxgh.yuejuguihai W/System.err:     at java.lang.Class.forName(Class.java:326)
06-26 10:50:14.903 10028-10154/com.gxgh.yuejuguihai W/System.err:     at org.apache.cordova.PluginManager.instantiatePlugin(PluginManager.java:489)
06-26 10:50:14.903 10028-10154/com.gxgh.yuejuguihai W/System.err:     at org.apache.cordova.PluginManager.getPlugin(PluginManager.java:169)
06-26 10:50:14.903 10028-10154/com.gxgh.yuejuguihai W/System.err:     at org.apache.cordova.PluginManager.exec(PluginManager.java:122)
06-26 10:50:14.903 10028-10154/com.gxgh.yuejuguihai W/System.err:     at org.apache.cordova.CordovaBridge.jsExec(CordovaBridge.java:57)
06-26 10:50:14.903 10028-10154/com.gxgh.yuejuguihai W/System.err:     at org.apache.cordova.engine.SystemExposedJsApi.exec(SystemExposedJsApi.java:41)
06-26 10:50:14.903 10028-10154/com.gxgh.yuejuguihai W/System.err:     at org.chromium.base.SystemMessageHandler.nativeDoRunLoopOnce(Native Method)
06-26 10:50:14.903 10028-10154/com.gxgh.yuejuguihai W/System.err:     at org.chromium.base.SystemMessageHandler.handleMessage(SystemMessageHandler.java:41)
06-26 10:50:14.903 10028-10154/com.gxgh.yuejuguihai W/System.err:     at android.os.Handler.dispatchMessage(Handler.java:102)
06-26 10:50:14.903 10028-10154/com.gxgh.yuejuguihai W/System.err:     at android.os.Looper.loop(Looper.java:185)
06-26 10:50:14.903 10028-10154/com.gxgh.yuejuguihai W/System.err:     at android.os.HandlerThread.run(HandlerThread.java:61)
06-26 10:50:14.903 10028-10154/com.gxgh.yuejuguihai W/System.err: Caused by: java.lang.ClassNotFoundException: Didn't find class "cn.jiguang.cordova.sms.JSMSPlugin" on path: DexPathList[[zip file "/data/app/com.gxgh.yuejuguihai-1/base.apk"],nativeLibraryDirectories=[/data/app/com.gxgh.yuejuguihai-1/lib/arm64, /data/app/com.gxgh.yuejuguihai-1/base.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64]]
06-26 10:50:14.904 10028-10154/com.gxgh.yuejuguihai W/System.err:     at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
06-26 10:50:14.904 10028-10154/com.gxgh.yuejuguihai W/System.err:     at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
06-26 10:50:14.904 10028-10154/com.gxgh.yuejuguihai W/System.err:     at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
06-26 10:50:14.904 10028-10154/com.gxgh.yuejuguihai W/System.err: 	... 13 more

(Laijuncheng) #11

插件下载到本地,先修改了路径,再add到项目中,然后项目中的Android工程,从路径上看,的确正确添加插件了,但是cordova build android后导出的apk,路径还是错误的,并且运行apk出现跟昨天一样的错误


(Laijuncheng) #12

请问是什么原因?


(Josh Lipan) #14

用AS打开工程,尝试Clean或者rebuild一下


(Laijuncheng) #16

并不行,还是找不到JSMSPlugin的错误


(Laijuncheng) #17

还是无法找到JSMSPlugin


(Josh Lipan) #19

你对应的cordova-android版本是多少


(Laijuncheng) #21

Android版本是 6.4.0


(Laijuncheng) #22

找到原因了吗?这个BUG我这边还挺急的,而且我因为有些插件不支持Android7.0,所以没办法下载最新的cordova-plugin-jsms


(Josh Lipan) #23

打开已经集成到工程中的JSMSPlugin.java,修改包名导入为package cn.jiguang.cordova.sms;


(Laijuncheng) #24

十分感谢,解决了