setting gradle on offline mode in android studio

2019-08-21 19:33发布

问题:

I'm messing about the android studio and having a problem with Gradle. I'm looking to put gradle on offline mode for more speed, but the error below pops up:

No cached version of com.android.tools.build:gradle:3.1.2 available for offline mode.

How to fix this?

回答1:

I think you have to build the project online at lease once after adding the library and make it offline afterwards will solve your issue



回答2:

For running project completely offline I have a small trick.

  1. Go to folder that you have already created project (build using online mode) for example C:\users\user\AndroidStudioProjects\project1.
  2. After that create a new project in Android Studio. And build it in offline mode.
  3. It shows same error. Now copy the .gradle and app folderfrom first project folder to second project folder.
  4. Now build and sinc project it will run perfectly.
  5. For this you should have atleast one "Hello World" project already build using online mode. After that copy this for all other projects.