Skip to content
master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 

MigrateToAndroidX

Python Script to automatically migrate old imports in a React-Native project to AndroidX imports

What does it do?

  • Uses the bindings file provided by Android
  • Looks at all the node_modules java files and searches for the old bindings (Usually of the form android.support.*) and replaces with the new AndroidX imports(Of the form androidx.*)
  • Currently, I'm only looking for a sublist of imports (that is used by most react-native libraries) and replacing them. The sublist of imports are below:-
  1. android.support.annotation.**
  2. android.support.annotation.RequiresPermission.**
  3. android.support.design.**
  4. android.support.v4.**

Usage

python3 migrateToAndroidX.py --node_modules <path>

Example

If your path is ~/projects/rnProject/node_modules/ python3 migrateToAndroidX.py --node_modules ~/projects/rnProject/node_modules/

How to make this script run automatically after npm install

It might be beneficial to run the script after all node_modules are installed. For this, we can use postinstall hook of npm In your package.json, you can add a new script,

"scripts":{
  ... 
  "postinstall":"python3 migrateToAndroidX.py --node_modules <path>"
}

About

Python Script to automatically migrate imports to AndroidX

Resources

License

Releases

No releases published

Packages

No packages published

Languages