samoylenkodmitry / Android-migrate-package-to-namespace

Android migrate package to namespace

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

GPT4 prompt:

write a script to migrate in Android project package='my.package.name' in AndroidManifest.xml to the build.gradle in the same module, android { namespace = 'my.package.name' }. First, let it find all the build.gradle files in the project, next navigate to the ./src/main/AndroidManifest.xml and copies package name from package="xxx" string, then adds 'android { namespace = 'xxx' }' to the end of the current build.gradle. Script can by python, kts or bash on your preference.

And for this README:

I want to publish this script to my github. Write a README.md text for me please.

Android Package Name Migrator

This Python script helps you migrate the package name specified in AndroidManifest.xml to the build.gradle file for each module in your Android project.

Features

  • Finds all build.gradle files in your project.
  • Extracts the package name from the corresponding ./src/main/AndroidManifest.xml file.
  • Adds the android { namespace = 'xxx' } line to the end of the build.gradle file, where 'xxx' is the extracted package name.

Requirements

  • Python 3.x

Usage

  1. Clone this repository or download the migrate_package_name.py script.
  2. Place the migrate_package_name.py script in the root directory of your Android project.
  3. Open a terminal/command prompt, navigate to your Android project's root directory, and run the following command:
python migrate_package_name.py

Note

This script assumes that you have a standard Android project structure with build.gradle and AndroidManifest.xml files in their usual locations. If your project structure is different, you might need to modify the script to accommodate those differences.

License

MIT License. See LICENSE for more information.

About

Android migrate package to namespace

License:MIT License


Languages

Language:Python 100.0%