Android Studio how to package a JAR package, androidjar
How to package a JAR package in Android Studio
In eclipse, we know how to export a project as a jar package for other projects.
In AS, you can modify gradle for processing.
Create a new project MakeJar and create a new modle in the project. The modle type is library.
The app is our main project, and librarydemo is the model for generating the jar package.
Add the following code to librarydemo:
Task makeJar (type: Copy) {delete 'build/libs/mysdk. jar 'from ('build/intermediates/bundles/release/') into ('build/libs/') include ('classes. jar ') rename ('classes. jar ', 'mysdk. jar ')} makeJar. dependsOn (build) // execute the JAR package generated on the terminal // gradlew makeJar
In Terminal, type gradlew makeJar and press Enter. You can see the following:
Of course, you must add the librarydemo dependency model to the build of the main project App:
Dependencies {compile fileTree (dir: 'libs', include :['*. jar ']) compile 'com. android. support: appcompat-v7: 22.2.0 'compile project (': librarydemo ')}
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.