常见问题 FAQ

更新时间:2019-06-26 15:17:22

Q:API 通道 SDK 初始化的时候,出现ErrorCode=103错误
A:在logcat中可以看到类似如下的报错日志:

12-16 16:26:11.430 10486-10486/? W/System.err: ErrorCode = 103
12-16 16:26:11.430 10486-10486/? W/System.err: com.alibaba.wireless.security.open.SecException: java.lang.UnsatisfiedLinkError: dlopen failed: "/data/data/com.aliyun.iot.demo.wuxi.demoapp/app_SGLib/app_1513412765/libsgmainso-5.3.38.so" is 32-bit instead of 64-bit
12-16 16:26:11.430 10486-10486/? W/System.err:     at com.alibaba.wireless.security.mainplugin.SecurityGuardMainPlugin.onPluginLoaded(Unknown Source)
12-16 16:26:11.430 10486-10486/? W/System.err:     at com.alibaba.wireless.security.framework.e.a(Unknown Source)
12-16 16:26:11.430 10486-10486/? W/System.err:     at com.alibaba.wireless.security.framework.e.c(Unknown Source)
12-16 16:26:11.431 10486-10486/? W/System.err:     at com.alibaba.wireless.security.framework.e.c(Unknown Source)
12-16 16:26:11.431 10486-10486/? W/System.err:     at com.alibaba.wireless.security.open.initialize.b.a(Unknown Source)
12-16 16:26:11.431 10486-10486/? W/System.err:     at com.alibaba.wireless.security.open.initialize.a.loadLibrarySync(Unknown Source)
12-16 16:26:11.431 10486-10486/? W/System.err:     at com.alibaba.wireless.security.open.initialize.a.initialize(Unknown Source)
12-16 16:26:11.431 10486-10486/? W/System.err:     at com.alibaba.wireless.security.jaq.SecurityInit.Initialize(Unknown Source)
12-16 16:26:11.431 10486-10486/? W/System.err:     at com.aliyun.iot.demo.wuxi.demoapp.DemoApplication.onCreate(DemoApplication.java:34)
12-16 16:26:11.431 10486-10486/? W/System.err:     at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1025)
12-16 16:26:11.431 10486-10486/? W/System.err:     at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5403)
12-16 16:26:11.431 10486-10486/? W/System.err:     at android.app.ActivityThread.-wrap2(ActivityThread.java)
12-16 16:26:11.431 10486-10486/? W/System.err:     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1545)
12-16 16:26:11.431 10486-10486/? W/System.err:     at android.os.Handler.dispatchMessage(Handler.java:102)
12-16 16:26:11.431 10486-10486/? W/System.err:     at android.os.Looper.loop(Looper.java:154)
12-16 16:26:11.431 10486-10486/? W/System.err:     at android.app.ActivityThread.main(ActivityThread.java:6119)
12-16 16:26:11.431 10486-10486/? W/System.err:     at java.lang.reflect.Method.invoke(Native Method)
12-16 16:26:11.431 10486-10486/? W/System.err:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
12-16 16:26:11.431 10486-10486/? W/System.err:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)

这种情形一般是 so 文件加载失败导致的,因为我们的 SDK 仅提供了 armeabi, x86 两种架构的so,所以,需要过滤其他类型的 so 文件,可以在 build.gradle 文件中添加如下配置:

android {
    compileSdkVersion 26
    defaultConfig {

        ...

        ndk {
            abiFilters "armeabi", "x86"//过滤除 armeabi 和 x86 以外的 so 文件
        }
    }
}

Q:API 通道 SDK 初始化的时候,出现app key or app secret must be initialed错误
A:在logcat中可以看到类似如下的报错日志:

10-22 03:03:37.555 18552-18552/? E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.rnd.kx, PID: 18552
    java.lang.RuntimeException: Unable to create application com.rnd.kx.MyApplication: com.alibaba.cloudapi.sdk.exception.SdkException: app key or app secret must be initialed
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4710)
        at android.app.ActivityThread.-wrap1(ActivityThread.java)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1405)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:148)
        at android.app.ActivityThread.main(ActivityThread.java:5417)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
     Caused by: com.alibaba.cloudapi.sdk.exception.SdkException: app key or app secret must be initialed

这个情况请检查libsgmain.so是否被打进apk内,要保证lib/armeabi和lib/x86文件夹内包含该文件

Q:API 通道 SDK 初始化的时候,出现ErrorCode=202错误
A:在logcat中可以看到类似如下的报错日志:

