Link to home
Start Free TrialLog in
Avatar of Sam Elfassy
Sam Elfassy

asked on

How to build 100% offline? (Using Android Studio + Android libraries + Kotlin + Gradle)

My question is meant to save much time and energy by asking for a proven advice and pro tips from the experience of an expert who has built with Android/Kotlin/Gradle offline. That is the type of information which helps me very much, and I appreciate it to the utmost.

I have a need to build locally, in full & certainty, sometimes. It should be possible, quite surely in the cases when I have no need to add & resolve new dependencies. Please correct me if I got that wrong: if the JDK, the Studio IDE compiler and Kotlin are installed locally by default, then what I need to be sure about is if Gradle has cached locally the Android libraries I'm using and can resolve all the dependencies without network resources.

If Gradle cannot build a new source without network resources, so can it do it regularly offline after the the first build was done successfully online? i.e. Does Gradle can cache and caches locally everything it needs for a source (that won't add new dependencies)?

And in a case of a code error: do Studio and Gradle cover a reasonable amount of their build error-info offline as well? Or that you'll need to anyway go online and build again to get it?

Below is the Android site's information about the offline mode feature (naturally, it doesn't cover my question):

"Enable offline mode
If you are on a slow network connection, your build times may suffer when Gradle attempts to use network resources to resolve dependencies. You can tell Gradle to avoid using network resources by using only the artifacts that it has cached locally.

To use Gradle offline when building with Android Studio, proceed as follows:

Open the Preferences window by clicking File > Settings (on Mac, Android Studio > Preferences).
In the left pane, click Build, Execution, Deployment > Gradle.
Check the Offline work checkbox."

https://developer.android.com/studio/build/optimize-your-build


Thanks in advance,

Sam
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.