Android

How to resolve the issue that Application Binary Interface (ABI) mismatches between the base and mywebdynamicfeature modules?

This error occurs because the base module supports ARM64_V8A and ARMEABI_V7A, whereas mywebdynamicfeature also includes ARMEABI. The error message is as follows:

copy
All modules with native libraries must support the same set of ABIs, but module 'base' supports '[ARM64_V8A, ARMEABI_V7A]' and module 'mywebdynamicfeature' supports '[ARM64_V8A, ARMEABI_V7A, ARMEABI]'.

However, Android enforces ABI consistency across all modules with native libraries. To resolve mismatches, update the base module's build.gradle file to add an abiFilters block under ndk to specify the allowed ABIs as follows:

copy
android {
    ...

    defaultConfig {
        ...

        //Explicitly list allowed ABIs
        ndk {
            abiFilters 'arm64-v8a', 'armeabi-v7a'
        }
    }

}

How to resolve the lib/arm64-v8a/libc++_shared.so conflict between the base and mywebdynamicfeature modules?

This error occurs because the base and mywebdynamicfeature modules include different versions of lib/arm64-v8a/libc++_shared.so. The Android build system blocks APK merging to prevent runtime instability from conflicting native libraries. The error message is as follows:

copy
Modules 'base' and 'mywebdynamicfeature' contain entry 'lib/arm64-v8a/libc++_shared.so' with different content.

To resolve the conflict, replace the .so file in the mywebdynamicfeature module with the version from the base module to ensure that both modules use the same .so file. Follow these steps:

  1. Extract the .so file from the base module

Build your APK. Use Android Studio's APK Analyzer (right-click the APK and select Analyze APK) to locate libc++_shared.so in the base module. Then, export this file to your computer.

  1. Add the .so file to the mywebdynamicfeature module

Create the directory: mywebdynamicfeature/libs/arm64-v8a/. Then, copy the extracted libc++_shared.so into this directory. An example directory structure is as follows:

image.png

  1. Update the mywebdynamicfeature build.gradle file

Add the following configurations:

    • pickFirst: Configure this to resolve the duplicate .so conflict by selecting the appropriate version for the build.
    • sourceSets: Configure this to include the libs directory with the .so file.

Refer to the following code sample for details:

copy
android {
    ...

    // Resolve the duplicate .so conflict
    packagingOptions {
        pickFirst 'lib/arm64-v8a/libc++_shared.so'
    }
    
    // Include the lib directory containing the .so file
    sourceSets {
        main {
            jniLibs.srcDirs = ['libs']
        }
    }
}
dependencies {
    implementation project(":app")
    implementation "com.alipay.plus.android:iapminiprogram-myweb:${iapminiprogram_version}"
}

Note: Avoid using exclude in mywebdynamicfeature's build.gradle to remove the .so file. Excluding it causes MYWeb to fail at runtime. The following code sample shows an incorrect configuration:

copy
// Do not do this
packagingOptions {
    exclude 'lib/arm64-v8a/libc++_shared.so'
}

How to solve the problem of error page when jumping to third-party apps on Android side?

The WebView supports HTTP and HTTPs protocols by default. But WebView does not have built-in processing methods for other custom URL protocols (such as mailto, tel, sms, etc.). If your WebView needs to process URLs with these non-standard protocols, you need to handle them by yourself in the shouldOverrideUrlLoading method of your WebViewClient. The processing code in onStartUrlNavigation is as follows:

copy
else if (url.startsWith("snssdk")) {
    // Using Intent to handle custom schemes
    try {
        Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
        page.getPageContext().getActivity().startActivity(intent);
    } catch (ActivityNotFoundException e) {
        // No application that can handle the scheme is found, so error handling is performed or a prompt is given to the user.
    }
    return true; // Returns true, indicating that the URL has been processed
}

How to solve the problem that Android phone cannot obtain location through my.getLocation JSAPI?

You can solve the problem by adding the cacheTimeout property when using the my.getLocation JSAPI.

The code is as follows, where 15s is configured:

copy
my.getLocation({
  cacheTimeout: 15,
  success(res) {
    
  },
  fail(err) {
  
  },
});

How to solve the problem of SSL error: null pop-up window when loading web page on Android client?

The reason for this problem is that the server certificate chain of the loading page is missing.

Solutions proposed as follows:

  • The temporary solution is: you can submit a work order to our support team to configure through AMCS, and close the SSL pop-up window first.
  • The final solution is: Because the server certificate chain is missing, notify the customer service end to make configuration changes, and improve the certificate chain.

How to solve the error problem when loading scheme links in the bytedance://dispatch_message format in Android client mini program?

On the Android side, loading a link with a similar scheme can be solved by implementing the following proxy (see the following code sample).

Specifically, implement the GriverInterceptUrlEvent protocol and implement the scheme whitelisting logic for the interceptUrl method.

copy
public class UrlInterceptEventHandler implements GriverInterceptUrlEvent {
    @Override
    public boolean interceptUrl (Page page, String url) {
      Log.d ( tag:"UrlInterceptEventHandle", msg:"url intercepted: " + url);
      // intercept scheme
      if(url.startsWith ("market://")) {
        return true;
        return false;
     @Override
     public void onInitialized() {
     @Override
     public void onFinalized() {
}

How to open encrypted PDF files in Android mini-program SDK?

  1. Create a custom implementation of GriverOpenDocumentExtension. For more information, see the Customize behaviors to open PDF files topic. The following is a code sample:
copy
public class CustomGriverOpenDocumentExtensionImpl implements GriverOpenDocumentExtension {

    @Override
    public void openDocument(Activity activity, String fileType, String filePath) {
        Intent intent = new Intent();
        intent.setClass(activity, CustomPdfViewerActivity.class);
        intent.putExtra("fileType", fileType);
        intent.putExtra("filePath", filePath);
        activity.startActivity(intent);
    }
}

  1. Use a third-party PDF library such as PDFium, MuPDF, or others to handle decryption and rendering of encrypted PDF documents.

How to integrate the "share” capacity to allow mini programs to be shared via links accessible in other apps?

The mini program can be shared with others via the share capacity provided by the SDK. Others who receive the share link via Facebook, Twitter, or other apps can open the shared mini program. For integration details, refer to Customize the share capacity.

How to address the Play Store policy requirements where an Android app is not permitted to request the READ_MEDIA_IMAGES and READ_MEDIA_VIDEO permissions?

Try the following ways to resolve this problem:

  • Way 1: Remove permissions if APIs are not used
    If the my.chooseImage or my.chooseVideo APIs are not used in your app, you can remove these permissions completely by modifying the AndroidManifest.xml file as follows, where the node="remove" indicates the specific permission is remved.
copy
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES"
    tools:node="remove"
/>
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO"
    tools:node="remove"
/>

  • Way 2: Update the IAPMiniProgram SDK if APIs are used

If the my.chooseImage or my.chooseVideo APIs are used in your app, you need to upgrade your IAPMiniProgram SDK to version 2.65.7 or later. For the SDK version, see SDK release notes (Android).

NOTE: Pay attention if you work on the Android 13 devices. After upgrading, the my.onUserCaptureScreen JSAPI is not available at all.

How to get the current URL correctly ?

You can use onProgressChanged function to print the current URL correctly. For more information, see the GriverPageHelperEvent interface.