#如何解决运行故障: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
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。