
Android Studio 4.0 - raybb
https://android-developers.googleblog.com/2020/05/android-studio-4.html
======
matchbok
Did they build a real simulator yet, like iOS? Note, not an emulator, which
does hardware stuff. A simulator, so we don't have to use up our entire
machine to run another operating system just to run a java app.

Or finally fix the activities and fragment mess?

~~~
lfy_google
I'm on the emulator team; we've considered this route before, but the hard
part about maintaining a simulator is that the contact surface with the host
OS is much larger, making it so that we would essentially have to port the
current year's version of Android, with all java/C userspace APIs, to all
wanted host OSes. This would require much greater resources dedicated to this
porting than we're able to handle, and/or we'd need to make the hard choice of
only maintaining certain Android versions and skipping certain ones
completely. It would also be very difficult to maintain fidelity.

With full virtualization, the contact surface is restricted to a few low level
bits in the kernel along with a few HALs/drivers that need to talk to the host
for meaningful/fast I/O, like input/network/graphics, and everything else can
be kept stock with no modification. This allows us to ship largely the same
binaries that would go on a dedicated Android device and have it be able to
run on windows/macos/linux easily, and it's how we've been able to keep up
with the pace of yearly Android releases.

Edit: Oh and note that we are totally aware of and bummed out by emulator's
increasing resource usage as android version bumps up, to the point we're
afraid that the next one will finally be the one that really needs all
resources of a modern PC; as such, we're looking into ways to minimize the
cpu/ram/disk footprint of the system images, keeping only the bits that are
actually needed for testing apps (with Google Play Services, and being better
at maintaining/promoting more stock AOSP images in the case where GMS isn't
needed)

~~~
dingdongding
Have you thought about streaming emulators from the cloud? I know it sounds
crazy but if we can stream games, why not android emulator?

