We've lifted the lid on the Android Studio Box
and pulled out Instant Run, a fast and shiny new emulator,
a new GPU profiler and all the new features
and improvements of IntelliJ 15.
I'm Reto Meier.
It's Android Tool Time time, and this is Android Studio 2.0.
[MUSIC PLAYING]
Instant Run is a new feature that,
once enabled, lets you build and deploy incremental changes
to your app within a few seconds,
dramatically improving the speed of your test and debug cycles.
Once you have your app up and running, hitting Instant Run
after making code changes such as changing this chessboard
from 2D to 3D and modifying the size and color of the pieces,
will perform a hot swap, sending only the changed code
to your app.
The affected methods are overridden,
and your code changes are applied in real time
within the running app instance.
Hot swapping works by injecting code where you make changes.
Your app isn't restarted, so memory allocations
remain unchanged, meaning class initializes won't be re-run
and static variables aren't initialized.
Existing instances and constructs
like Fields and Singletons are left untouched.
Changing resources, such as editing colors, strings,
or even layouts will send the modified resources
file to the running app.
And you will be able to see it when the activity is
restarted-- called a warm swap, which
will do for you automatically if we detect that it's necessary.
Some changes such as modifying your manifest or changing
layout IDs currently trigger a full build.
Exactly which changes will cause a full rebuild
versus a cold or warm swap will change as Instant Run improves
and evolves.
So rather than listing them here in detail
and having this video become quickly outdated,
you can find the details in the Docs.
Instant Run works with all emulators
in every recent physical device.
In fact, on every platform version
all the way back to Ice Cream Sandwich.
Not content with Instant Run, Android Studio 2.0
also improves each step of the full build and deploy process.
So even full builds happen more than 2 and 1/2 times faster.
The first time you hit Run or Debug
for your code or each time you do a clean build,
your code is compiled and converted to dex files,
is optionally shrunk, optimized, and obfuscated with Proguard
and has its classes and resources
packaged all before it's uploaded to the device
and installed.
Android Studio 2.0 has improved each of these steps,
starting with dx.
We have reduced time here by over half,
primarily through improving the dx merger algorithm.
Now that merging dex dependency modules is lightning fast,
we gain significant gains from pre-dexing them and not
re-dexing them if they haven't changed.
So if your project has a lot of modules,
you'll see significant gains here.
We've also modified dx so that it now runs in process,
and you can specify running up to four dx
instances in parallel.
This has significant advantages, as we no longer start a new VM
for each dx instance, keeping the GIT more opportunity
to optimize code and removing the overhead of starting
and running multiple parallel VM instances.
If you're using Proguard, it creates a single job
that effectively disables the pre-dexing advantages
that we just gained.
So we developed a new shrinker to use in debug builds.
It doesn't replace Proguard, it just
replaces it's shrinking functionality.
So you'll still need to run Proguard on release builds
to optimize and obfuscate your code.
But for debugging the shrinker is much faster
by including some incremental support
and critically by not re-dexing dependencies.
To improve AAPT packaging times on full builds,
we now ask you to select a deploy target
before your app is built. We'll check
what resources are required for that particular device.
For example, initially we'll only package and push
the appropriate image resource resolutions.
And future Android Studio releases
will expand that to include resources such as ABIs Legacy
MultiDex.
To improve deploy times, we improved the ADB
push-pull protocol, making it very fast
to deploy to an emulator, which seems like a really good reason
to improve the emulator UX and make it really, really
ridiculously fast.
In fact, running the new emulator
on typical dev hardware is faster than
using a physical Android device.
To achieve this without an SMP support
to take advantage of host multi-core architecture
and optimize GPU, IO, and CPU performance.
At the same time, we completely rebuilt the emulator UI.
It now includes a toolbar to enable actions
like screen rotation and screen shots
and support for deploying APKs through drag and drop.
You can rescale the emulator frame by dragging a corner,
modify device hardware changes like GPS,
cellular network conditions, battery state,
and incoming phone calls or texts.
We've also made it easier to keep up to date.
The IDE will prompt you when there's a new emulator
available for you to download.
If you're building something graphics intensive,
like a game, you can take advantage of our new GPU
profiler and debugger.
It lets you record and replay the entire GPU stream frame
by frame, allowing you to inspect the GPU
state at each stage and help you understand
what caused each specific rendering outcome.
You can select an individual frame
by either the top bar or the GPU Commands panel.
Once you select a frame, the frame buffer window
will update to show that frame's contents.
You can also see and inspect each individual command and GL
call that was used.
You can also use the GPU State window or the Textures tab
to explore GPU state at the time of your selected frame or draw
calls.
Android Studio 2.0 is built on IntelliJ 15, which
offers improved stability and a number of new features,
including improvements to the built-in integrations
with version control systems, such as support
for rebase on GIT and cool new features like Find in Path,
and Distraction-Free Mode.
There's also a unified user interface for testing
that includes a Test Run a Tool window, In-line Statistics,
and a Test Result History.
We've built on top of those test improvements,
allowing you to have both Android and unit tests
source sets active while you develop,
enabling refactorings across those source sets.
We've also worked closely with Google Search
to make it easier to create deep links within your app,
including static code inspections
to check that your links are correctly configured
and real time testing to confirm Google can index
and render your app pages correctly.
In future episodes of Android Tool Time,
we'll dive deeper into these and other new features
from Android Studio.
So subscribe to Android Developers on YouTube,
and check out the Android Tool Time playlist.
And remember, if you've been taking your breaks based
on building and deploying your app,
you may want to start setting alarms to remind you to eat
and drink at regular intervals.
That's Android Studio 2.0, and this was Android Tool Time
time.
[MUSIC PLAYING]