【Android学习】Android studio环境搭建-解决下载gradle慢&加载mainfest.xml慢的问题

这篇具有很好参考价值的文章主要介绍了【Android学习】Android studio环境搭建-解决下载gradle慢&加载mainfest.xml慢的问题。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

转载:https://blog.csdn.net/qq_31881469/article/details/78646406/

目录

1、解决网络连接问题

(1)问题描述 

(2)方法步骤 

2、解决内存吃紧问题 

(1)问题描述 

(2)方法步骤 

3、解决构建速度慢问题 

(1)问题描述 

(2)方法 


androidstudio下载gradle慢,Android 学习,android,android studio,环境配置

 文章来源地址https://www.toymoban.com/news/detail-633882.html

1、解决网络连接问题

(1)问题描述 

        检查你的 Android SDK,卡上很长时间,需要更新则需要进行安装。

(2)方法步骤 

①跳过这一步,可在Android Studio安装目录下的 bin 目录下,找到 idea.properties 文件,在文件最后追加disable.android.first.run=true 。 

# Use ${idea.home.path} macro to specify location relative to IDE installation home.
# Use ${xxx} where xxx is any Java property (including defined in previous lines of this file) to refer to its value.
# Note for Windows users: please make sure you're using forward slashes: C:/dir1/dir2.

#---------------------------------------------------------------------
# Uncomment this option if you want to customize a path to the settings directory.
#---------------------------------------------------------------------
# idea.config.path=${user.home}/.AndroidStudio/config

#---------------------------------------------------------------------
# Uncomment this option if you want to customize a path to the caches directory.
#---------------------------------------------------------------------
# idea.system.path=${user.home}/.AndroidStudio/system

#---------------------------------------------------------------------
# Uncomment this option if you want to customize a path to the user-installed plugins directory.
#---------------------------------------------------------------------
# idea.plugins.path=${idea.config.path}/plugins

#---------------------------------------------------------------------
# Uncomment this option if you want to customize a path to the logs directory.
#---------------------------------------------------------------------
# idea.log.path=${idea.system.path}/log

#---------------------------------------------------------------------
# Maximum file size (in KiB) IDE should provide code assistance for.
# The larger file is the slower its editor works and higher overall system memory requirements are
# if code assistance is enabled. Remove this property or set to very large number if you need
# code assistance for any files available regardless of their size.
#---------------------------------------------------------------------
idea.max.intellisense.filesize=2500

#---------------------------------------------------------------------
# Maximum file size (in KiB) the IDE is able to open.
#---------------------------------------------------------------------
idea.max.content.load.filesize=20000

#---------------------------------------------------------------------
# This option controls console cyclic buffer: keeps the console output size not higher than the specified buffer size (KiB).
# Older lines are deleted. In order to disable cycle buffer use idea.cycle.buffer.size=disabled
#---------------------------------------------------------------------
idea.cycle.buffer.size=1024

#---------------------------------------------------------------------
# Configure if a special launcher should be used when running processes from within IDE.
# Using Launcher enables "soft exit" and "thread dump" features
#---------------------------------------------------------------------
idea.no.launcher=false

#---------------------------------------------------------------------
# To avoid too long classpath
#---------------------------------------------------------------------
idea.dynamic.classpath=false

#---------------------------------------------------------------------
# Uncomment this property to prevent IDE from throwing ProcessCanceledException when user activity
# detected. This option is only useful for plugin developers, while debugging PSI related activities
# performed in background error analysis thread.
# DO NOT UNCOMMENT THIS UNLESS YOU'RE DEBUGGING IDE ITSELF. Significant slowdowns and lockups will happen otherwise.
#---------------------------------------------------------------------
#idea.ProcessCanceledException=disabled

#---------------------------------------------------------------------
# There are two possible values of idea.popup.weight property: "heavy" and "medium".
# If you have WM configured as "Focus follows mouse with Auto Raise" then you have to
# set this property to "medium". It prevents problems with popup menus on some
# configurations.
#---------------------------------------------------------------------
idea.popup.weight=heavy

#---------------------------------------------------------------------
# Removing this property may lead to editor performance degradation under Windows.
#---------------------------------------------------------------------
sun.java2d.d3d=false

