开发者社区 > 物联网 > 正文

生活物联网Android SDK中 IoTSmart.init(this); 运行报错

#如何解决运行故障:SdkException: app key or app secret must be initialed

##移植生活物联网android sdk,添加安全图片后初始化 IoTSmart.init(this);运行报错。已确定包名,安全图片,集成SDK都是按文档描述进行。

##输出日志如下:

E/AndroidRuntime: FATAL EXCEPTION: main Process: com.aliyun, PID: 17075 java.lang.RuntimeException: Unable to create application com.aliyun.MyApplication: com.alibaba.cloudapi.sdk.exception.SdkException: app key or app secret must be initialed at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5364) at android.app.ActivityThread.-wrap2(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1528) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6077) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756) Caused by: com.alibaba.cloudapi.sdk.exception.SdkException: app key or app secret must be initialed at com.alibaba.cloudapi.sdk.model.BaseClientInitialParam.check(BaseClientInitialParam.java:20) at com.alibaba.cloudapi.sdk.model.HttpClientBuilderParams.check(HttpClientBuilderParams.java:31) at com.alibaba.cloudapi.sdk.client.HttpApiClient.init(HttpApiClient.java:64) at com.aliyun.iot.aep.sdk.apiclient.adapter.APIGatewayHttpAdapterImpl. (APIGatewayHttpAdapterImpl.java:144) at com.aliyun.iot.aep.sdk.apiclient.IoTAPIClientImpl.init(IoTAPIClientImpl.java:151) at com.aliyun.iot.aep.sdk.init.BaseSDKDelegate.a(SourceFile:130) at com.aliyun.iot.aep.sdk.init.BaseSDKDelegate.init(SourceFile:62) at com.aliyun.iot.aep.sdk.framework.sdk.SDKManager._initSdkDelegates(SourceFile:269) at com.aliyun.iot.aep.sdk.framework.sdk.SDKManager.a(SourceFile:103) at com.aliyun.iot.aep.sdk.framework.sdk.SDKManager.init_underUiThread(SourceFile:62) at com.aliyun.iot.aep.sdk.framework.sdk.SDKManager.init(SourceFile:54) at com.aliyun.iot.aep.sdk.IoTSmartImpl.init(SourceFile:88) at com.aliyun.iot.aep.sdk.IoTSmartImpl.init(SourceFile:53) at com.aliyun.iot.aep.sdk.IoTSmart.init(SourceFile:51) at com.aliyun.MyApplication.onCreate(MyApplication.java:9) at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1024) at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5361) at android.app.ActivityThread.-wrap2(ActivityThread.java)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1528)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:154)  at android.app.ActivityThread.main(ActivityThread.java:6077)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756) 

##android studio 调用代码为:

public class MyApplication extends AApplication {

@Override

public void onCreate() {

    super.onCreate();

    IoTSmart.init(this);

}

}

###完整输出日志:

