gpt4 book ai didi

android - 卡在 Gradle 构建运行中

转载 作者:IT老高 更新时间:2023-10-28 21:54:19 25 4
gpt4 key购买 nike

在尝试在 Android Studio 2.1(在 Ubuntu 16.04 上)上构建我的应用程序时,它卡在下面的注释中:

Executing tasks: [:app:generateDebugSources, :app:mockableAndroidJar, :app:prepareDebugUnitTestDependencies, :app:generateDebugAndroidTestSources]

谁能帮帮我。

最佳答案

其实并没有卡住。 build 需要更多时间。我有将近 3 个解决方案可以解决这个问题。

解决方案一:

按照这些步骤操作将使其速度提高 10 倍,并将构建时间缩短 90%

首先在以下目录中创建一个名为gradle.properties的文件:

/home/<username>/.gradle/ (Linux)
/Users/<username>/.gradle/ (Mac)
C:\Users\<username>\.gradle (Windows)

将此行添加到文件中:

org.gradle.daemon=true

org.gradle.parallel=true

解决方案 2:

如果 Android Studio 有代理服务器设置并且无法访问服务器,那么构建需要很长时间,可能是它试图访问代理服务器并等待超时。当我删除代理服务器设置它的工作正常。

在 Android Studio 中转到 File -> Settings -> Build, Execution, Deployment -> Build Tools -> Gradle

勾选'Global Gradle settings'

下的 'Offline work'

它将减少 90% 的 gradle 构建时间。


解决方案-3

如果您使用的是 Google Play 服务,请确保您没有在 Gradle 构建脚本中使用它:

compile 'com.google.android.gms:play-services:8.3.0'

仅使用您的应用真正使用的那些 Google API。如果您使用的只是谷歌地图,您会使用这个:

com.google.android.gms:play-services-maps:8.3.0

当我这样做时,我的编译时间从 2 分钟多到 25 秒左右。有关可以选择性编译的 Google api 列表,请参阅:

https://developers.google.com/android/guides/setup

资源链接:

  1. Android Studio gradle takes too long to build
  2. Discussion about stuck in gradle build

解决方案#4:

Arun George已评论以下解决方案。

the issue was due to certain 32 bit libraries missing. Had to do sudo apt-get install lib32z1. Adding to gradle.properties helped reducethe build time.

关于android - 卡在 Gradle 构建运行中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37063217/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com