12-16 13:19:06.586 9344-9344/com.aliyun.iot.demo W/System.err: ErrorCode = 202
12-16 13:19:06.587 9344-9344/com.aliyun.iot.demo W/System.err: com.alibaba.wireless.security.open.SecException:
12-16 13:19:06.594 9344-9344/com.aliyun.iot.demo W/System.err:     at com.taobao.wireless.security.adapter.JNICLibrary.doCommandNative(Native Method)
12-16 13:19:06.595 9344-9344/com.aliyun.iot.demo W/System.err:     at com.alibaba.wireless.security.mainplugin.a.doCommand(Unknown Source:0)
12-16 13:19:06.595 9344-9344/com.aliyun.iot.demo W/System.err:     at com.alibaba.wireless.security.a.j.a.getAppKeyByIndex(Unknown Source:21)
12-16 13:19:06.596 9344-9344/com.aliyun.iot.demo W/System.err:     at com.alibaba.sdk.android.push.securitybox.alipush.a.getAppKey(Unknown Source:7)
12-16 13:19:06.597 9344-9344/com.aliyun.iot.demo W/System.err:     at com.alibaba.sdk.android.push.vip.AppRegister.h(Unknown Source:17)
12-16 13:19:06.597 9344-9344/com.aliyun.iot.demo W/System.err:     at com.alibaba.sdk.android.push.vip.AppRegister.a(Unknown Source:34)
12-16 13:19:06.597 9344-9344/com.aliyun.iot.demo W/System.err:     at com.alibaba.sdk.android.push.impl.j.a(Unknown Source:30)
12-16 13:19:06.597 9344-9344/com.aliyun.iot.demo W/System.err:     at com.alibaba.sdk.android.push.impl.j.register(Unknown Source:1)
12-16 13:19:06.599 9344-9344/com.aliyun.iot.demo W/System.err:     at com.aliyun.iot.aep.demo.DemoApplication.initPush(DemoApplication.java:115)
12-16 13:19:06.599 9344-9344/com.aliyun.iot.demo W/System.err:     at com.aliyun.iot.aep.demo.DemoApplication.onCreate(DemoApplication.java:27)
12-16 13:19:06.599 9344-9344/com.aliyun.iot.demo W/System.err:     at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1118)
12-16 13:19:06.599 9344-9344/com.aliyun.iot.demo W/System.err:     at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5791)
12-16 13:19:06.599 9344-9344/com.aliyun.iot.demo W/System.err:     at android.app.ActivityThread.-wrap1(Unknown Source:0)
12-16 13:19:06.601 9344-9344/com.aliyun.iot.demo W/System.err:     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1661)
12-16 13:19:06.601 9344-9344/com.aliyun.iot.demo W/System.err:     at android.os.Handler.dispatchMessage(Handler.java:105)
12-16 13:19:06.601 9344-9344/com.aliyun.iot.demo W/System.err:     at android.os.Looper.loop(Looper.java:164)
12-16 13:19:06.601 9344-9344/com.aliyun.iot.demo W/System.err:     at android.app.ActivityThread.main(ActivityThread.java:6541)
12-16 13:19:06.601 9344-9344/com.aliyun.iot.demo W/System.err:     at java.lang.reflect.Method.invoke(Native Method)
12-16 13:19:06.604 9344-9344/com.aliyun.iot.demo W/System.err:     at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
12-16 13:19:06.604 9344-9344/com.aliyun.iot.demo W/System.err:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)

这种情形一般是安全图片与当前 apk 的签名不匹配导致的,可以考虑修改当前 apk 签名或者重新上传 apk 生成新的安全图片

Q:API 通道 SDK 初始化的时候,出现ErrorCode=203错误
A:在logcat中可以看到类似如下的报错日志:

