How Android Studio hits the jar pack
In eclipse we know how to export a project as a jar package for use by other projects.
Can be processed by modifying gradle in as.
We create a new project Makejar, create a new modle-type for the library in the project
App for our main project, Librarydemo is the model that we want to generate the jar package for.
Add the following code to the 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)//在终端执行生成JAR包// gradlew makeJar
Type Gradlew Makejar in terminal Enter to see OK as shown below:
Of course, in the main engineering app build to add Librarydemo this dependent model:
dependencies { compile fileTree(dir‘libs‘, include: [‘*.jar‘]) ‘com.android.support:appcompat-v7:22.2.0‘ compile project(‘:librarydemo‘)}
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
How Android Studio hits the jar pack