Mobile Development 18 min read

Trip.com App Android 11 Migration: Design, Implementation, and Lessons Learned

This article describes Trip.com’s experience adapting its Android app to Android 11, covering background, key changes such as scoped storage and package visibility, migration strategies, implementation details, encountered challenges, and lessons learned for mobile developers.

Ctrip Technology
Ctrip Technology
Ctrip Technology
Trip.com App Android 11 Migration: Design, Implementation, and Lessons Learned

1. Background

Google Play started enforcing targetSdkVersion >=30 (Android 11) in Q3/Q4 2021. Android 11 introduced mandatory scoped storage, making migration complex. Trip.com app began Android 11 adaptation in Q1 2021.

2. Key Changes

2.1 Package Visibility

Before Android 11, apps could query installed packages. After targetSdkVersion 30, getInstalledPackages() returns an empty list, requiring explicit <queries> entries in AndroidManifest.xml .

<manifest package="com.example.game">
    <queries>
        <package android:name="com.example.store" />
        <package android:name="com.example.services" />
        <intent>
            <action android:name="android.intent.action.SEND" />
            <data android:mimeType="image/jpeg" />
        </intent>
    </queries>
    ...
</manifest>

2.2 Unique Identifiers

Access to IMEI, MAC address, ICCID and other non‑resettable identifiers is restricted; apps must switch to resettable identifiers.

2.3 Scoped Storage

Android 11 forces scoped storage. Private app directories remain unchanged, media files can be accessed directly or via permissions, while non‑media files must be accessed through the Storage Access Framework (SAF).

Private directory access unchanged

Media files can be accessed directly or with granted permissions

Non‑media files require SAF

2.4 Other Changes

Custom Toasts are limited (text‑only, deprecated setView() ), SharedPreferences listeners receive null keys, foreground service restrictions, and other minor API adjustments.

3. Migration Strategy

3.1 Precise Scope Identification

Identify code that uses package visibility APIs ( getInstalledPackages() ), unique identifier APIs ( getIccid() ), and storage APIs ( getExternalStorageDirectory() , getExternalStoragePublicDirectory() , direct path concatenations).

3.2 Simplify Work

Centralize <queries> and intent declarations in AndroidManifest.xml . Provide a utility class IBUStorageEnvironment that abstracts Environment functions and offers helper methods for scoped‑storage checks.

3.3 Provide Fallback

Use Environment.isExternalStorageLegacy() to detect legacy storage mode and allow a fallback to targetSdkVersion 29 if necessary. Consider compileSdkVersion and buildToolsVersion upgrades and their impact on nullability annotations.

4. Pitfalls Encountered

4.1 Gradle Plugin Upgrade

Upgrading compileSdkVersion , targetSdkVersion , and the Android Gradle Plugin (AGP) introduced compilation and Lint failures, especially because the <queries> tag requires a newer AGP version.

4.2 Third‑Party Library Crashes

SecurityException errors (e.g., missing READ_PHONE_STATE ) appeared during testing; resolved by updating third‑party libraries to compatible versions or adding proper exception handling.

4.3 CI/CD Adaptation

CI pipelines needed updates for the new SDK, Lint rules, and ADB limitations on external storage. Paths like /mnt/sdcard were replaced with /sdcard , and storage‑related test steps were adjusted accordingly.

5. Conclusion

Trip.com completed the Android 11 migration within a month, stabilizing the app and CI/CD pipelines. The effort highlighted increased privacy protection, improved user experience, and provided practical guidance for developers facing similar Android version upgrades.

mobile developmentCI/CDGradleAndroid 11Scoped StoragePackage Visibility
Ctrip Technology
Written by

Ctrip Technology

Official Ctrip Technology account, sharing and discussing growth.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.