1

I am new to Android Studio and Flutter. I started just today. And when I build a demo flutter app and RUN it. Gradle started downloading many things. I don't know if it happens on every run, of once for a project of once entierly. But the problem is I dont have unlimited internet. My service provider gives 1.5GB data daily. So I wanted to ask how much data does it takes while running the app and building gradle? Also how frequently that happens? And is there way to stop using online SDKs and Gradle Builds and use offline one every time..?

PS: I am using Android Studio 4

Terminal output while I build my first app..

Launching lib\main.dart on Redmi Note 7 Pro in debug mode...
Running Gradle task 'assembleDebug'...
Checking the license for package Android SDK Build-Tools 28.0.3 in C:\Users\jay76\AppData\Local\Android\sdk\licenses
License for package Android SDK Build-Tools 28.0.3 accepted.
Preparing "Install Android SDK Build-Tools 28.0.3 (revision: 28.0.3)".
"Install Android SDK Build-Tools 28.0.3 (revision: 28.0.3)" ready.
Installing Android SDK Build-Tools 28.0.3 in C:\Users\jay76\AppData\Local\Android\sdk\build-tools\28.0.3
"Install Android SDK Build-Tools 28.0.3 (revision: 28.0.3)" complete.
"Install Android SDK Build-Tools 28.0.3 (revision: 28.0.3)" finished.
Checking the license for package Android SDK Platform 28 in C:\Users\jay76\AppData\Local\Android\sdk\licenses
License for package Android SDK Platform 28 accepted.
Preparing "Install Android SDK Platform 28 (revision: 6)".
"Install Android SDK Platform 28 (revision: 6)" ready.
Installing Android SDK Platform 28 in C:\Users\jay76\AppData\Local\Android\sdk\platforms\android-28
"Install Android SDK Platform 28 (revision: 6)" complete.
"Install Android SDK Platform 28 (revision: 6)" finished.
thisisjaymehta
  • 614
  • 1
  • 12
  • 26
  • 3
    Does this answer your question? [How to configure gradle to work "offline" (using cached dependencies)](https://stackoverflow.com/questions/32171524/how-to-configure-gradle-to-work-offline-using-cached-dependencies) – sdex Jun 26 '20 at 06:49
  • @YuriyMysochenko No, because the option of `Offline Work` is missing in my Android Studio 4's Settings, while the answer shows it in Android Studio 3's Settings. – thisisjaymehta Jun 26 '20 at 07:19
  • @thisisjaymehta then you should use the one labeled "Android Studio (v. 3.6.1 and above)" because that would include your version (I've confirmed that option is present in 4.1) – Ryan M Jun 26 '20 at 08:09
  • @RyanM I cant find it. Can you give me the exact path. – thisisjaymehta Jun 26 '20 at 13:29
  • 1
    https://stackoverflow.com/a/60655321/208273 – Ryan M Jun 26 '20 at 18:44

3 Answers3

7

After you create a project gradle will download all the required dependencies for the first time if those dependencies are not already available locally (may be you upgraded to another version of dependency).

Also gradle will only fetch dependency when you add a new dependency to dependency tree so it does a good job of avoiding re-downloading artifacts.

If you still wish to use gradle in offline mode, there are couple of ways to do so -

You can pass --offline to Gradle to prevent from accessing the network during builds.

gradle --offline build

Your build will fail if the build needs something from internet and is not cached locally.

Another way is you could configure gradle to run offline from gradle window -

Gradle Offline

Hope this helps!

Tanuj
  • 2,032
  • 10
  • 18
1

Gradle will only download the dependencies needed for your project to build successfully . Such as SDK tools and other app dependencies specified in the build.gradle file .

Once the are download the only other time it will download more stuff is if you add other dependencies to the build.gradle file other than that its not a good idea to use gradle offline as if it needs to download a dependency and thee is no connection your build will fail.

on a personal note i can say with confidence that gradle can not use more than 20mbs of data on subsequent builds after the first build

alvinMemphis
  • 185
  • 2
  • 14
0

It is not recommended to turn off the internet data because Gradle might throw an out-of-date plugins error and in that case, you will have to go online to get the latest updates.

Sajad Jaward
  • 247
  • 5
  • 16