简体   繁体   English

Android Studio在真实设备上运行应用程序需要太长时间

[英]Android Studio Takes too long time to run the app on real device

I have a Laptop with a Core i3 processor and a 2GB of RAM, and I am using my Sony Xperia C as an alternative to the Emulator. 我有一台配备Core i3处理器和2GB RAM的笔记本电脑,而我正在使用我的Sony Xperia C作为仿真器的替代品。 When I click on debug and choose my mobile device, the Gradle starts building and it takes about 5 to 10 minutes to finish. 当我点击调试并选择我的移动设备时,Gradle开始构建,大约需要5到10分钟才能完成。 I understand that I have very low resources but I doubt that there is another reason why it takes too long time to finish building and running the app. 我知道我的资源非常少,但我怀疑为什么完成构建和运行应用程序需要很长时间才有另一个原因。

I noticed in the logcat tab that it is spending the time on sending a request and waiting for a response repeatedly.. 我在logcat选项卡中注意到它花时间发送请求并反复等待响应。

Can anyone tell me if the problem is with the hardware resources or my doubts are true about the cause being something else. 任何人都可以告诉我,如果问题是硬件资源的问题,或者我的疑问是真的是因为其他原因。

Android Studio is very resource hungry. Android Studio非常耗费资源。 I use an old Sony with Core 2 Duo and 2.5 GB of RAM, with tweaked system that running about 200MB for the operating system. 我使用的是具有Core 2 Duo和2.5 GB RAM的旧索尼,调整后的系统为操作系统运行大约200MB。 It takes about 10 minutes or more to build a project. 构建项目大约需要10分钟或更长时间。

My suggestion, upgrade your Laptop RAM to 4GB or more. 我的建议是,将笔记本电脑RAM升级到4GB或更高。 8GB should be enough. 8GB就足够了。 Now I'm working with 4GB and Corei5 where Android Studio take about < 1 minutes to run a project, but it depends of the project size and its dependencies. 现在我正在使用4GB和Corei5,其中Android Studio大约需要1分钟来运行项目,但这取决于项目大小及其依赖性。

-- UPDATE -- - 更新 -

Default setting of Windows 10 will use about >90% of your disk which will make your building process much more slower. Windows 10的默认设置将使用大约90%的磁盘,这将使您的构建过程更慢。 You could decrease it to <12% by simply turning off "Show Me About Windows": 只需关闭“Show Me About Windows”,即可将其降低至<12%:

From the Windows Menu, go to Settings, then go to System and then go to Notifications and Actions. 在Windows菜单中,转到“设置”,然后转到“系统”,然后转到“通知和操作”。 Turn off "Show Me Tips About Windows" 关闭“显示关于Windows的提示”

update reference: Disk usage always at 100% 更新参考: 磁盘使用率始终为100%

I would strongly recommend that you either upgrade your development machine's RAM (8GB or more) since 2 GB ram will be too painful for studio. 我强烈建议您升级开发机器的RAM(8GB或更多),因为2 GB内存对于工作室来说太痛苦了。

Also I recommend: open single project at a time and clean your project after running your app in emulator every time. 我还建议:每次打开单个项目并在每次在模拟器中运行应用程序后清理项目。

After upgrade your RAM, you should try to upgrade Android Studio. 升级RAM后,您应该尝试升级Android Studio。 In Android Studio v2.0.0 ++ , they support Instant Run 在Android Studio v2.0.0 ++中,它们支持Instant Run

Android Studio now deploys clean builds faster than ever before. Android Studio现在比以前更快地部署干净的构建。 Additionally, pushing incremental code changes to the emulator or a physical device is now almost instantaneous. 此外,将增量代码更改推送到仿真器或物理设备现在几乎是即时的。 Review your updates without redeploying a new debug build or, in many cases, without restarting the app. 查看更新,而无需重新部署新的调试版本,或者在许多情况下,无需重新启动应用程序。

More info about Instant Run 有关Instant Run的更多信息

In my case, I don't use debugger for monitoring app performance ...etc, So I do not install app to device (I build application only instead of run), then I use adb to install apk to device ... 在我的情况下,我不使用调试器来监控应用程序性能等等,所以我不安装app到设备(我只构建应用程序而不是运行),然后我使用adb安装apk到设备...

adb install -rst <$$path_to>.apk

path_to_apk is where my apk gets built Usually ... path_to_apk是我建立apk的地方通常......

<$$build_path>/android-build/build/outputs/apk/my.apk

I get things work with a reasonable speed , offcourse, on the cost of debugger! 我让事情以合理的速度,幕后工作,调试器的成本!
I am then trying how to activate debugging from adb! 我正在尝试如何从adb激活调试! if possible and needed. 如果可能和需要。

I recommend that you upgrade your ram so that your Android Studio will run normally (Technically speaking: It will have enough resources to use) . 我建议你升级你的ram,以便你的Android Studio能够正常运行(从技术上讲:它将有足够的资源可以使用) I use a core i3 4gb RAM system and it feels a little slow to me too. 我使用的是核心i3 4gb RAM系统,对我来说感觉有点慢。

Check this image... 检查此图片......

运行Android Studio的要求

Kill some background processes and then start your android studio (This is a temporary solution) or upgrade your RAM. 杀死一些后台进程,然后启动你的android工作室(这是一个临时解决方案)或升级你的RAM。

调试时禁用“ Instant Run然后重试。

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

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