#---------------------------------------------------------------------
# Removing this property may lead to editor performance degradation on Java 8+.
#---------------------------------------------------------------------
swing.bufferPerWindow=true

#---------------------------------------------------------------------
# Removing this property may lead to editor performance degradation under X Window.
#---------------------------------------------------------------------
sun.java2d.pmoffscreen=false

#---------------------------------------------------------------------
# Enables HiDPI support in JBR
#---------------------------------------------------------------------
sun.java2d.uiScale.enabled=true

#---------------------------------------------------------------------
# Applicable to the Swing text components displaying HTML (except JEditorPane).
# Rebases CSS size map depending on the component's font size to let relative
# font size values (smaller, larger) scale properly. JBR-only.
#---------------------------------------------------------------------
javax.swing.rebaseCssSizeMap=true


#---------------------------------------------------------------------
# Workaround for accessing (in terms of a11y) long VCS logs on macOS. JBR-only.
#---------------------------------------------------------------------
sun.awt.mac.a11y.tableAccessibleRowCountThreshold=1000

#---------------------------------------------------------------------
# Enabling an optimization that excludes traversal of collapsed accessible nodes from the accessible tree. JBR-4167
#---------------------------------------------------------------------
javax.swing.JTree.excludeAccessibleChildrenFromClosedNodes=true

#---------------------------------------------------------------------
# Workaround to avoid long hangs while accessing clipboard under Mac OS X.
#---------------------------------------------------------------------
#ide.mac.useNativeClipboard=True

#---------------------------------------------------------------------
# Maximum size (KiB) the IDE will use to show historical file contents -
# in Show Diff or when calculating Digest Diff
#---------------------------------------------------------------------
#idea.max.vcs.loaded.size.kb=20480

#---------------------------------------------------------------------
# IDEA file chooser peeks inside directories to detect whether they contain a valid project
# (to mark such directories with a corresponding icon).
# Uncommenting the option prevents this behavior outside the user home directory.
#---------------------------------------------------------------------
#idea.chooser.lookup.for.project.dirs=false

#---------------------------------------------------------------------
# Experimental options that do a number of things to make truly smooth scrolling possible:
#
# * Enables hardware-accelerated scrolling.
#     Blit-acceleration copies as much of the rendered area as possible and then repaints only newly exposed region.
#     This helps to improve scrolling performance and to reduce CPU usage (especially if drawing is compute-intensive).
#
# * Enables "true double buffering".
#     True double buffering is needed to eliminate tearing on blit-accelerated scrolling and to restore
#     frame buffer content without the usual repainting, even when the EDT is blocked.
#
# * Adds "idea.true.smooth.scrolling.debug" option.
#     Checks whether blit-accelerated scrolling is feasible, and if so, checks whether true double buffering is available.
#
# * Enables handling of high-precision mouse wheel events.
#     Although Java 7 introduced MouseWheelEven.getPreciseWheelRotation() method, JScrollPane doesn't use it so far.
#     Depends on the Editor / General / Smooth Scrolling setting, remote desktop detection and power save mode state.
#     Ideally, we need to patch the runtime (on Windows, Linux and macOS) to improve handling of the fine-grained input data.
#     This feature can be toggled via "idea.true.smooth.scrolling.high.precision" option.
#
# * Enables handling of pixel-perfect scrolling events.
#     Currently, this mode is available only under macOS with JetBrains Runtime.
#     This feature can be toggled via "idea.true.smooth.scrolling.pixel.perfect" option.
#
# * Enables interpolation of scrolling input (scrollbar, mouse wheel, touchpad, keys, etc).
#     Smooths input, which lacks both spatial and temporal resolution, performs the rendering asynchronously.
#     Depends on the Editor / General / Smooth Scrolling setting, remote desktop detection and power save mode state.
#     The feature can be tweaked using the following options:
#       "idea.true.smooth.scrolling.interpolation" - the main switch
#       "idea.true.smooth.scrolling.interpolation.scrollbar" - scrollbar interpolation
#       "idea.true.smooth.scrolling.interpolation.scrollbar.delay" - initial delay for scrollbar interpolation (ms)
#       "idea.true.smooth.scrolling.interpolation.mouse.wheel" - mouse wheel / touchpad interpolation
#       "idea.true.smooth.scrolling.interpolation.mouse.wheel.delay.min" - minimum initial delay for mouse wheel interpolation (ms)
#       "idea.true.smooth.scrolling.interpolation.mouse.wheel.delay.max" - maximum initial delay for mouse wheel interpolation (ms)
#       "idea.true.smooth.scrolling.interpolation.precision.touchpad" - touchpad interpolation
#       "idea.true.smooth.scrolling.interpolation.precision.touchpad.delay" - initial delay for touchpad interpolation (ms)
#       "idea.true.smooth.scrolling.interpolation.other" - interpolation of other input sources
#       "idea.true.smooth.scrolling.interpolation.other.delay" - initial delay for other input source interpolation (ms)
#
# * Adds on-demand horizontal scrollbar in editor.
#     The horizontal scrollbar is shown only when it's actually needed for currently visible content.
#     This helps to save editor space and to prevent occasional horizontal "jitter" on vertical touchpad scrolling.
#     This feature can be toggled via "idea.true.smooth.scrolling.dynamic.scrollbars" option.
#---------------------------------------------------------------------
#idea.true.smooth.scrolling=true

#---------------------------------------------------------------------
# The VM option value to be used to start a JVM in debug mode.
# Some JREs define it in a different way (-XXdebug in Oracle VM)
#---------------------------------------------------------------------
idea.xdebug.key=-Xdebug

#-----------------------------------------------------------------------
# Change to 'enabled' if you want to receive instant visual notifications
# about fatal errors that happen to an IDE or plugins installed.
#-----------------------------------------------------------------------
idea.fatal.error.notification=disabled

disable.android.first.run=true

②或者:使用墙外代理。

2、解决内存吃紧问题 

(1)问题描述 

        Android Studio 安装目录的-xmx 参数是 Java 虚拟机启动时的参数,用于限制最大堆内存。Android Studio 启动时设置了这个参数,并且默认值很小。 一旦你的工程变大,IDE 运行时间稍长,内存就开始吃紧,频繁触发 GC,自然会卡。

(2)方法步骤 

        每次升级/安装 Android Studio 之后都修改android-studio/bin/studio64.exe.vmoptions studio64.vmoptions 两个文件的以下属性: 

-Xms2048m 
-Xmx2048m 
-XX:MaxPermSize=2048m 
-XX:ReservedCodeCacheSize=2048m

-XX:+IgnoreUnrecognizedVMOptions
-XX:+UseG1GC
-XX:SoftRefLRUPolicyMSPerMB=50
-XX:CICompilerCount=2
-XX:+HeapDumpOnOutOfMemoryError
-XX:-OmitStackTraceInFastThrow
-ea
-Dsun.io.useCanonCaches=false
-Djdk.http.auth.tunneling.disabledSchemes=""
-Djdk.attach.allowAttachSelf=true
-Djdk.module.illegalAccess.silent=true
-Djna.nosys=true
-Djna.boot.library.path=
-Didea.vendor.name=Google
-Dkotlinx.coroutines.debug=off

3、解决构建速度慢问题 

(1)问题描述 

        随着项目的增大,依赖库的增多,构建速度越来越慢,现在最慢要6分钟才能build一个release的安装包

(2)方法 

        开启gradle单独的守护进程,增大gradle运行的java虚拟机的大小,让gradle在编译的时候使用独立进程,让gradle可以平行的运行。


①在下面的目录下面创建gradle.properties文件:C:\Users\.gradle (Windows)

②在文件中增加:org.gradle.daemon=true

③优化以上用户目录下的gradle.properties文件,配置如下:

# Project-wide Gradle settings.
 
# IDE (e.g. Android Studio) users:
# Settings specified in this file will override any Gradle settings
# configured through the IDE.
 
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
 
# The Gradle daemon aims to improve the startup and execution time of Gradle.
# When set to true the Gradle daemon is to run the build.
# TODO: disable daemon on CI, since builds should be clean and reliable on servers
org.gradle.daemon=true
 
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx10248m -XX:MaxPermSize=256m
org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
 
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
org.gradle.parallel=true
 
# Enables new incubating mode that makes Gradle selective when configuring projects. 
# Only relevant projects are configured which results in faster builds for large multi-projects.
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:configuration_on_demand
org.gradle.configureondemand=true

 

