This project converts an APK file into an Android AAR library. It uses apktool
to decompile the APK and gradle
to build the AAR. The library will be named after the package name from the manifest with _library
appended.
Ensure you have the following installed on your system:
- Node.js
- Java 8
- Gradle
- apktool (apktool_2.9.3.jar should be placed in the root directory of this project)
apk-to-aar
├── apktool_2.9.3.jar
├── index.js
├── package.json
└── templates
├── build.gradle
├── settings.gradle
└── gradle
└── wrapper
├── gradle-wrapper.jar
└── gradle-wrapper.properties
-
Clone the repository:
git clone <repository_url> cd apk-to-aar
-
Install dependencies:
npm install
-
Ensure
apktool_2.9.3.jar
is placed in the root directory of the project.
To convert an APK to an AAR, use the following command:
npm start -- --input path/to/your.apk
-i, --input <path>
: APK file path (required)-x, --exclude <classes>
: Classes to exclude, comma separated-r, --exclude-resources
: Exclude resources from AAR-h, --help
: Display help
-
Convert an APK to AAR:
npm start -- --input path/to/your.apk
-
Convert an APK to AAR and exclude specific classes:
npm start -- --input path/to/your.apk -x ClassToExclude1,ClassToExclude2
-
Convert an APK to AAR and exclude resources:
npm start -- --input path/to/your.apk -r
The generated AAR file will be located in the out/<apk_name>/<package_name>_library/build/outputs/aar/
directory.
Example:
AAR file generated: /path/to/project/out/com.example.app/com.example.app_library/build/outputs/aar/com.example.app_library-release.aar
- Fork the repository.
- Create your feature branch (
git checkout -b feature/my-feature
). - Commit your changes (
git commit -m 'Add some feature'
). - Push to the branch (
git push origin feature/my-feature
). - Open a pull request.
This project is licensed under the MIT License - see the LICENSE file for details.