8/04 16:58:08: Launching 'app' on Pixel 2 API 24. $ adb shell am start -n "com.aliyun/com.aliyun.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER Connected to process 17075 on device 'Pixel_2_API_24 [emulator-5554]'. Capturing and displaying logcat messages from application. This behavior can be disabled in the "Logcat output" section of the "Debugger" settings page. I/MultiDex: VM with version 2.1.0 has multidex support Installing application VM has multidex support, MultiDex support library is disabled. V/jni_log: JNI_OnLoad jvm:-1468858176 V/coap_jni: alcs_init start alcs_init end V/jni_log: onJniLoad start V/jni_log: onJniLoad ICAProbeListener onJniLoad end V/coap_jni: setLogLevelNative logLevel:4,static_log_level:2 I/art: Do partial code cache collection, code=14KB, data=31KB I/art: After code cache collection, code=14KB, data=31KB Increasing code cache capacity to 128KB W/System.err: ErrorCode = 110 com.alibaba.wireless.security.open.SecException: plugin main not existed at com.alibaba.wireless.security.framework.d.d(Unknown Source) at com.alibaba.wireless.security.framework.d.getPluginInfo(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.aliyun.iot.aep.sdk.init.BaseSDKDelegate.a(SourceFile:88) at com.aliyun.iot.aep.sdk.init.BaseSDKDelegate.init(SourceFile:62) at com.aliyun.iot.aep.sdk.framework.sdk.SDKManager._initSdkDelegates(SourceFile:269) at com.aliyun.iot.aep.sdk.framework.sdk.SDKManager.a(SourceFile:103) at com.aliyun.iot.aep.sdk.framework.sdk.SDKManager.init_underUiThread(SourceFile:62) at com.aliyun.iot.aep.sdk.framework.sdk.SDKManager.init(SourceFile:54) at com.aliyun.iot.aep.sdk.IoTSmartImpl.init(SourceFile:88) at com.aliyun.iot.aep.sdk.IoTSmartImpl.init(SourceFile:53) at com.aliyun.iot.aep.sdk.IoTSmart.init(SourceFile:51) at com.aliyun.MyApplication.onCreate(MyApplication.java:9) at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1024) at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5361) at android.app.ActivityThread.-wrap2(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1528) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6077) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756) E/APIGatewaySDKDelegate: security-sdk-initialize-failed EXCEPTION: null W/System.err: ErrorCode = 110 com.alibaba.wireless.security.jaq.JAQException at com.alibaba.wireless.security.jaq.SecurityInit.Initialize(Unknown Source) at com.aliyun.iot.aep.sdk.init.BaseSDKDelegate.a(SourceFile:88) at com.aliyun.iot.aep.sdk.init.BaseSDKDelegate.init(SourceFile:62) at com.aliyun.iot.aep.sdk.framework.sdk.SDKManager._initSdkDelegates(SourceFile:269) at com.aliyun.iot.aep.sdk.framework.sdk.SDKManager.a(SourceFile:103) at com.aliyun.iot.aep.sdk.framework.sdk.SDKManager.init_underUiThread(SourceFile:62) at com.aliyun.iot.aep.sdk.framework.sdk.SDKManager.init(SourceFile:54) at com.aliyun.iot.aep.sdk.IoTSmartImpl.init(SourceFile:88) at com.aliyun.iot.aep.sdk.IoTSmartImpl.init(SourceFile:53) at com.aliyun.iot.aep.sdk.IoTSmart.init(SourceFile:51) W/System.err: at com.aliyun.MyApplication.onCreate(MyApplication.java:9) at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1024) at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5361) at android.app.ActivityThread.-wrap2(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1528) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6077) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756) ErrorCode = 110 com.alibaba.wireless.security.open.SecException: plugin main not existed W/System.err: at com.alibaba.wireless.security.framework.d.d(Unknown Source) at com.alibaba.wireless.security.framework.d.getPluginInfo(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.open.SecurityGuardManager.getInstance(Unknown Source) at com.alibaba.wireless.security.open.SecurityGuardManager.getInstance(Unknown Source) at com.aliyun.iot.aep.sdk.apiclient.adapter.APIGatewayHttpAdapterImpl.getAppKey(APIGatewayHttpAdapterImpl.java:326) at com.aliyun.iot.aep.sdk.apiclient.IoTAPIClientImpl.init(IoTAPIClientImpl.java:147) at com.aliyun.iot.aep.sdk.init.BaseSDKDelegate.a(SourceFile:130) at com.aliyun.iot.aep.sdk.init.BaseSDKDelegate.init(SourceFile:62) at com.aliyun.iot.aep.sdk.framework.sdk.SDKManager._initSdkDelegates(SourceFile:269) at com.aliyun.iot.aep.sdk.framework.sdk.SDKManager.a(SourceFile:103) at com.aliyun.iot.aep.sdk.framework.sdk.SDKManager.init_underUiThread(SourceFile:62) at com.aliyun.iot.aep.sdk.framework.sdk.SDKManager.init(SourceFile:54) at com.aliyun.iot.aep.sdk.IoTSmartImpl.init(SourceFile:88) at com.aliyun.iot.aep.sdk.IoTSmartImpl.init(SourceFile:53) at com.aliyun.iot.aep.sdk.IoTSmart.init(SourceFile:51) at com.aliyun.MyApplication.onCreate(MyApplication.java:9) at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1024) at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5361) at android.app.ActivityThread.-wrap2(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1528) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6077) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756) D/APIGatewayImpl: xx default host:api.link.aliyun.com isDebugfalse D/AndroidRuntime: Shutting down VM E/AndroidRuntime: FATAL EXCEPTION: main Process: com.aliyun, PID: 17075 java.lang.RuntimeException: Unable to create application com.aliyun.MyApplication: com.alibaba.cloudapi.sdk.exception.SdkException: app key or app secret must be initialed at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5364) at android.app.ActivityThread.-wrap2(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1528) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6077) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756) Caused by: com.alibaba.cloudapi.sdk.exception.SdkException: app key or app secret must be initialed at com.alibaba.cloudapi.sdk.model.BaseClientInitialParam.check(BaseClientInitialParam.java:20) at com.alibaba.cloudapi.sdk.model.HttpClientBuilderParams.check(HttpClientBuilderParams.java:31) at com.alibaba.cloudapi.sdk.client.HttpApiClient.init(HttpApiClient.java:64) at com.aliyun.iot.aep.sdk.apiclient.adapter.APIGatewayHttpAdapterImpl. (APIGatewayHttpAdapterImpl.java:144) at com.aliyun.iot.aep.sdk.apiclient.IoTAPIClientImpl.init(IoTAPIClientImpl.java:151) at com.aliyun.iot.aep.sdk.init.BaseSDKDelegate.a(SourceFile:130) at com.aliyun.iot.aep.sdk.init.BaseSDKDelegate.init(SourceFile:62) at com.aliyun.iot.aep.sdk.framework.sdk.SDKManager._initSdkDelegates(SourceFile:269) at com.aliyun.iot.aep.sdk.framework.sdk.SDKManager.a(SourceFile:103) at com.aliyun.iot.aep.sdk.framework.sdk.SDKManager.init_underUiThread(SourceFile:62) at com.aliyun.iot.aep.sdk.framework.sdk.SDKManager.init(SourceFile:54) at com.aliyun.iot.aep.sdk.IoTSmartImpl.init(SourceFile:88) at com.aliyun.iot.aep.sdk.IoTSmartImpl.init(SourceFile:53) at com.aliyun.iot.aep.sdk.IoTSmart.init(SourceFile:51) at com.aliyun.MyApplication.onCreate(MyApplication.java:9) at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1024) at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5361) at android.app.ActivityThread.-wrap2(ActivityThread.java)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1528)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:154)  at android.app.ActivityThread.main(ActivityThread.java:6077)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)  I/art: Do partial code cache collection, code=56KB, data=62KB After code cache collection, code=56KB, data=62KB Increasing code cache capacity to 256KB

展开
收起
游客7x3cxmycz5tyu 2020-08-04 17:18:09 2093 0
1 条回答
写回答
取消 提交回答
  • 有没有解决问题的哦

    2021-03-22 14:15:55
    赞同 展开评论 打赏

物联网领域前沿技术分享与交流

相关产品

  • 物联网平台
  • 热门讨论

    热门文章

    相关电子书

    更多
    从 SDK 到编解码:视频直播架构解析 立即下载
    跨平台的云服务SDK需要什么 立即下载
    一个跨平台的云服务SDK需要什么 立即下载