# Troubleshooting

This document compiles common issues you might encounter during Android integration, helping you troubleshoot effectively.

# How to Handle App Crashes After Enabling Code Obfuscation?

Add the following rules to your project's ProGuard configuration file proguard-rules.pro:

-keep class net.aihelp.** {*;}

# Why Does the SDK Display a Different Language Than Specified?

Normally, you can specify the SDK's display language through the last parameter of the init method. If not set, the SDK will initialize using the device language.

To ensure optimal user experience, AIHelp implements a language correction logic:

  1. We standardize different language codes. For example, zh / zh-cn / zh-CN / zh_CN / zh-hans are all converted to zh-CN for processing
  2. If the corrected language isn't enabled in the backend, it will be corrected to the default language set in the AIHelp backend

The AIHelp backend typically defaults to English as the fallback language. This default can be adjusted based on specific requirements.

Note that AIHelp API currently accepts ISO 639-1 language codes. Country codes should not be used during initialization, as some country codes might conflict with language codes. For example, 'KR' represents South Korea in country codes but refers to the Kanuri language in language codes.

If your project currently uses country codes, we recommend mapping ISO-3166 country codes to ISO 639-1 language codes before passing them to AIHelp.


# How to Handle Permissions for Image and Video Selection?

AIHelp handles all permission request logic internally. You only need to declare the relevant permissions in your manifest file.

For targetSdkVersion <= 32, simply configure storage permissions:

<uses-permission
    android:name="android.permission.READ_EXTERNAL_STORAGE"
    tools:node="replace" />
<uses-permission
    android:name="android.permission.WRITE_EXTERNAL_STORAGE"
    tools:node="replace" />

Note that tools:node="replace" is required to override declarations from other SDKs, ensuring your app's declarations take priority.

For targetSdkVersion >= 33, restrict storage permissions to API 32 and separately request media permissions for Android 13+:

<uses-permission
    android:name="android.permission.READ_EXTERNAL_STORAGE"
    android:maxSdkVersion="32"
    tools:node="replace" />

<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />

Both android:maxSdkVersion="32" and tools:node="replace" are required. Android 13 deprecated storage permissions, requiring API limitation to 32 and new media permissions.


# Why Do Some Devices Show Permission Errors Without Settings Options?

This issue occurs on Android 13 devices when using AIHelp versions below v4.3.6 with targetSdkVersion >= 33, due to deprecated storage permissions.

Solutions:

  1. Upgrade to AIHelp v4.3.6 or later, or

  2. Restrict storage permissions to API 32:

<uses-permission
    android:name="android.permission.READ_EXTERNAL_STORAGE"
    android:maxSdkVersion="32"
    tools:node="replace" />

If issues persist, check WRITE_EXTERNAL_STORAGE permission:

<uses-permission
    android:name="android.permission.WRITE_EXTERNAL_STORAGE"
    android:maxSdkVersion="32"
    tools:node="replace" />

Note: If your app doesn't require storage permissions, you can use remove instead of replace to forcibly remove these permissions.


# Why Does Player Information Show as 'anonymous' with Random Characters?

By default, before calling the updateUserInfo API, AIHelp uses 'anonymous' as the username and 'deviceId' as the user ID.

UID information isn't synchronized with the backend until the AIHelp page opens. Since UID is stored in memory, sessions work correctly if UID is available before page opening.

If information isn't showing in the backend, the API likely wasn't called effectively.

This might be due to timing - the API must be called after initialization:

AIHelpSupport.init(/* your code here */);
AIHelpSupport.updateUserInfo(/* your code here */);

The updateUserInfo call only needs to follow init; successful initialization isn't required.

If user information updates occur before initialization, they might fail. Consider updating just before opening the page.


# Does AIHelp Have Non-AndroidX Versions?

While AIHelp Android SDK is AndroidX-based, two Support version AAR packages are available:

Support versions require manual AAR integration with these dependencies:

implementation 'com.android.support:support-v4:28.0.0' 
implementation 'com.android.support:appcompat-v7:28.0.0' 
implementation 'com.android.support:design:28.0.0' 
implementation 'com.android.support:recyclerview-v7:28.0.0' 
implementation 'com.android.support:viewpager:28.0.0' 
implementation 'com.android.support:swiperefreshlayout:28.0.0' 
implementation 'com.squareup.okhttp3:okhttp:3.12.13'

# Can AIHelp Be Integrated Offline on Android?

All AIHelp AAR versions are available in the maven repository (opens new window).

For offline integration, you'll need to download both the AAR and its dependencies (opens new window):

implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation 'androidx.viewpager2:viewpager2:1.0.0'
implementation 'com.squareup.okhttp3:okhttp:3.12.13'
Last Updated: 11/30/2024, 11:18:33 AM