5

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

1 Answers1

4

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

MuhammadAliJr
  • 273
  • 4
  • 17