# ICU version upgrade Upgrade the ICU on Android to the new upstream version. The new upstream versions can be found at https://github.com/unicode-org/icu/releases. The below contains the steps and commands in order to upgrade the ICU version in the AOSP. # Prerequisites 1. Install the prerequisite tools * See http://site.icu-project.org/repository * [git-lts](https://git-lfs.github.com/) has to be installed to pull binaries correctly from the github. 2. Generate a github read-access token and setup a local ~/.m2/setting.xml * See http://cldr.unicode.org/development/maven. This is required to download the prebuilt ICU to break the circular dependency between CLDR and icu. 3. Check out aosp/master * http://go/repo-init/aosp-master-with-phones # Steps 1. Create a new branch in AOSP * The branch is a staging branch to **rebase** Android-specific patches onto the new upstream versions. * See detailed instruction at http://g3doc/company/teams/android-build-team/playbook/create_branch#creating-new-git-branches. * **Choose a branch name** * Create aosp/icu{version} branch, e.g. `aosp/icu67` in the `external/icu` project forked from `aosp/master` * For the external/cldr project, we don't need a new branch. We use the **`aosp/upstream-release-cldr** as the mirror of the upstream release branch. We don’t modify this branch with Android patches, but merge this branch into aosp/master where the Android patches are located. 2. Configure the versions and temp directory 2a. Customize the following environment variables. The following example targets the ICU 71.1 and CLDR 41.0 version. ```shell export ICU_VERSION=71 export ICU_MINOR_VERSION=1 export CLDR_VERSION=41 export ICU_UPGRADE_BUG=1234567890 # buganizer bug # Initially empty directory to store upstream source export UPSTREAM_CLDR_GIT=/media/user/disk/icu-git/cldr export UPSTREAM_ICU_GIT=/media/user/disk/icu-git/icu ``` 2b. Build the clean source of AOSP ```shell source build/envsetup.sh lunch sdk_phone_x86_64-userdebug m ``` 3. Copy the CLDR sources into the `upstream-release-cldr` branch 3a. Copy sources ```shell export CLDR_UPSTREAM_BRANCH=release-${CLDR_VERSION} cd ${ANDROID_BUILD_TOP}/external/cldr git fetch aosp upstream-release-cldr git branch ${CLDR_UPSTREAM_BRANCH} --track aosp/upstream-release-cldr git checkout ${CLDR_UPSTREAM_BRANCH} git clone https://github.com/unicode-org/cldr.git ${UPSTREAM_CLDR_GIT} git --git-dir=${UPSTREAM_CLDR_GIT}/.git --work-tree=${UPSTREAM_CLDR_GIT} fetch git --git-dir=${UPSTREAM_CLDR_GIT}/.git --work-tree=${UPSTREAM_CLDR_GIT} checkout ${CLDR_UPSTREAM_BRANCH} rm -rf * cp -r ${UPSTREAM_CLDR_GIT}/* . git clean -dfX # Remove ignored files git add -A git commit -F- <~1.. ``` 5b. Cherry-pick the patches since the ICU upgrade * Find the patches with this query. https://r.android.com/q/%2522Android+patch%2522+project:platform/external/icu+status:merged+-owner:automerger+-owner:android-build-coastguard-worker%2540google.com+branch:master 6. Regenerate and commit the artifacts 6a. Update icu source data files ```shell croot external/icu tools/updatecldrdata.py git add -A git commit -F- < libs/androidfw/LocaleDataTables.cpp git commit -a -F- < libs/androidfw/LocaleDataTables.cpp Bug: ${ICU_UPGRADE_BUG} Test: atest FrameworksCoreTests:android.text.format EOF ``` 7. Build and run test 7a. Build by `m droid cts` 7b. Run the device tests by `atest CtsIcu4cTestCases CtsIcuTestCases CtsLibcoreTestCases CtsLibcoreOjTestCases CtsBionicTestCases CtsTextTestCases minikin_tests -- --abi x86_64 # the primary ABI` 7c. Run the host-side test by * ICU4J host-side test `ant check` * ICU4C host-side test `make CINTLTST_OPTS=-w INTLTEST_OPTS=-w check` (Currently, it has some failing tests. No of failures?) 8. Upload the CLs to gerrit for code reviews from `aosp/icu${ICU_VERSION}` in `external/icu` and `aosp/upstream-release-cldr` in `external/cldr` ```shell repo upload --cbr -o uploadvalidator~skip --no-verify . ``` 9. Merge `aosp/icu*` branch to aosp/master ```shell cd $ANDROID_BUILD_TOP/external/icu repo start icu${ICU_VERSION}-master . git merge --no-ff icu${ICU_VERSION} -m " Merge branch aosp/icu${ICU_VERSION} into aosp/master Bug: ${ICU_UPGRADE_BUG} Test: atest CtsIcu4cTestCases CtsIcuTestCases CtsLibcoreTestCases CtsLibcoreOjTestCases CtsBionicTestCases CtsTextTestCases minikin_tests " ``` 10. Upload and submit changes from external/icu, external/cldr, libcore, frameworks/base, system/timezone 10a. `repo upload --cbr -o uploadvalidator~skip --no-verify .` 10b. Code review the diff in `android_icu4j/src/main/tests/android/icu/extratest/expected_transliteration_id_list.txt` * If a transliteration id is removed from the list, it may introduce app compatibility issues if the app depends on them. However, app has been warned to check the availability before invoking them. https://developer.android.com/reference/android/icu/text/Transliterator#getAvailableIDs() 11. After submitting all the CLs to aosp/master, expose the new stable ICU4J APIs to Android SDK ```shell rm tools/srcgen/allowlisted-public-api.txt ./tools/generate_android_icu4j.sh # Modify Icu4jTransform.java to allowlist more classes if needed. Check the error message for the details m update-api droid git commit -a -F- < just landed Android AOSP. https://android.googlesource.com/platform/external/icu/+/master/README.version as well as Android S (or Android 12). https://googleplex-android.googlesource.com/platform/external/icu/+/sc-dev/README.version Note: - Contains bug fixes / build changes with a small set of API methods added. - Unicode stays at version 14, and no new version has been published yet. ``` ## Historic version of this doc http://g3doc/third_party/icu/g3doc/update/android