• 当一回Android Studio 2.0的小白鼠


    上个星期就放出了Android studio出2.0的消息,看了一下what's new 简直抓到了那个蛋疼的编译速度痛点.在网上稍微搜索了一下后发现基本都是介绍视频.一番挣扎后(因为被这IDE坑过几次),于是决定自己当一回小白鼠实验一下.

    instant run

    准备

    首先,是把升级跳到最不稳定的频道,check 一下然后 update and restart,这不必说.唯一值得讲的一点在于,下完安装的时候会耗尽磁盘的资源,很卡.然后第一次打开的时候记得导入之前的设置.

    床说中的瞬间执行

    instant run需要gradle 2.8+好在ide认识到这一点,点自动更新工程,等待结果完成即可.

    更新之后,会发现gradle用上了2.8.然后下面的设置也不再是灰色.表明设置可用.我建议只勾选第一项

    此外,应用instant run的AVD需要api14+

    不足

    但是目前,该功能还是有些不完善的.这里引用原文

    Here are some code changes that Instant Run does not currently support:

    • Add/remove/change annotations

    • Add/remove/change an instance field

    • Add/remove/change a static field

    • Add/remove a static method signature

    • Change a static method signature

    • Add/remove an instance method

    • Change an instance method signature

    • Changing which parent class the current class inherits from

    • Change the list of implemented interfaces

    • Changing static initializer of a class

    使用和体会

    代码改动之后,点击run(此时的run左边有个小闪电的图标),之后即可完成迅速编译.我这边试了一下,大概2s以内.

    11:23:46 Executing tasks: [:app:incrementalDebugSupportDex]
    11:23:48 Gradle build finished in 1s 948ms
    11:23:48 Instant Run: Instant Run applied code changes.
    You can restart the current activity by clicking here or pressing Ctrl+Shift+R anytime.
    You can also configure restarts to happen automatically. (Dismiss, Dismiss All)

    还是比较快的~

     

    至于GPU Profiler,暂时用不到,就不作说明了

    这玩意大概就是用来 预览和跟踪渲染效果的吧,具体的指导可以看第三个链接.

    此外,编辑器的一些细节(窗体的大小,etc)有些许的变化,这个就自己慢慢体会了.

    总结

    总的来说instant run只是加速了项目的构建,这就是本来应该做的事情嘛~惊喜不是很多,我期待的是更快的AVD,但是目前还看不到相关消息.

    微软最近也出了AVD,但是正当我激动之时,发现这玩意要hyper-v.也就是专业版win8.1/10才有,而当初8.1升级过来全特么变成家庭版,心凉了一截.

    参考链接:

    Android studio 2.0下载链接

    https://sites.google.com/a/android.com/tools/tech-docs/instant-run%20

    https://sites.google.com/a/android.com/tools/tech-docs/gpu-profiler%20

  • 相关阅读:
    linux查看系统类型和版本
    javascript 中的继承实现, call,apply,prototype,构造函数
    redis原理分析
    HashTable 简述
    算法之 快速排序
    react js 之生命周期
    Java源代码编译过程
    Java字节码文件结构---概述
    Java程序运行时内存划分
    数据结构--汉诺塔--借助栈实现非递归---Java
  • 原文地址:https://www.cnblogs.com/zeusro/p/5006746.html
Copyright © 2020-2023  润新知