This topic describes common issues and solutions for the Android SDK.
Q: Why do I see a "poor network connection" error when I log on to or register in the app?
A: Check the following items.
- Confirm that your phone's time is set correctly. An incorrect time can cause the security monitor to block your login attempt.
- Confirm that the security image is in the src/drawable directory. For more information, see Integrate a security image.
// Set the image suffix. ConfigManager.getInstance().setSecGuardImagePostfix("xxxx"); // xxxx is the suffix of the security image. - Check if any exceptions are thrown during initialization.
- You can ignore exceptions with ErrorCode=110.
- You can ignore the following warnings, which are used to check the social account SDK.
W/oa_Oauth: [] : Umeng is not available, Umeng Oauth Service Provider is disabled W/oa_Oauth: [] : Taobao MemberSDK is not available, Taobao 3rd Oauth Service Provider is disabled W/oa_Oauth: [] : Taobao login4android SDK is not available, Taobao 2nd Oauth Service Provider is disabled W/oa_Oauth: [] : Alipay sdk is not available, Alipay Oauth Service Provider is disabled - If you use the OALoginAdapter provided in the demo, you can ignore the following exception log.
java.lang.NullPointerException: Attempt to invoke virtual method 'long java.lang.Long.longValue()' on a null object reference at com.aliyun.iot.aep.sdk.login.oa.OALoginAdapter.a(OALoginAdapter.java:343)
Cannot open the logon page
A: Check the following items.
- Check if the following exception appears in the log.
init failed code = 10010 message = An error occurred. The message is null. Use LogCat to view details, or search for Failed resolution of: Lcom/ut/mini/UTHitBuilders@UTCustomHitBuilderThis error indicates that the main project is missing the UT SDK dependency. Add the following two dependencies to your main project, or download the SDK dependency files again from the platform.compile 'com.aliyun.ams:alicloud-android-utdid:1.1.5.4' compile 'com.aliyun.ams:alicloud-android-ut:5.1.0' - If the application crashes on startup and the log shows an XML-related error, check that the packageName in Manifest.xml is identical to the applicationID in build.gradle.
Q: Why does an ErrorCode=103 error occur during API channel SDK initialization?
A: Check logcat for an error log similar to the following.
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)
If this log appears, this error usually occurs because the .so file fails to load. Add the following configuration to the build.gradle file.
android {
compileSdkVersion 28
defaultConfig {
...
ndk {
abiFilters "arm64-v8a","armeabi-v7a" // For SDKs of API level 7 and later.
// abiFilters "armeabi", "x86" // For SDKs of API level 6 and earlier. Filters out .so files other than armeabi and x86.
}
}
}
Q: Why does an "app key or app secret must be initialed" error occur during API channel SDK initialization?
A: Check logcat for an error log similar to the following.
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
If this log appears, check the following items.
- Check for an error code 203 and investigate the possible causes.
- Check if the libsgmain.so file is packaged into the build/outputs/apk/debug directory of the APK package. Also, ensure that the lib/armeabi and lib/x86 folders contain this file.
Q: Why does an ErrorCode=202 error occur during API channel SDK initialization?
A: Check the logcat for an error similar to the following.
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)
If this log appears, this error usually occurs because the security image does not match the current APK signature. To resolve this issue, you can either modify the APK signature or upload the APK again to generate a new security image.
Q: Why does an ErrorCode=203 error occur during API channel SDK initialization?
A: Check logcat for an error log similar to the following.
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)
If this log appears, check the following items.
- The image file was not found. Ensure that the security image is in the res\drawable directory and that the last four digits of the security image name match the current authCode.
- In an Android environment, this can happen if resource optimization reduces the image file size to 0. Check the image in the APK.
- If obfuscation is enabled, check that the size of the 335 deployment package is not 0. Setting `shrinkResources` to `true` reduces the size of images that start with
yw_1222_to 0.release { minifyEnabled true // Enable obfuscation. shrinkResources true // This will reduce the security image size to 0. proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" }You can prevent this by disabling resource shrinking or by creating a res/raw/keep.xml file with the following content.
<?xml version="1.0" encoding="UTF-8"?> resources xmlns:tools="http://schemas.android.com/tools" tools:keep="@drawable/yw_1222_0335, @drawable/yw_1222,@drawable/yw_1222_china_production" - If you are debugging in Android Studio and the image cannot be found, but you have confirmed the image is correct, disable the Instant Run feature. In Instant Run, the APK is not a complete bundle because its resource files are split into specific bundles. This changes the image path and prevents the security component from finding the image.
- If obfuscation is enabled, check that the size of the 335 deployment package is not 0. Setting `shrinkResources` to `true` reduces the size of images that start with
Q: Why can't I initialize the logon SDK, with an error message that is null?
init failed code = 10010 message =
A: You can use LogCat to view more log details. This error can be caused by a missing SDK dependency. Add the following two dependencies to the main project's build.gradle file, or generate a new dependency.gradle file on the platform.
compile 'com.aliyun.ams:alicloud-android-utdid:1.1.5.4'
compile 'com.aliyun.ams:alicloud-android-ut:5.1.0'Q: Why does API Gateway return the following error when I access an API?
code:403, message:request forbidden, localizedMsg:Request forbidden
A: This error can occur if the project's AppKey does not have permission to access the API. To resolve this, submit a ticket from the console. In the ticket, provide your AppKey and the name of the API that you requested.
Q: Why do I see an "unsupported auth type iotAuth" error?
unsupported auth type iotAuth, maybe you forgot to register IoTAuthProvider
A: Refer to the SDK Initialization document to initialize the SDK. The initialization code for the IoTCredentialProviderImpl module must also be included in your application. To call an API, you must also add setAuthType("iotAuth").
Q: Why do I see a "poor network connection" or "cannot connect" error after I switch the demo app to the international site or replace the security image?
A: Follow these steps to resolve the issue.
- Set BuildConfig.BUILD_COUNTRY=OVERSEA.
- In the build.gradle file, change CHINA to OVERSEA
- In the demo app, change all instances of SINGAPORE to OVERSEA
- In the drawable directory, replace the security image with the one for the international site.
- Change
EnvConfigure.putEnvArg(RNContainerComponentDelegate.KEY_RN_CONTAINER_PLUGIN_ENV, "test");toEnvConfigure.putEnvArg(RNContainerComponentDelegate.KEY_RN_CONTAINER_PLUGIN_ENV, "release"); - RNContainerComponentDelegate.java file, change
BoneConfig.set("region", "china");toBoneConfig.set("region", "singapore"); - If you package the APK using the release.gradle file, change the security images in the src/oversea/res and /configure/oversea/ directories.
Q: Why do I see an error that libreactnativejni.so cannot be found?
A: Check logcat for the following message.
java.lang.UnsatisfiedLinkError: couldn't find DSO to load: libreactnativejni.so
at com.facebook.soloader.SoLoader.doLoadLibraryBySoName(SoLoader.java:738)
at com.facebook.soloader.SoLoader.loadLibraryBySoName(SoLoader.java:591)
at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:529)
at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:484)
at com.facebook.react.bridge.ReactBridge.staticInit(ReactBridge.java:31)
at com.facebook.react.bridge.NativeMap.<clinit>(NativeMap.java:19)
at com.facebook.react.jscexecutor.JSCExecutorFactory.create(JSCExecutorFactory.java:25)
at com.facebook.react.ReactInstanceManager$5.run(ReactInstanceManager.java:944)
at java.lang.Thread.run(Thread.java:764)
This error can occur if the CPU architecture is not supported. The armeabi and x86 architectures are no longer supported. You can resolve this issue by adding the following code.
android {
compileSdkVersion 28
defaultConfig {
...
ndk {
abiFilters "armeabi-v7a", "arm64-v8a" // Filter out armeabi and x86 .so files.
}
}
}