12-16 13:29:59.005 10232-10267/? W/System.err: ErrorCode = 203
12-16 13:29:59.005 10232-10267/? W/System.err: com.alibaba.wireless.security.open.SecException:
12-16 13:29:59.005 10232-10267/? W/System.err:     at com.taobao.wireless.security.adapter.JNICLibrary.doCommandNative(Native Method)
12-16 13:29:59.005 10232-10267/? W/System.err:     at com.alibaba.wireless.security.mainplugin.a.doCommand(Unknown Source:0)
12-16 13:29:59.005 10232-10267/? W/System.err:     at com.alibaba.wireless.security.a.j.a.getAppKeyByIndex(Unknown Source:21)
12-16 13:29:59.005 10232-10267/? W/System.err:     at com.alibaba.sdk.android.push.securitybox.alipush.a.getAppKey(Unknown Source:7)
12-16 13:29:59.005 10232-10267/? W/System.err:     at com.alibaba.sdk.android.push.securitybox.alipush.a.a(Unknown Source:8)
12-16 13:29:59.005 10232-10267/? W/System.err:     at com.alibaba.sdk.android.push.securitybox.alipush.a.getMpsDeviceId(Unknown Source:2)
12-16 13:29:59.005 10232-10267/? W/System.err:     at com.alibaba.sdk.android.push.vip.AppRegister$a.b(Unknown Source:68)
12-16 13:29:59.005 10232-10267/? W/System.err:     at com.alibaba.sdk.android.push.vip.AppRegister$a.a(Unknown Source:0)
12-16 13:29:59.006 10232-10267/? W/System.err:     at com.alibaba.sdk.android.push.vip.b.handleMessage(Unknown Source:54)
12-16 13:29:59.006 10232-10267/? W/System.err:     at android.os.Handler.dispatchMessage(Handler.java:105)
12-16 13:29:59.006 10232-10267/? W/System.err:     at android.os.Looper.loop(Looper.java:164)
12-16 13:29:59.006 10232-10267/? W/System.err:     at android.os.HandlerThread.run(HandlerThread.java:65)

可能的原因如下:
1、没有找到图片文件,请确保安全图片在res\drawable目录下,并检查安全图片的名称的末四位和当前 authCode 是否一致(authCode 默认为 114d);
2、安卓环境下可能是因为资源优化被优化成了0,请检查APK中的图片,解决方法见下图
3、如果是在android studio下调试发现找不到图片,但是确认过图片是正常的,请关闭Android studio的 instant run功能,在instant run下apk并非一个完整bundle,其资源文件被拆分到特定bundle中,图片路径发生改变会导致保镖找不到图片。

Q: 执行登录或者注册时,提示“亲,您的手机网络不太顺畅哦~”
A:可能原因如下:

  1. 安全图片是否存在(参考上面ErrorCode=202的情况),登录SDK初始化是否抛出异常
  2. 如果有ErrorCode=110的异常码,请忽略

    10-22 03:03:37.543 18552-18552/? W/System.err: ErrorCode = 110
     com.alibaba.wireless.security.open.SecException: plugin main not existed
         at com.alibaba.wireless.security.framework.e.c(Unknown Source)
         at com.alibaba.wireless.security.framework.e.c(Unknown Source)
         at com.alibaba.wireless.security.open.initialize.b.a(Unknown Source)
         at com.alibaba.wireless.security.open.initialize.a.loadLibrarySync(Unknown Source)
         at com.alibaba.wireless.security.open.initialize.a.initialize(Unknown Source)
         at com.alibaba.wireless.security.jaq.SecurityInit.Initialize(Unknown Source)
         at com.rnd.kx.iot.sdk.base.delegate.page.APIGatewaySDKDelegate.init(APIGatewaySDKDelegate.java:47)
         at com.rnd.kx.ApplicationHelper._initBaseSdk(ApplicationHelper.java:61)
         at com.rnd.kx.ApplicationHelper.init(ApplicationHelper.java:37)
         at com.rnd.kx.ApplicationHelper.onCreate(ApplicationHelper.java:30)
         at com.rnd.kx.MyApplication.onCreate(MyApplication.java:118)
         at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1013)
    
  3. 确认登录环境是否设置正确(大陆环境还是海外环境):在初始化OpenAccount时,是否调用了如下API:ConfigManager.getInstance().setApiGatewayHost(host);

 如果您的登录环境为大陆环境,无需调用此API,如果是海外,请根据文档设置对应的HOST

Q:无法正常初始化登录SDK,提示init failed code = 10010 message = 发生错误,消息为 null, 请使用 LogCat 查看更多细节
A:原因如下:

  1. 缺少SDK依赖,请在主工程的build.gradle中添加以下2个依赖,或者在平台上重新生成一份dependency.gradle文件
compile 'com.aliyun.ams:alicloud-android-utdid:1.1.5.4'
compile 'com.aliyun.ams:alicloud-android-ut:5.1.0'

Q:访问API时,API网关报错:code:403, message:request forbidden, localizedMsg:请求被禁止
A:原因如下:
该项目APPKEY没有访问API的权限,请提工单,备注APPKEY以及请求API的名称

Q:出现unsupported auth type iotAuth, maybe you forgot to register IoTAuthProvider报错
A:参看身份认证SDK文档初始化sdk,初始化IoTCredentialProviderImpl模块代码也放在application内,如需要主动调用接口注意要加.setAuthType("iotAuth")。

results matching ""

    No results matching ""