自有APP常见问题
更新时间:2020-06-30 15:31:55
IOS常见问题
Q:IOS自有APP初始化插件相关的SDK成功后,无法调用起来插件,返回失败,但是日志无任何报错信息
A:问题原因:IMSRouter取window的rooterViewController方法有问题,当客户同时有多个window的时候,会发生取不到window,从而打开不了插件的情况。
解决方案:默认的xcode工程会指定main.storyboard作为入口,系统此时会自动创建一个window,需要取消该入
口。
Q:用户退出登陆后,再次登陆,无法获取到新的token
A:请确保退出登录时,调用了退出登陆API。
// 引入头文件
#import <IMSAccount/IMSAccountService.h>
#import <ALBBOpenAccountCloud/ALBBOpenAccountSDK.h>
IMSAccountService *accountService = [IMSAccountService sharedService];
id<IMSAccountProtocol> protocol = accountService.sessionProvider;
[[NSNotificationCenter defaultCenter] postNotificationName:protocol.accountDidLogoutSuccessNotificationName object:nil];
// 退出登录
[[ALBBOpenAccountSession sharedInstance] logout];
Android常见问题
Q:API 通道 SDK 初始化的时候,出现ErrorCode=103错误
A:在logcat中可以看到类似如下的报错日志:
2-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 仅提供了 arm64-v8a, armeabi-v7a两种架构的so,所以,需要过滤其他类型的 so 文件,可以在 build.gradle 文件中添加如下配置:
android {
compileSdkVersion 26
defaultConfig {
...
ndk {
abiFilters "arm64-v8a","armeabi-v7a" //API level 7及以上版本的SDK
// abiFilters "armeabi", "x86" //API level 6以及低版本的SDK,过滤除 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
可能原因:
1、查看下是不是出现ErrorCode=203错误的可能原因导致的;
2、这个情况请检查libsgmain.so是否被打进apk内,要保证lib/armeabi和lib/x86文件夹内包含该文件
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:出现unsupported auth type iotAuth, maybe you forgot to register IoTAuthProvider报错
A:参看身份认证SDK文档初始化sdk,初始化IoTCredentialProviderImpl模块代码也放在application内,如需要主动调用接口注意要加.setAuthType("iotAuth")。
Q:安卓SDK支持的最低版本号是多少?
A:4.4.0
Q:安卓调用logout登出后,登录其他账号,获取到的identityid无变化
A:需要先执行 LoginBusiness.init,再执行IoTCredentialManageImpl.init(appKey),如果反过来,就会出现监听不到登录状态变化,无法刷新identityId
Q:安卓自有APP作为系统应用运行报java.lang.UnsatisfiedLinkError: dalvik.system.DexClassLoader 错误,自有APP在手机端安装运行是正常的
A: Androidmanifest.xm中加入配置: android: extractnativelibs=" false"libsgmainso-5.4.94.zip将带有版本号的so( libsgmainso-6.4.69.50)push到/ system/lib目录或者/ systen/app/应用部署文件夹/Iib/系统架构/目录
Q:初始化时出现code:10109 -- message:网络连接失败,请检查网络配置
A:如是Android 9或以上系统,则是网络请求限制问题,targetSdkVersion设置为27,或者networkSecurityConfig设置允许http请求 即可。
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:安卓自有APP SDK初始化报ErrorCode = 508 com.alibaba.wireless.security.open.SecException错误
日志打印如下:
01-07 14:53:24.204 24489-24560/com.example.hometest E/oa_security: [] : Sec Exception, the code = 508
ErrorCode = 508
com.alibaba.wireless.security.open.SecException:
at com.taobao.wireless.security.adapter.JNICLibrary.doCommandNative(Native Method)
at com.alibaba.wireless.security.mainplugin.a.doCommand(Unknown Source)
at com.alibaba.wireless.security.a.e.a.a(Unknown Source)
at com.alibaba.wireless.security.a.e.a.getString(Unknown Source)
at com.alibaba.sdk.android.openaccount.security.a.a.getValueFromDynamicDataStore(SecurityGuardWrapper.java:147)
at com.alibaba.sdk.android.openaccount.session.a.a.init(DefaultSessionManagerServiceImpl.java:77)
at java.lang.reflect.Method.invoke(Native Method)
at com.alibaba.sdk.android.pluto.runtime.BeanLoaderManager.load(BeanLoaderManager.java:107)
at com.alibaba.sdk.android.pluto.Pluto.init(Pluto.java:94)
at com.alibaba.sdk.android.openaccount.task.b.c(InitTask.java:226)
at com.alibaba.sdk.android.openaccount.task.b.run(InitTask.java:112)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:168)
at android.os.HandlerThread.run(HandlerThread.java:61)
A:该报错没有影响的,忽略即可。