到了这里,关于【Android学习】Android studio环境搭建-解决下载gradle慢&加载mainfest.xml慢的问题的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • 解决Android Studio下载gradle超时问题

      下载地址:https://mirrors.cloud.tencent.com/gradle/  

    2024年01月21日
    浏览(47)
  • Android Studio 内gradle配置失败、下载gradle失败简单解决

    腾讯镜像的Gradle 下载之后 找到对应的.gradle文件 将下载文件放到 wrapper/dists/gradle-x.x-bin/xxxxxxxxxx/   下 并解压 会出来一个 gradle-xxx-bin的文件       将文件拿到 xxxxxxxxxx中 回到android studio 重新build gradle      

    2024年02月08日
    浏览(33)
  • 记录解决Android Studio下载gradle超时问题

    大三学生,2023年3月19号晚,首次下载Android Studio2022版本并新建项目,发现在下载gradle总是连接超时,舍友则没有这个问题,用的是同一个安装包。 查阅文献太多,忘记都有哪些了,就不列出来了,都是公开的。 总结:连接不上外网的谷歌导致网络超时,通过其他方法下载好

    2024年02月05日
    浏览(83)
  • android studio gradle 下载失败解决方案

    报错如上,介绍个绝对成功的办法,看了很多文章居然都没人提到,这里的意思就是这个地址访问失败,所以有两种解决方案,一种是换代理,一种是直接更换下载地址。这里介绍第二种方法,基本都能成功,先去找到下载页面,题主写时可用界面为Gradle Distributions 然后找到

    2024年02月21日
    浏览(39)
  • Android Studio下载gradle速度慢—解决方法

    配置对所有项目起效的项目环境 查看 .gradle 所在位置 :打开 Android Studio - File - setting  文件夹中打开 Gradle user home 显示的路径,在 .gradle 文件夹中创建 init.gradle 文件,在 init.gradle 文件中输入以下配置内容 重启Android Studio即可

    2024年02月13日
    浏览(32)
  • Android studio gradle 一直提示下载,下载还下载不到超时,问题解决

    一般正常使用时gradle不会有重新加载的问题,但有时候会突然打你个措手不及。 文件从服务手动下载后放到.gradle文件夹中也是不行的,因为gradle的更新流程是必须下载完成了才会去解压,再去加载。如果你下载这一步一直不通过的话,AS是一直不去加载文件的,即使你已经下

    2024年04月11日
    浏览(35)
  • 解决:Android Studio下载gradle速度慢的问题

    配置对所有项目起效的项目环境 查看 .gradle 所在位置 :打开 Android Studio - File - setting  文件夹中打开 Gradle user home 显示的路径,在 .gradle 文件夹中创建 init.gradle 文件,在 init.gradle 文件中输入以下配置内容 重启Android Studio即可

    2024年02月04日
    浏览(35)
  • Android Studio每次打开都要下载Gradle的解决方法

    我是先下载了相应版本的gradle-bin的zip,放入对应文件夹,但是再次打开Android Studio的时候还是在下载... 于是,打开setting,搜索gradle,修改Gradle user home的路径,直接定位到.gradle文件夹,就行了。  所以有时候其实定义文件夹位置太准确反而不是好事...

    2024年02月11日
    浏览(40)
  • 保姆级——成功解决Android studio中下载gradle慢的方法

    控诉:作为计算机专业的学生,虽然说下载和使用新的软件应该是我们的家常便饭,但是每一次用新的软件,在配置和下载方面真的花的时间都要比学习这个语法更长,要命(尤其是涉及到tizi)。最可怕的是,可能开始觉得配置好了,等到后面运用的时候还会出问题 下面来

    2024年02月04日
    浏览(41)
  • 保姆式教程:MAC安装Android studio(包括安装JDK,Android SDK),解决gradle下载慢的问题

    原文链接 原文链接 下载地址 下载后双击安装包 打开Mac的终端,输入命令查询JDK的安装路径 配置环境之前需要清楚这个JDK的安装路径,如果知道就不用查 输入以上字符串,就会输出JDK的安装路径,将这个路径复制暂且复制下来,一会儿用。 然后接下来我们在终端输入相应的

    2024年02月04日
    浏览(42)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包