Skip to content

Instantly share code, notes, and snippets.



Forked from dlew/
Last active Jul 26, 2020
What would you like to do?
Simple AndroidX Migration Script (updated to work with Linux and avoid xarg argument list too long)
#!/usr/bin/env bash
# I've found that the "Migrate to AndroidX" converter in Android Studio doesn't work very
# well, so I wrote my own script to do the simple job of converting package names.
# You can download a CSV of package names here:
# It'll run faster on a clean build because then there are fewer files to scan over.
# Uses `gsed` because I'm on a Mac. Can easily replace with `sed` if you don't have `gsed`.
# This isn't perfect; it won't find every conversion issue. You break it you buy it. Viewer discretion is advised.
while IFS=, read -r from to
done <<< "$(cat $MAPPING_FILE)"
echo -e "$replace" > sed.convert
find $PROJECT_DIR \( -name "*.kt" -o -name "*.java" -o -name "*.xml" \) -type f -not -path '*/\.git*' -print0 | xargs -0 sed -i -f sed.convert
rm sed.convert
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment