简体   繁体   English

Android studio gradle build运行时间太长,无法构建apk

[英]Android studio gradle build running for too long time for build apk

  1. New Project. 新项目。
  2. Imported all libs using gradle build system. 使用gradle构建系统导入所有库。
  3. Gradle build successful. Gradle构建成功。
  4. Enabled gradle offline work and instant run. 启用gradle脱机工作和即时运行。
  5. Attached my device, clicked run. 附上我的设备,点击运行。 App build competed in 4 mins. 应用程序构建在4分钟内完成比赛。
  6. After few changes in code I clicked apply changes. 在代码中进行少量更改后,我点击了应用更改。
  7. App runs perfectly on device which I previously build, but when I extract the installed app(debug keys) it doesn't install on other device or same device (package currept). 应用程序在我之前构建的设备上运行完美,但是当我提取已安装的应用程序(调试密钥)时,它不会安装在其他设备或同一设备上(软件包当前)。
  8. I clicked build apk(debug) in Android studio but gradle build running forever. 我在Android工作室点击了build apk(debug),但gradle build永远运行。

Please help me friends. 请帮帮我的朋友。 There is no error in code. 代码中没有错误。 When I use Instant Run app opens perfectly on device but I cannot extract that apk to test on other device. 当我使用Instant Run应用程序在设备上完美打开但我无法提取该apk以在其他设备上进行测试。

You need to disable Instant Run first, because debug apk built with Instant Run will not run on phone with different api level from your test device. 您需要先禁用“ 即时运行” ,因为使用“即时运行”构建的调试apk无法在测试设备上具有不同api级别的手机上运行。

Then you need to clean up and build the apk. 然后你需要清理并构建apk。 If building apk seems like forever, make sure your internet connection is up. 如果构建apk似乎永远,请确保您的互联网连接已启动。

To Fix this Issue no need to enable gradle online mode. 要解决此问题,无需启用gradle在线模式。 I just cleaned Project and done rebuild. 我刚刚清理了Project并完成了重建。 Then restarted Android studio. 然后重启Android工作室。 Now it's build apk very fast. 现在它构建apk非常快。 It's recommend to enable gradle offline mode (not for initial build and when importing new libs) 建议启用gradle offline模式(不适用于初始构建和导入新库时)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM