How to create an android studio project offline?

拜拜、爱过 提交于 2021-01-05 07:18:25

问题


I want to create my android projects offline. I've tried several techniques but none of them worked for me! I've downloaded offline components (Android Gradle Plugin & Google Maven dependencies) from developers.android.com website for creating offline projects, but the problem is that I don't know how to make them work with android studio? Please help!


回答1:


As said here https://developer.android.com/studio/build/optimize-your-build#offline_mode (Android Studio < 3.6)

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.
  • Click Apply or OK.

If you're building from the command line, pass the --offline option.

[EDIT]

https://developer.android.com/studio/releases/#3.6-gradle-offline-ui (Android Studio > 3.6)

New location to toggle Gradle's offline mode To enable or disable Gradle's offline mode, first select View > Tool Windows > Gradle from the menu bar.

Then, near the top of the Gradle window, click Toggle Offline Mode Gradle offline button in the Gradle panel..

Whenever you add a dependency, you need to download it. If so, you need to have a connection.

You can also import all dependencies once with a network connection and then switch to offline mode.




回答2:


Theoretically you can work offline by going to File > Settings > Build, Execution, Deployment > Gradle and checking Offline Work. You will unfortunately have to sync the project while on a working internet connection at least once to have the necessary dependencies downloaded for your project.



来源:https://stackoverflow.com/questions/63653771/how-to-create-an-android-studio-project-offline

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!