Created
March 11, 2019 19:25
-
-
Save abdallaadelessa/dcc1a701d6aa68e0ce61fae0f4d5ed00 to your computer and use it in GitHub Desktop.
We can make this file beautiful and searchable if this error is corrected: It looks like row 2 should actually have 1 column, instead of 2 in line 1.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Fixes for androidx-class-mapping.csv | |
| android.support.v7.widget.GridLayoutManager,androidx.recyclerview.widget.GridLayoutManager | |
| com.android.databinding.library,androidx.databinding.library |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| # Hint: https://gist.github.com/dlew/5db1b780896bbc6f542e7c00a11db6a0 | |
| # 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: https://developer.android.com/topic/libraries/support-library/downloads/androidx-class-mapping.csv | |
| # | |
| # 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`. | |
| # | |
| # Install gsed in Mac: | |
| # brew install gnu-sed | |
| # port install gsed | |
| # | |
| # This isn't perfect; it won't find every conversion issue. You break it you buy it. Viewer discretion is advised. | |
| function migrateToAndroidX() { | |
| PROJECT_DIR=$1 | |
| MAPPING_FILE=$2 | |
| replace="" | |
| while IFS=, read -r from to | |
| do | |
| 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*' -not -path '*/\.idea*' -not -path '*/build/*' -print0 | xargs -0 gsed -i "$replace" | |
| } | |
| PROJECT_FOLDER="$1" | |
| if [ -z "$PROJECT_FOLDER" ] | |
| then | |
| echo "Please enter the relative project folder name" | |
| else | |
| echo "applying androidx-class-mapping-fixes.csv on $PROJECT_FOLDER ..." | |
| migrateToAndroidX "./$PROJECT_FOLDER" "./androidx-class-mapping-fixes.csv" | |
| echo "Done" | |
| echo "applying androidx-class-mapping on $PROJECT_FOLDER ..." | |
| migrateToAndroidX "./$PROJECT_FOLDER" "./androidx-class-mapping.csv" | |
| echo "Done" | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment