Instantly share code, notes, and snippets.

What would you like to do?
Simple AndroidX Migration Script
#!/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
replace+="; s/$from/$to/g"
done <<< "$(cat $MAPPING_FILE)"
find $PROJECT_DIR \( -name "*.kt" -o -name "*.java" -o -name "*.xml" \) -type f -not -path '*/\.git*' -print0 | xargs -0 gsed -i "$replace"

This comment has been minimized.

matthewcmckenna commented Nov 14, 2018

Thanks for this!


This comment has been minimized.

cmargonis commented Nov 15, 2018

Thank you!


This comment has been minimized.

ondrej23 commented Nov 20, 2018

Great job, thanks a lot!


This comment has been minimized.

vashisthg commented Nov 21, 2018

Thanks Dan Leu
We can add,,

to the csv if using AppBarLayout and FloatingActionButton


This comment has been minimized.

lwasylkowski commented Nov 27, 2018

Some more missing classes:,,,,

This comment has been minimized.

Kisty commented Nov 28, 2018

Thanks for this, Dan!

Android relevant issue for missing mappings:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment