I'm using AndroidStudio and I have this project as shown:
What is inside the blue circle is myLib. myLib also needs to use an external lib that is inside the red circle, and an apache package (green circle).
So I want to make this whole thing become a single .jar, so I can use it in another projects.
A step-by-step guide would be really appreciated, I'm a beginner in the developer world.
Thanks!
If you are unable to find the libs folder in Android studio then open your android project in “Project” mode If the project is already opened in the “Android” mode. Then go to Your Project Name > app > libs and right-click on it and paste the downloaded JAR files.
You cannot directly run jar files in android as android runs on Dalvik Virtual Machine , whereas to run jar files you will need Java Runtime Environment which has Java Virtual Machine .
Open build.gradle for library project
Write two tasks in build.gradle -- deleteJar and createJar and add rule createJar.dependsOn(deleteJar, build)
The code from above:
task deleteJar(type: Delete) { delete 'libs/jars/logmanagementlib.jar' } task createJar(type: Copy) { from('build/intermediates/bundles/release/') into('libs/jars/') include('classes.jar') rename('classes.jar', 'logmanagementlib.jar') } createJar.dependsOn(deleteJar, build)
Expand gradle panel from right and open all tasks under yourlibrary->others. You will see two new tasks there -- createJar and deleteJar
Double click on createJar
Once the task run successfully, get your generated jar from path mentioned in createJar task i.e. libs/xxxx.jar
copy the newly generated jar into your required project's lib folder-->right click-->select "add as library"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With