~~~
defied
We’re doing just that at [https://testingbot.com](https://testingbot.com) :
stream android emulators and even physical devices. You can control these
through your own browser.

~~~
therealasdf
I'm very interested in this. I usually run into crashes in production on
specific devices that I don't own. It would be nice to be able to reproduce
them on a virtual device. FYI, the site is not loading atm.

------
krm01
I’m still amazed and somewhat annoyed by the filesize of Android Studio. And
as you keep adding simulators and what not (which inevitably happens), before
you know it, Android Studio occupies 20% of your entire disk space.

~~~
Twiebie
Same thing goes for Xcode.

~~~
Analemma_
Same for Visual Studio (the full one, not VSCode). I think this just the
nature of these giant IDEs that let you target multiple OS versions: if you
want to faithfully target/simulate multiple operating systems, you need both
the OS binaries and the platform libraries for each of them. As the saying
goes, couple gigs here, a couple gigs there, and soon you're talking about
real disk space.

~~~
ploxiln
Check out Zig: in less than 50 MB, it supports cross-compiling on any major
os/arch for any other major os/arch, and it compiles most plain C code, and it
includes libc headers for linux/mac/windows.

[https://ziglang.org/download/](https://ziglang.org/download/)
[https://ziglang.org/#Cross-compiling-is-a-first-class-use-
ca...](https://ziglang.org/#Cross-compiling-is-a-first-class-use-case)

50 million bytes is really a lot of bytes, it's just that everyone has become
accustomed to orders-of-magnitude bloat, and doesn't realize the 100x
duplication and inefficiency which sneaks into just about every part of
computing where it can get away with it.

~~~
kbumsik
Zig is just a language compiler, isn't it? It is comparable to clang, gcc, or
Visual C++ compiler. Why are you comparing it with a fully featured IDE?

~~~
ploxiln
... because it was claimed that the IDEs are many gigabytes because they "let
you target multiple OS versions". Well, you can get the required essence for
targeting multiple operating systems and architectures in 50 MB. If a "proper
IDE" for a single OS/arch/platform is 500 MB, then one for "multiple" could be
about 550 MB. So how does it get up to 5 GB or more? Convenience and junk.

~~~
genocidicbunny
Just because Zig can compile for multiple platforms, doesn't mean it can
target those platforms like those IDEs could.

For example, with Visual Studio, a large part of the installation footprint
are the various SDKs you need to actually build a realistic Windows
application (that interacts with the OS, maybe does some COM stuff, brings up
a GUI, uses networking..etc) There are also multiple versions of these SDKs,
especially the Windows SDKs. Visual Studio also supports a lot of languages,
and for some of these languages, there is support going back to very old
versions and tech stacks. You can still build Windows XP compatible
applications in modern Visual Studio versions.

Can Zig talk to COM? Can it set up a DXGI swap chain? Can I pop up
notification toasts as simple as calling one function? How do you package Zig
apps for the Microsoft Store?

So yes, you can compile Zig programs for multiple platforms, and these can run
on those platforms. But once you start getting into actually interacting with
those platforms, you will need all those things you call convenience and junk.
Libc is just a fraction of what you need to make applications for a platform.

------
pcx
1\. The selected Java SDK API desugaring, though limited, is much awaited.
Little things like supporting `java.time` up until API Level 14 make it less
painful, don't have to end up using Joda Time even though it officially is not
developed anymore.

2\. Good to see Google focus on animations finally

3\. The CPU profiler looks amazing

The transition to androidx has been slow and painful. But overall Android dev
experience is improving consistently

~~~
carstenhag
Mostly [source needed] people use(d)
[https://github.com/JakeWharton/ThreeTenABP](https://github.com/JakeWharton/ThreeTenABP)
used for this.

------
dep_b
I miss doing my designs visually, I used storyboards again for a demo app and
getting the layout working for all screen sizes just worked once I got the
layout right in interface builder.

With coded constraints you need to do that change code / restart cycle,
especially with more complex layouts and SwiftUI isn’t there yet.

Those motion guides look like what Flash used to have, dearly missed.

~~~
nicetryguy
I don't miss many things about Flash / Actionscript but boy do i miss that
development GUI.

Sure, HTML 5 can do everything Flash can do but there is nothing even close to
that envioronment for making interactive animation and full games.

------
dgellow
> Clangd support for C++

That’s interesting, how common is it to write C++ for Android applications,
and with Android Studio? I’m not that informed regarding android stuff but I
understood that the native development kit wasn’t really that well maintained,
making C++ an 2nd class citizen when compared to Java (and maybe Kotlin?).

I would guess it’s mostly used for games?

~~~
tick_tock_tick
C/C++ is only the only choice for cross platform business logic between
windows/ios/android/macos.

~~~
nicoburns
You can also use Rust (and some big companies are - Cloudflare is shipping
Rust on Android/iOS for their warp VPN, and Dropbox uses it in their desktop
sync client (not sure if the same code is also used on mobile)).

~~~
javajosh
Very interesting. Do you have any sources for people targeting Android with
Rust?

~~~
nicoburns
\-
[https://github.com/cloudflare/boringtun](https://github.com/cloudflare/boringtun)

\- [https://blog.cloudflare.com/warp-technical-
challenges/](https://blog.cloudflare.com/warp-technical-challenges/)

\-
[https://www.reddit.com/r/rust/comments/8ygbvy/state_of_rust_...](https://www.reddit.com/r/rust/comments/8ygbvy/state_of_rust_for_iosandroid_on_2018/)

\- [https://medium.com/visly/rust-on-
android-19f34a2fb43](https://medium.com/visly/rust-on-android-19f34a2fb43)

\- [https://medium.com/visly/rust-on-
ios-39f799b3c1dd](https://medium.com/visly/rust-on-ios-39f799b3c1dd)

------
javajosh
It's really interesting to me that, in the end, we build interactive screens.
Consider all the complexity it takes to build one of those for Android (or
iOS), and what it takes to make a a screen for the browser. One requires a
whole stack of big, complicated, brittle tools. The other can be achieved in a
single html file.

~~~
Yuioup
You forget that web browsers are very complex programs running on operating
systems which in turn also are complex programs.

If you can boot an entire operating system with a single html file, THAT would
be impressive.

~~~
londons_explore
It really depends where you want to draw the line between the code which is
part of the "OS" and the part that is the "app". The web platform puts as much
as possible into the "OS", while android has far less, so the app has to
include much more.

~~~
g_p
I'm not a defender of the "modern web" recursive dependencies approach to
building js sites, but the one thing the web platform seems to do better than
Android is let the developer focus more onto their own logic, rather than
reimplementing basic boilerplate activities. Sadly I've never really found a
"one layer higher" overlay for the Android APIs to let developers take
advantage of good boilerplates by default - I'd rather not pretend I'll
implement data loading from an array or db into a scroll view better than
someone else that has thought it through and understands the platform, because
I know I won't!

~~~
kllrnohj
The "one layer higher" for Android is Jetpack:
[https://developer.android.com/jetpack](https://developer.android.com/jetpack)

Eg for "I'd rather not pretend I'll implement data loading from an array or db
into a scroll view better than someone else" that'd be the Paging library:
[https://developer.android.com/topic/libraries/architecture/p...](https://developer.android.com/topic/libraries/architecture/paging)

~~~
g_p
I will take a look at Jetpack - it does sound promising as the "next layer
up". I was hoping Flutter might try to fill this space - it feels to me that
there's no inherent need for the "higher layer" to be platform specific,
although there's probably an impetus for Google/Apple to make it so, from the
perspective of ecosystem control, developer mindshare, and simply reducing
effort to build and maintain.

At least skimming the docs and watching the introduction videos, it does
sounds like JetPack might be what I'm looking for! Thanks

------
tjbiddle
I haven't touched Android development in... Maybe 7 years? And even then,
wasn't really in the trenches. I have to imagine boat loads have changed since
then.

If I wanted to poke around with some hobby projects, where would be the best
place to start from scratch with all the best practices and development tools?

~~~
on_and_off
Download Android Studio,

read the kotlin koans (assuming you are not familiar with kotlin), they are
the best way to get used to that language if you know java, and kotlin is much
more pleasant to use than java

Best practices and tools might be harder, a LOT has changed in the past 7
years.

Maybe
[https://github.com/ZacSweers/CatchUp](https://github.com/ZacSweers/CatchUp)
as a sample ?

After that, it depends whether your hobby is to write an android app, or if
the resulting product is hobby.

if it is the former, Compose is lots of fun and will be a big leap in android
development. You can already use the dev version.

MVI has also deeply changed how I code Android apps. Again, maybe not needed
for the level of complexity of an hobby app unless you want to toy with
something different.

~~~
scns
What is MVI?

~~~
lubonay
MVI stands for Model-View-Intent. It's a state management pattern that uses
unidirectional flow. Basically you send events (Intents, similar to Redux
actions, not to be confused with the Android Intent class..) to your Model,
which does a state update and sends out the updated state to the View.

~~~
scns
Ah okay. Seems to be another name for Model View Update aka The Elm
architecture aka Flux pattern.

~~~
on_and_off
I just skimmed [https://guide.elm-
lang.org/architecture/buttons.html](https://guide.elm-
lang.org/architecture/buttons.html) .

It does sound very familiar ! Yeah there is nothing new there (and MVI on
Android having been heavily influenced by what's going on on other platforms
is readily acknowledged).

It is newish (it has been there for several years now) as far as "trendy"
Android architecture patterns go.

We started with a bad implementation of MVC for several reasons :

\- what Google ended with (which does not look like it fits what they
initially intended, but I digress) with its god Activities has encouraged the
community to go in that direction.

\- when Android was first released, the smartphones of the time were heavily
CPU and memory constrained. The way applications were built was to best fit
these constraints (sometimes in naive ways).

And again, I am not advocating for all problems to use MVI or that it is the
one architecture to rule them all. Just something interesting that was very
likely not in gp mind 7 years ago.

------
pjmlp
> Java 8 language support update: APIs you can use regardless of your app’s
> minimum API level

Meanwhile in the real world, [https://jdk.java.net/14/release-
notes](https://jdk.java.net/14/release-notes)

~~~
MattGaiser
Has the Android world moved to Kotlin then?

~~~
vbezhenar
Yes, Kotlin is preferred language now. Some new Google libraries are targeting
Kotlin first. You should not use Java for new projects.

~~~
javajosh
Kotlin is great, but if you're looking for max maintainability in the next ~10
years Java is better. It's just so much easier to hire for Java!

~~~
Larrikin
As an Android dev, I disregarded any company hiring that was not transitioning
to Kotlin. It was a major red flag if the project was relatively new. My
personal project on spring boot is completely powered by Kotlin and I fully
expect KotlinJS to be ready for production in a year or so for full stack
development.

Writing in Kotlin really is a nicer experience and with near full access to
all the legacy java libraries I would never want to switch back even with the
small improvements java has made to be more like Kotlin. I highly suspect as
the number of java devs that are exposed to Kotlin increases the number of
devs happy to write in Java over Kotlin (or Scala) will decrease. Android
going Kotlin first was in part justified by giving the decision makers a short
period of a week or two to get adjusted away from java and see how they felt
about the language in comparison

~~~
javajosh
I agree with everything you say, but that transition will take time. I think
Kotlin is a great language, and combines a lot of the best strengths of others
while not giving up that JVM tooling goodness. However, I think you still need
to have good Java chops to work with Kotlin, at least to deal with those
dependencies. In fact, its almost exactly the situation that TypeScript has:
yes, its a good language, but you can't really use it well unless you know
JavaScript (and in particular, ES6) really well. Edit: sorry, I'm really
talking more generally than Android. You're probably right about hiring for
Kotlin for Android instead of Java. But Kotlin is targeted at _everything_ ,
and for that I think it's probably good to wait a bit.

------
trashburger
3D layout reminds me of Firefox's 3D view, which I sorely miss. Wish they
brought it back, but it seems unlikely.

~~~
_ZeD_
I never understood why they remove it

------
tomerbd
Is android studio same as having IntelliJ ultimate with android plugins? Is it
a form of the community edition? Will I miss features getting into IntelliJ
because it's a fork?

~~~
kllrnohj
Android Studio has C++ & JNI support which IntelliJ Ultimate doesn't (you have
to use Jetbrain's CLion instead for that), which is insanity.

In terms of Android features Android Studio is more than just the android
plugins, but if you like the latter then go for it?

------
deussum
Lots of improvements for the Gradle plugin, but no mention of Bazel?

~~~
tomlu
Me and my team made that plugin. It initially came from the same org that
makes Bazel (rather than the other way around), but I think there's now a
small team in the Android org that support it.

Nevertheless, Gradle is currently much more popular than Bazel for Android
development so it makes sense that this is where the focus is.

~~~
mwcampbell
Do you know if any real, non-trivial Android apps are being built using only
Bazel?

~~~
tomlu
The majority of all Android apps produced by Google are, and I have worked on
one myself.

------
locusm
What's the impact for Flutter devs?

~~~
kdot
Dart, and Flutter plugin aren't supported.

~~~
sebe
Flutter on studio 4 is working fine for me onlinux, just had to enable and
upgrade the flutter and dart plugins, only tried on flutter master channel
with linux and web devices.

------
habosa
The new layout tools look great, I'm excited to try them. Especially the
revamped Layout Inspector.

Also I noticed that the final 3.x minor release was much faster on my Mac than
any of the others before it. I hope 4.0 keeps or improves the performance.

------
TuringNYC
What program did they use to do the SpeakerVideo-in-ScreenShare layout they
used on the site
([https://youtu.be/f1fHPqAYj5I?t=292](https://youtu.be/f1fHPqAYj5I?t=292))

~~~
capableweb
You could do that in basically any video editor that supports multiple layers
and masks. Blender is an open source (3D) editor where you can do this with.

Most likely they are using one of/combination of: After Effects, Premiere Pro,
DaVinci Resolve, iMovie and/or Final Cut Pro as those are the more standard
tools in the industry.

~~~
PunksATawnyFill
I'm curious: Why would you use Blender for this? I consider it a 3-D modeling
tool, not a video editor.

Then again, I just started using it. So far I'm pleasantly surprised at its
UI. After using the detestable UI in GIMP (and the somewhat hokey-looking one
in Audacity), I didn't expect much from open source.

~~~
capableweb
> I'm curious: Why would you use Blender for this? I consider it a 3-D
> modeling tool, not a video editor.

Because it has a nice video editor in it, that's useful for lots of things.

Might be hard to get into if you never used Blender before. But if you've done
3D modelling in Blender, you'll be pleasantly surprised that your intuition of
how to move, scale and generally edit stuff works the same in the video editor
as in the rest of Blender.

------
dirtylowprofile
Android Studio is 1.28Gb memory right now on my MBP. I bet this is normal and
is way more memory hog than the previous version.

------
rraghur
is there hw virtualization on amd processors yet?

~~~
lfy_google
Yes, you can use the new AMD Hypervisor or use Hyper-V/WHPX, depending on your
needs:

[https://developer.android.com/studio/run/emulator-
accelerati...](https://developer.android.com/studio/run/emulator-
acceleration#choose-windows-hypervisor)

(Edit: On Linux, KVM for AMD should work already; this advice is for Windows
hosts only)

------
illuminated
The very first thing that crossed my mind while reading about the motion
editor was: "here comes the Google's 'Macromedia Flash' for mobile".

~~~
anoncareer0212
doesn't make any sense, this is for adding animations to apps, not a
proprietary format for distributing animated content

~~~
illuminated
Yeah, but the animation editing resembles of the same thing done in MM Flash.
And I haven't seen that in many many years. That's where the thought came
from, not anything else.

------
misotaur
Cant wait for the snap to be updated.

------
ajharrison
As Apple is (trying) to move away from a behemoth Xcode, Google is moving
closer to their version of it.

~~~
agildehaus
How is Apple moving away from XCode?

~~~
Austin_Conlon
The parent is maybe just thinking of a rumored iPadOS port.

