Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reusing locally downloaded Android libraries

Tags:

I usually have issues with power and steady internet connectivity. Thus I'm wondering if it is:

  1. Possible to import a library that exists in an existing local project of mine to a new project. Without having to add the library dependency (or even if I have to add the dependency, at least without having to download the library again.)

E.g Assuming I have an existing project in which I used Retrofit for my network calls. Now if I create a new project which requires I use Retrofit again, is there a way I can get the Retrofit library or source code from the already existing project into this new project, without having to download the library all over again from the internet.

  1. If possible, how can I access this library on my local machine or existing Android project
like image 420
Peterstev Uremgba Avatar asked Apr 04 '18 21:04

Peterstev Uremgba


People also ask

What is .AAR file?

AAR files can contain Android resources and a manifest file, which allows you to bundle in shared resources like layouts and drawables in addition to Java classes and methods. AAR files can contain C/C++ libraries for use by the app module's C/C++ code.


1 Answers

Yes you can import cached libraries that you used before using Gradle

The way to achieve this first you have to use the library once and make sure it cached in Gradle files Folder you can reach it following this root

   C:\Users\[username]\.gradle\caches\modules-2\files-2.1

This contain all cached libraries you used with the current setup. After making sure that your needed library is cached, open your new project and change gradle settings to work offline

gradle settings

Then add the dependency and sync Gradle should then bring it to your project without internet connectivity at all.

Other option you can download the jar file or aar package of the library you want to use Here's how to achieve that

like image 144
MuhammadAliJr Avatar answered Sep 23 '22 13:09

MuhammadAliJr