News for hackers. Stuff that matters.
Re:Android Studio 4.0 by matchbok on Thursday May 28, 2020 @04:55PM (#23342472)
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?

Re:Android Studio 4.0 by lfy_google on Thursday May 28, 2020 @08:27PM (#23344884)
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)

Re:Android Studio 4.0 by pjmlp on Friday May 29, 2020 @02:08AM (#23346733)
As anecdote I don't run the emulator since years, as I am not going to buy a last generation PC to keep running it at average speeds.

On all my PCs it is faster to build to device than having to deal with the emulator competing with Android Studio for hardware resources.

Not everyone has Google level budgets for hardware.

Re:Android Studio 4.0 by kllrnohj on Friday May 29, 2020 @01:45PM (#23353090)
Since the switch to x86 images with VT-x acceleration & GPU pass-through the emulator has gotten massively faster.

Neither of which required anything resembling a latest generation hardware. Try it again before you pretend your experiences years ago are still relevant.

Re:Android Studio 4.0 by pjmlp on Friday May 29, 2020 @04:46PM (#23355330)
Than why does HAXM refuse to install on this computer?

I tell you why, you have forgotten to mention that "Extended Page Tables (EPT), and Unrestricted Guest (UG) features" are also required.

Re:Android Studio 4.0 by kllrnohj on Friday May 29, 2020 @06:36PM (#23356389)
Which are 12 & 10 year old features, respectively.
Re:Android Studio 4.0 by pjmlp on Saturday May 30, 2020 @05:29AM (#23359778)
Which goes back to my original post,

> Not everyone has Google level budgets for hardware.

Given that my current one runs Windows 10 64bit Pro, Visual Studio 2019, OpenJDK 14, clang 10 and Eclipse 2020‑03 just fine, I am not upgrading a perfectly working computer just to make Android emulator, or are you offering to get me one?

Specially since it was a Google's decision to drop support for its capabilities around Android 7 emulator release.

Re:Android Studio 4.0 by kllrnohj on Saturday May 30, 2020 @06:07PM (#23365207)
And your point is obviously ridiculously untrue. You're complaining about poor performance (not that it doesn't work, mind you, just that it's slow), while also refusing to upgrade to a system from the last decade.

You can get a system that will run the emulator with great performance for less than $50 on Ebay. There's no possible way to describe or classify this as requiring "Google level budgets for hardware." If you can't afford to upgrade that sucks, but you also can't at all make a reasonable complaint about performance when insisting on using a 10+ year old system.

Re:Android Studio 4.0 by airstrike on Friday May 29, 2020 @01:53AM (#23346662)
If we're all throwing spaghetti at the wall here, what do I know, but maybe create an android-sdk OS that one may boot into and is heavily optimized for (speedy) android development?
Re:Android Studio 4.0 by lfy_google on Friday May 29, 2020 @11:38AM (#23351250)
Yep, that basically sums up what we're looking into---a system image that still keeps up with the latest API levels and features introduced in the latest Android OS, but has minimal impact on resources.
Re:Android Studio 4.0 by dingdongding on Thursday May 28, 2020 @10:51PM (#23345817)
Have you thought about streaming emulators from the cloud? I know it sounds crazy but if we can stream games, why not android emulator?
Re:Android Studio 4.0 by lfy_google on Thursday May 28, 2020 @11:17PM (#23345944)
Thanks for the interest! We've been exploring this in limited ways; for example, https://github.com/google/android-emulator-container-scripts contains a set of Python/Docker/JS scripts for setting up WebRTC streaming of emulators remotely. More to come soon.
Re:Android Studio 4.0 by defied on Friday May 29, 2020 @06:53AM (#23348476)
We’re doing just that at https://testingbot.com : stream android emulators and even physical devices. You can control these through your own browser.
Re:Android Studio 4.0 by therealasdf on Friday May 29, 2020 @08:23AM (#23349114)
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.
Re:Android Studio 4.0 by mook on Friday May 29, 2020 @12:05AM (#23346160)
With WSL2 being a full(-ish) VM, running Android on a Linux base might be interesting (especially when using a Linux host, see the other anbox comment). Not sure how to deal with macOS though.

And yeah, as of Android Studio 3.x (was waiting for the official 4.0 release), it was trying to nudge towards using the Google Play Services images pretty hard.

Re:Android Studio 4.0 by izacus on Friday May 29, 2020 @02:58AM (#23347006)
> With WSL2 being a full(-ish) VM, running Android on a Linux base might be interesting (especially when using a Linux host, see the other anbox comment). Not sure how to deal with macOS though.

But this is pretty much what Android Emulator is - a fullish VM on a Linux base.

Re:Android Studio 4.0 by 2ion on Friday May 29, 2020 @04:24AM (#23347602)
Yes, but that's different in that it's x86 on x86 so you can use hardware paravirtualization features for maximum performance (through HyperV). ARM on x86 can't use hardware virtualization features, you have to run it all in software, which is why it's slow. Big value in getting rid of the architecture mismatch.
Re:Android Studio 4.0 by izacus on Friday May 29, 2020 @04:51AM (#23347778)
Android Emulator has been (by default) x86 for years now and it's using both hardware paravirtualization and even OpenGL passthrough.
Re:Android Studio 4.0 by dtech on Friday May 29, 2020 @03:45AM (#23347309)
I thought WSL was a compatibility layer similar to Wine, not a full VM?
Re:Android Studio 4.0 by moooo99 on Friday May 29, 2020 @04:47AM (#23347755)
The original WSL(1) was. However, the new version, WSL2, brings a lot of architecture changes. Now its basically a virtualized Linux running in Hyper-V. The nice thing about that new architecture is that now applications like Docker can use WSL2 to run the containers which was not possible with previous versions.
Re:Android Studio 4.0 by Osiris on Friday May 29, 2020 @04:37AM (#23347683)
WSL1 was a translation layer. WSL2 is a VM.
Re:Android Studio 4.0 by CameronNemo on Thursday May 28, 2020 @10:10PM (#23345580)
Have you considered https://anbox.io ?
Re:Android Studio 4.0 by lfy_google on Friday May 29, 2020 @12:33PM (#23352105)
Thanks, I've read about this before but just went over it again in more detail yesterday with a fresh look.

So this is basically the simulator situation, but with easier management of which libraries the guest userspace can dlopen and files to read()/write().

It's much like current Android-on-ChromeOS capabilities where containers are used to isolate where the "guest" userspace libraries are stored, so that it's not necessary to interop well with things like the host version of libc for example.

However, the problems come when considering the interface to the host kernel and hardware. Here are just two of the showstoppers:

1. Android expects to run on a particular range of kernel versions and configs each release. Fidelity is sacrificed to run with a wide range of Linux host kernel configurations. It's also easy for components on the host system such as SELinux to interfere with guest operation (and Android itself expects to use its own version of SELinux...so which one wins in the end?).

2. Further customization in the guest userspace needs to be made to account for needing to interop with a regular Linux system; e.g., input/network/display will be much more code that touches various parts of guest userspace and potentially hurts fidelity versus the VM abstraction where they are fake hardware and no customization of guest userspace is needed.

There are also isolation issues that involve more delicate dances, such as how to prevent runaway resource usage in the container from hogging the whole system (VMs merely waste the #vcpus + RAM dedicated to them; while that can be a lot compared to the host, it's explicitly controllable).

These problems sound less serious on the surface versus porting the Android framework directly to the host OS, but in the end it's basically the same level of essential complexity; containers just let you remove the incidental complexity of guest userspace libraries leaking into your /usr/lib and interop w/ your filesyste.

And once we try to run on non-Linux systems we're back at square one needing to port all userspace code to the host OS (Unless you're running Docker on macOS/Windows in which case you'd be creating a VM again, sacrificing all the benefits of containers versus VMs while keeping the complex customizations).

This is probably why Microsoft is pushing WSL2, ChromeOS skipped Android 10 support and is looking into ARCVM, and anbox is still running Android 7.1.1 (w/ plans to update but skipping releases in the meantime).

Re:Android Studio 4.0 by jsolson on Friday May 29, 2020 @02:24AM (#23346818)
Mind pinging me internally? Username in profile.

I have... an idea.

Re:Android Studio 4.0 by vbezhenar on Thursday May 28, 2020 @05:26PM (#23342871)
I think that emulator is vastly superior option as it uses real Android running exactly the same code as your phone. I never had any issues with performance (with hardware acceleration). May be on extremely weak laptops it might cause issues, but Android Studio probably will be unusable there at all.
Re:Android Studio 4.0 by qwerty456127 on Thursday May 28, 2020 @07:54PM (#23344579)
Android emulation (I've tried both the bundled emulator and VirtualBox+RemixOS) is the most insanely slow piece of software I've ever seen in my life. It feels like if I were running Windows10 on an original 80386. My laptop is Core2Duo with 4GB RAM, IntelliJ IDEs and everything work great (especially after I've upgraded my HDD to an SSD), desktop and server OSes work great in VirtualBox but Android feels like playing chess via mail. Why does it have to be heavier than desktop Linux&Java?

I don't want to upgrade the PC as I love it the way it is and it's enough for everything else. I feel like I'd like to make a simple app for my phone occasionally (just for fun and to make something in my life easier) but emulation seems impossible.

Re:Android Studio 4.0 by serf on Thursday May 28, 2020 @08:11PM (#23344731)
>My laptop is Core2Duo with 4GB RAM

i'm with you that android emulation is pretty slow, but your machine is reaching near parity with many of the devices that run the platform you're trying to emulate.

it's nearly always the case that an emulator host has to have a significant performance margin over the guest just to account for the inaccuracies/inconsistencies/hacks that are involved in mimicking a system on a dissimilar hardware platform.

Re:Android Studio 4.0 by qwerty456127 on Thursday May 28, 2020 @08:17PM (#23344785)
I would be Ok emulating the slowest Android phone of those which existed some years ago - I bet it was much weaker than my actual laptop yet not nearly as slow as an emulation I actually get. I'm not interested in using NDK, 3D graphics or any bells-and-whistles in my Android apps.
Re:Android Studio 4.0 by kllrnohj on Thursday May 28, 2020 @08:44PM (#23344998)
Make sure to customize the AVD then and use a much lower resolution. If you pick a default like the Pixel 3 it'll be running at a resolution that really doesn't work if you're trying to share 4GB of RAM with a host OS, IDE, and whatever else you have open.

EDIT: Also make sure you've enabled VT-x if your laptop has it.

Re:Android Studio 4.0 by kelnos on Thursday May 28, 2020 @09:18PM (#23345246)
If you're targeting a fairly old Android release, that would probably be ok. But I'd bet to get decent performance on your hardware, you'd have to emulate a low-RAM, single-core phone that probably wouldn't be able to run a current Android release.
Re:Android Studio 4.0 by apocalyptic0n3 on Thursday May 28, 2020 @09:22PM (#23345272)
Most Android phones nowadays have more RAM than your laptop. That CPU is also 10+ years old and a phone running a Snapdragon 855 or 865 is going to perform 2-5x better depending on which exact chip you have and single vs multi core benchmarks. The Android emulator may not be the fastest thing in the world, but your 10 year old computer is certainly not helping.
Re:Android Studio 4.0 by qwerty456127 on Saturday May 30, 2020 @06:07PM (#23365200)
I've never actually seen a smartphone with more than 4GB of RAM (mine has 2 GB and runs Android 9 in FullHD with perfect performance). Whatever, a huge amount of ram usually is used when running heavy apps. Running the basic system + a small app isn't supposed to take anything near 100% RAM or CPU.

An Android app I want to write is going to be a single form with some text fields and some buttons, it will have simple logic but it needs to run in background, be able to read a sensor, read/write some SQLite/CSV data and play a sound occasionally. No fancy graphics bells and whistles.

This seems like a very simple task to handle, I bet it's not going to take much RAM or CPU.

Why is it so hard to emulate?

Re:Android Studio 4.0 by apocalyptic0n3 on Monday June 01, 2020 @08:07PM (#23385633)

  - Galaxy S9+ (2018): 6GB
  - Galaxy S10 (2019): 6 or 8 GB
  - Galaxy S10+ (2019): 8 or 12 GB
  - Galaxy S20 (2020): 8 or 12 GB
  - Galaxy S20 Ultra (2020): 12 or 16 GB
  - OnePlus 3 (2016): 6 GB
  - OnePlus 8 (2020): 8 or 12 GB
  - LG G7 ThinQ (2018): 4 or 6 GB
  - LG Velvet (2020): 8GB  
  - Pixel 4 (2019): 6GB
  - Xiaomi Pocophone F1 (2018): 6 or 8GB
  - Huawei Mate 20 (2018): 4 or 6 or 8GB
  - Sony Xperia 1 (2019): 6GB 
  - Moto Razr (2020): 6GB
Pretty much every Android phone maker is producing phones with at least 6GB of memory now. The flagships are heading toward 12 and 16GB now. OnePlus had more than 4GB almost 4 years ago. Only Apple, who has the benefit optimizing its OS for a small set of hardware, seems to still be running on 4GB or less on all of its phones

You're trying to emulate an entire OS here. Android 10 requires a minimum of 2GB of RAM just on its own now. You have overhead for the emulation software itself on top of that, in addition to the memory needed by your computer's OS, your IDE, your browser, etc. Android Studio alone requires a minimum of 1GB and, at least in my experience, it will use that within 5 minutes of opening up.

Not to mention, even budget phones today are at least twice as fast as the CPU you're running.

You can't expect emulated software to run well on a computer that barely even meets the minimum requirements for that software. It's ludicrous.

Re:Android Studio 4.0 by qwerty456127 on Tuesday June 02, 2020 @10:06AM (#23391126)
> Pretty much every Android phone maker is producing phones with at least 6GB of memory now

Ok. I can see no reason to care about such though. What the heck do they need that for?

> You're trying to emulate an entire OS here.

But I emulate desktop Linuxes and Windows without problems - that's entire OSes too.

> Android 10 requires a minimum of 2GB of RAM just on its own now.

Why? What does it need this much for? Anyway, I can reserve 2GB of RAM now and I'm sure I'm not going to notice too much drop in performance.

> You can't expect emulated software to run well on a computer that barely even meets the minimum requirements for that software. It's ludicrous.

As for the app - I'm sure it can't require anything near that much. As for the OS - why does Android have to require so much more than Linux and Windows do?

BTW my actual phone (Galaxy Note 3) runs Android 9 on 3 GB RAM perfectly. I never tried 3D games but everything else is blazing fast. I've been updating it (Android 4-5-6-9) for years and never noticed a glitch.

Re:Android Studio 4.0 by apocalyptic0n3 on Tuesday June 02, 2020 @12:34PM (#23392936)
> Ok. I can see no reason to care about such though. What the heck do they need that for?

> Why? What does it need this much for?

As a developer, that shouldn't matter to you. Only that it _does_ require that much. You can assume that your users will have 4GB of memory in almost all cases now, whether you agree with it or not. Your opinion on the _why_ is irrelevant, frankly.

If you can't provide that much to the emulator, you can't expect to run it smoothly. There is no magic solution to this. These things require resources that your computer does not have. If you want it to run better (or even at all), get better hardware. That's all there is to it.

Re:Android Studio 4.0 by brokenmachine on Friday May 29, 2020 @01:12AM (#23346473)
>My laptop is Core2Duo

Core2Duo was released over 13 years ago, and discontinued over 7 years ago.

Time to think about upgrading before complaining about performance issues. Especially for emulation.

Re:Android Studio 4.0 by qwerty456127 on Friday May 29, 2020 @04:07PM (#23354876)
Why, if absolutely everything except Android emulation (desktop Linux and Windows emulation work fine) and recent games (in which I am not interested) work perfectly? I've just replaced my HDD with an SSD a couple of years ago and it feels like a new PC again. I never experience even slightest discomfort when I'm not trying to emulate Android.
Re:Android Studio 4.0 by brokenmachine on Friday May 29, 2020 @11:21PM (#23358190)
Because emulation is a heavy operation. Be realistic.

Also I don't believe that PC isn't painful to use for everything else. I had a core2duo a while back and it was slowish back then.

Re:Android Studio 4.0 by qwerty456127 on Saturday May 30, 2020 @05:56PM (#23365122)
> Because emulation is a heavy operation. Be realistic.

Then why is desktop Linux and Windows emulation not nearly as slow? Windows 7+ emulation is slightly slow, especially running VisualStudio on an emulated Windows7 is painfully slow (while perfectly swift on non-emulated) but still usable if you have enough patience (Android emulation is absolutely unusable). Emulated (VirtualBox on a Linux host) Windows XP runs even faster than on bare metal.

> Also I don't believe that PC isn't painful to use for everything else. I had a core2duo a while back and it was slowish back then.

You probably did something wrong. It's not just painless, it's perfectly swift (both with the latest KDE Plasma and with Windows 7). I have a modern PC at the office (late pre-Ryzen AMD, 8GB RAM, Win10) and its perceived performance is the same. It even feels more slow (less responsive) than the Core2Duo occasionally but I blame that to Windows10.

Of course I only mean basic tasks like browsing the web, watching videos (1080p or less), juggling files and writing code (VisualStudio, IntelliJ) for small projects. Obviously any modern CPU will beat Core2Duo in video transcoding, modern games etc.

Re:Android Studio 4.0 by brokenmachine on Monday June 01, 2020 @11:48PM (#23387217)
Even a current i5 is more than double as fast per core, and likely has 12 threads instead of 2. So as a roundabout figure let's say 8x the effective speed.

VT-D makes your Core2Duo better able to emulate Windows or Linux in hardware, but not Android.

Like I said, I don't believe that a Core2Duo isn't slow for everything you mentioned. I had one at home. I wasn't doing anything wrong - I know how fast it isn't - we had hundreds at my work. Have you noticed that other commenters are saying the same thing about Core2Duo speed as me? You must have more patience to wait for your PC than myself and the other commenters.

The reason I replaced my Core2Duo was because it was slow, and I replaced it around 8 years ago!

Re:Android Studio 4.0 by dikei on Thursday May 28, 2020 @09:19PM (#23345252)
I'm sorry but I refuse to believe that you're having a great experience using IntelliJ IDEA with a Core2Duo and 4GB RAM.
Re:Android Studio 4.0 by qwerty456127 on Friday May 29, 2020 @04:08PM (#23354889)
I only used it for Scala, never actually written anything beyond a Hello World in Java. Perhaps Scala takes less resources. I also use PyCharm actively and it works much faster on Linux than on Windows (on Windows it indeed is slow).
Re:Android Studio 4.0 by apocalyptic0n3 on Thursday May 28, 2020 @09:23PM (#23345280)
Yeah, I struggle to keep my RAM usage in PhpStorm below 1.5GB. And that's with me policing its indexing and what plugins are installed. There's no way that's a good experience.
Re:Android Studio 4.0 by The_Colonel on Friday May 29, 2020 @06:22AM (#23348284)
It can be fine on smaller to medium projects (not much to index).
Re:Android Studio 4.0 by fomine3 on Thursday May 28, 2020 @08:04PM (#23344668)
Core2Duo laptop for Android dev is almost same thing like using 80386.
Re:Android Studio 4.0 by qwerty456127 on Thursday May 28, 2020 @08:13PM (#23344750)
Why does Android dev has to be this much heavier than any other task? I'm ok doing .Net, Scala and Python dev (always using the most powerful IDEs), some lo-fi machine learning, running Windows and Linux and heavy Windows apps in VirtualBox, but Android - can't emulate.

What I have resorted to is writing single-page JavaScript apps and running them in the browser so I can debug them in the host browser instead of an emulator.

Re:Android Studio 4.0 by kelnos on Thursday May 28, 2020 @09:27PM (#23345313)
Remember that we're talking about emulating an entire system here, which is very different from running an IDE (even considering that an IDE like IntelliJ is pretty heavy-weight).

Windows and Linux themselves in a VM is probably reasonably ok on your hardware because both of those OSes are built to run on non-current hardware (especially Linux; I'm running Debian buster with a current kernel on a circa 2010 single-core ARMv5 CPU with 256MB of RAM with no problems).

Android doesn't target old hardware; I wouldn't expect a current release to run all that well even on a four-year-old phone, let alone a 10+-year-old laptop with virtualization overhead.

Also the usual stuff applies: be sure you have your system's virtualization extensions enabled if it has any, use the x86 Android emulator image with hardware accel enabled, not the ARM one, etc. But that still may not be enough.

Re:Android Studio 4.0 by mwcampbell on Thursday May 28, 2020 @09:39PM (#23345401)
> circa 2010 single-core ARMv5 CPU with 256MB of RAM

Just curious, which board is that?

Re:Android Studio 4.0 by RussianCow on Thursday May 28, 2020 @08:38PM (#23344958)
How are you doing all of those things with only 4GB of memory? My wife's old laptop had 3GB, and with about 10 Chrome tabs open, the computer would start swapping and quickly grind to a halt—with no other programs running in the foreground. I just checked memory usage on my own machine and Firefox alone is using over 3GB for me, and IntelliJ another 4GB. Granted, I know many programs tend to use more memory if it's available (for caching, etc), and I also hardly ever restart my machine, but still... Running a full dev environment with 4GB doesn't seem like it should be possible, so I'm curious how yours is so functional.
Re:Android Studio 4.0 by qwerty456127 on Friday May 29, 2020 @06:12PM (#23356155)
I usually have about 50 open Chrome tabs (on my Core2Duo with 4GB RAM). Half of them YouTube (I mostly watch 360p though, I only switch to 1080p when I watch somebody coding). This could get slightly slow occasionally when I used a HDD, not even slightly slow now as I switched to an SSD. I usually have PyCharm open so I code at the same time while watching something. I only experience some minor slowness when I run a system (Manjaro) update in the background and when PyCharm re-indexes libraries after an update.
Re:Android Studio 4.0 by ac29 on Thursday May 28, 2020 @09:22PM (#23345273)
Does your Core 2 Duo processor support hardware virtualization extensions (VT-x)? Some do, some dont. If it doesnt, you'd get no acceleration in the Android Emulator, so it would be expected to be pretty slow.
Re:Android Studio 4.0 by qwerty456127 on Friday May 29, 2020 @04:15PM (#23354960)
Mine does and I wouldn't be shocked by Android being that slow if normal Linuxes didn't work perfectly. People say that's because Android lacks proper virtual video card drivers.
Re:Android Studio 4.0 by fomine3 on Thursday May 28, 2020 @08:46PM (#23345007)
Modern Android devices have almost similar (or sightly less on low-end) specs as your laptop. And your laptop should run IDE and emulator. No reason to run comfortably.
Re:Android Studio 4.0 by qwerty456127 on Saturday May 30, 2020 @06:14PM (#23365254)
You miss a point: an app I need to run in the emulator is extremely simple, almost "hello world"-like. The OS itself shouldn't take much resources. I would expect 99% of the CPU and 80% of the RAM to be unused when running such a humble app on a bare OS. Another point is I actually have VT-x so x86 Linux and x86 Windows can normally be emulated without much overhead but x86 Android is a different story.
Re:Android Studio 4.0 by krschultz on Thursday May 28, 2020 @09:06PM (#23345172)
It sounds to me like you had the emulator setup incorrectly TBH. It's bad but not that bad. Make sure you're using an x86 image, have hardware emulation enabled, have the virtualization drivers installed, etc etc.
Re:Android Studio 4.0 by tootie on Thursday May 28, 2020 @11:17PM (#23345943)
Realistic hardware emulation is way cheaper than actual hardware. You can buy yourself 32 GB of RAM or you can buy dozens of test devices.
Re:Android Studio 4.0 by qwerty456127 on Friday May 29, 2020 @04:12PM (#23354925)
You can buy yourself 32 GB of RAM only if your motherboard chipset supports that much. If it does - then that can be really cheap, especially if you consider buying used RAM - it usually works ok forever once it passes MemTest86+.
Re:Android Studio 4.0 by clumsysmurf on Thursday May 28, 2020 @06:37PM (#23343772)
A word of caution, a few times I've gone to bed with Android Studio and the emulator up; and woken up with my machine's fans running full speed and the thing about to melt down; the emulator can do funky things like take 600% of your cpu for no apparent reason after sitting there idle for hours.
Re:Android Studio 4.0 by lfy_google on Thursday May 28, 2020 @08:19PM (#23344808)
Hi, what host OS are you running? I'd like to be able to send over a build with symbols so we can profile it (or on macos use the process sampler). Let's also try `adb shell top` next time this happens; we found that when networking state changes, sometimes, the virtual radio gets in a bad state and starts spinning.
Re:Android Studio 4.0 by kaixi on Friday May 29, 2020 @11:43AM (#23351331)
I need to add

hw.audioInput=no hw.audioOutput=no

to every AVD I create. Otherwise, the Android Emulator uses 100% CPU all the time, even when it's been idle for minutes.

I'm far from the only one having the problem, see https://stackoverflow.com/questions/37063267/high-cpu-usage-...

I'm on a Macbook Air 2014, Intel i5, 8GB of RAM, 500GB SSD. Hardware acceleration, etc. all enabled.

Re:Android Studio 4.0 by lfy_google on Friday May 29, 2020 @12:59PM (#23352463)
And here's the promised emulator build (from aemubins gmail account that we use to distribute debug binaries like this):

    https://drive.google.com/open?id=1sXEQcoiNpe3Lj8yeaKLasTjqlGQwy4Oi
If you still don't get symbols from that it should be possible to build the emulator itself on macos:

install repo from depot_tools https://www.chromium.org/developers/how-tos/install-depot-to...

    pip install absl-py
    pip install urlfetch
    mkdir emu
    cd emu
    repo init -u https://android.googlesource.com/platform/manifest -b emu-master-dev --depth=1
    repo sync -qcj 4
    cd external/qemu
    python android/build/python/cmake.py

    # run
    objs/emulator -avd avdName -no-snapshot
Debugging:

    # when it spins:

    # method 1: go to activity monitor -> sample process, send over the result

    # method 2: lldb
    lldb
    process attach --pid <pid-of-qemu-system-<arch>>
    bt all #send it over

    # method 3: guest process taking CPU
    adb shell top
Re:Android Studio 4.0 by kaixi on Friday May 29, 2020 @02:01PM (#23353348)
Sorry, I'm not an expert. What am I supposed to do with the emulator-symbols.zip?
Re:Android Studio 4.0 by lfy_google on Friday May 29, 2020 @02:53PM (#23354018)
Replace your current emulator install; delete $ANDROID_SDK_ROOT/emulator then unzip it there so theres $ANDROID_SDK_ROOT/emulator again.

$ANDROID_SDK_ROOT, if not set, should be set to the SDK location in Android Studio > Preferences > Android SDK (SDK path will show up there).

Set it in your ~/.bash_profile too so it's there next time for running the emulator from the command line.

The AVD config.ini can be found in ~/.android/avd/nameofAvd.avd/config.ini .

Re:Android Studio 4.0 by lfy_google on Friday May 29, 2020 @12:35PM (#23352131)
Interesting, sounds like a live loop in some audio thread somewhere. What's your audio setup and AVD config.ini? I might be able to reproduce on my Mac.
Re:Android Studio 4.0 by distances on Thursday May 28, 2020 @07:06PM (#23344099)
> I never had any issues with performance (with hardware acceleration). May be on extremely weak laptops it might cause issues, but Android Studio probably will be unusable there at all.

I have to use MacBook 13 (2019) in my current project, and it's having troubles with the emulator. Not sure if it's about the hardware or macOS inefficiencies, but I can't wait to get back to my Linux desktop where the emulator is buttery smooth, almost feels like a part of the system itself.

Re:Android Studio 4.0 by dahfizz on Thursday May 28, 2020 @07:47PM (#23344520)
Do you know if you have KVM set up? Or whatever the macos equivalent is? The difference in emulating in software vs hardware is massive.
Re:Android Studio 4.0 by benibela on Thursday May 28, 2020 @05:45PM (#23343127)
I also need an emulator, because I have native binaries

Unfortunately, there is only an aarch64 emulator for Android 7, which does not start on my system

Re:Android Studio 4.0 by lfy_google on Thursday May 28, 2020 @08:17PM (#23344789)
Hi, Android 9 and 11 Google APIs/Play system images should have userspace ARM translation available (with ARM64 translation available in Android 11).
Re:Android Studio 4.0 by benibela on Friday May 29, 2020 @08:04AM (#23348953)
> userspace ARM translation

What does that mean? The x86 system image can run arm code? I will try that (might get confusing if there is an arm and x86 lib in the apk).

I have been using the image without google apis to save space, because my sdd is almost full

Does it reject invalid arm? I wrote my app in Pascal, and the FreePascal compiler often generates invalid assembly. Especially because I need to use the nightly build, because the last stable release does not support aarch64

Re:Android Studio 4.0 by lfy_google on Friday May 29, 2020 @12:40PM (#23352189)
Yes, the x86 system image can run ARM code. Note that the speed will be much faster than running a full ARM emulated system image because only the guest userspace bits need to be translated from ARM to x86. System calls are still marshalled to x86 calls, so memory accesses are many many times faster because (there's no need to drop into emulating the MMU).

(Also AFAIK illegal instructions are still validated and trapped as SIGILL or SIGSEGV)

Re:Android Studio 4.0 by heavyset_go on Thursday May 28, 2020 @06:24PM (#23343605)
Anbox with libhoudini might work for you.
Re:Android Studio 4.0 by oakesm9 on Thursday May 28, 2020 @05:13PM (#23342724)
That works for iOS because it shares so much with macOS. It wouldn't work for Android as it doesn't share much with the OS.
Re:Android Studio 4.0 by e12e on Thursday May 28, 2020 @05:29PM (#23342909)
This is probably why wine doesn't exist, too. /s ;)
Re:Android Studio 4.0 by kelnos on Thursday May 28, 2020 @09:34PM (#23345364)
Yes, and wine has been under development for 27 years and, despite its achievements, still can't run all Windows apps.

(Regardless, reimplementing Windows APIs without documentation and writing a simulator for a phone OS are two completely different endeavors.)

Re:Android Studio 4.0 by robertoandred on Thursday May 28, 2020 @06:07PM (#23343388)
I wish. The Android emulator is so slow as to be almost unusable. The iOS simulator is fine.
Re:Android Studio 4.0 by heavyset_go on Thursday May 28, 2020 @06:17PM (#23343528)
iOS simulator can leverage the host's macOS libraries and kernel. Android doesn't share anything at all with Windows or macOS, and shares only the kernel at best with Linux. The best you can hope for is running Android in a container on a host Linux system, or via WSL. Unless you can get containers running natively on macOS, or run a Linux kernel a la WSL, there will need to be a layer of emulation to run Android.
Re:Android Studio 4.0 by xenadu02 on Thursday May 28, 2020 @10:36PM (#23345738)
While the iOS Simulator does share the host kernel it does not share libraries. It is effectively a separate userspace, with its own launchd_sim, its own mach bootstrap namespace, and so on.

The only exception to that is libsystem_{pthread,kernel,platform} because those form the kernel's ABI boundary. Libraries like libc, libdispatch, et al are the iOS build and use the iOS ABI.

Re:Android Studio 4.0 by heavyset_go on Sunday May 31, 2020 @09:32PM (#23374755)
Thanks for the clarification, I was under the impression that they shared libraries like the browser engine and what not. Not sure where I got that misconception.
Re:Android Studio 4.0 by Kipters on Thursday May 28, 2020 @07:22PM (#23344293)
I find it a bit ironic that WSL was born for supporting Android apps on Windows (Mobile)
Re:Android Studio 4.0 by qwerty456127 on Thursday May 28, 2020 @07:47PM (#23344521)
> Android doesn't share anything a

An Android app is a Java app using a set of special APIs. Why can't it run on a host JVM given some libraries implementing the same APIs? I'm not interested in the NDK.

Re:Android Studio 4.0 by MaulingMonkey on Thursday May 28, 2020 @08:42PM (#23344988)
> Why can't it run on a host JVM given some libraries implementing the same APIs?

That's a hideously huge API surface to double-implement - with a new and unique set of bugs reducing it's usefulness in CI builds - for slightly improved performance in a relatively niche dev edge case (!ndk android dev without android hardware.) You'd also need to skip conversion to DEX format (or convert back) to run on a standard JVM.

But your suggestion isn't technically impossible. You could (re)implement the subset of APIs your application happens to use yourself, if you really wanted to go down that route - which by virtue of being a much smaller subset of the APIs than the entire Android Java API surface, wouldn't even be practically impossible.

Re:Android Studio 4.0 by pjmlp on Friday May 29, 2020 @05:11AM (#23347891)
What one can expect, they don't even manage to keep up with Java.
Re:Android Studio 4.0 by dahfizz on Thursday May 28, 2020 @07:52PM (#23344553)
I've never had any problems with the android emulator on my 7 year old 4770k. It's perfectly smooth.

If your desktop can't replicate the performance of your phone, it's misconfigured or seriously underspecced.

Re:Android Studio 4.0 by 72deluxe on Thursday May 28, 2020 @08:14PM (#23344758)
I think it has issues with either GPU acceleration, or with saving state and resuming the emulator. It cannot do both, so you have to choose between fast startup and fast usage.

During typing this comment I nearly lost my mind because my macbook shift key is playing up and other keys are doing key repeats. I think I might go insane, stupid butterfly design

Re:Android Studio 4.0 by heavyset_go on Thursday May 28, 2020 @05:51PM (#23343191)
You can run Android in a container at native speed. You can also use containerized Android with binfmt_misc and libhoudini to run foreign binaries without having to run the entire Android OS in an emulator.
Re:Android Studio 4.0 by radarsat1 on Friday May 29, 2020 @03:52AM (#23347370)
I was wondering about that, is it possible to have an Android container on Linux that can be used from Android Studio for testing? Any info on this?
Re:Android Studio 4.0 by heavyset_go on Sunday May 31, 2020 @09:33PM (#23374760)
No experience in that department, sorry.
Re:Android Studio 4.0 by monocasa on Thursday May 28, 2020 @05:48PM (#23343159)
Anbox is pretty much what you're asking for (Android running within a container), but as others have said, the emulator is very good.

And what issues did you have with activities and fragments?

Re:Android Studio 4.0 by matchbok on Thursday May 28, 2020 @08:35PM (#23344939)
Hm, I'll have to try that out!

Oh, on those. Compared to iOS and ViewControllers, they just isn't a comparison. Starting them? Oh, can I do new Activity()? Nope, use this Intent thing. Rotation? Good luck! Passing data around? I have to use a bundle? Why can't I set a variable inside, like any other object?

Just to start. :)

Re:Android Studio 4.0 by kllrnohj on Thursday May 28, 2020 @10:21PM (#23345651)
> Passing data around? I have to use a bundle? Why can't I set a variable inside, like any other object?

You can just set variables like normal Java just fine. The bundle thing is only necessary to preserve data across process deaths.

Re:Android Studio 4.0 by lubonay on Friday May 29, 2020 @02:57AM (#23346995)
How do you set those variables? Do you keep a reference to your activity or fragment inside another screen? Do you clean up that reference on configuration change, or let it leak and/or cause crashes?

Your best bet to pass data around is to... not pass it but rather use a sophisticated DI setup where you can set up shared objects that live in a certain scope. Of course, you can add parameters to a bundle with some boilerplate, but that's not a great idea if the serialization overhead hurts you.

Re:Android Studio 4.0 by kllrnohj on Friday May 29, 2020 @01:39PM (#23353009)
Neither the ViewModel library nor Activity#onRetainNonConfigurationInstance() is what I'd call a "sophisticated DI setup"
Re:Android Studio 4.0 by V-2 on Thursday May 28, 2020 @06:26PM (#23343625)
Activities and Fragments, whatever one finds to be the problem with them, are an SDK thing, not an IDE thing.
Re:Android Studio 4.0 by surfmike on Thursday May 28, 2020 @05:31PM (#23342938)
I think their preferred route is to continue to make the emulator better instead.
Re:Android Studio 4.0 by halfjew22 on Thursday May 28, 2020 @09:06PM (#23345175)
I only see one reply remotely regarding Activites and Fragments and it's just asking what problems you had. It should be pretty obvious to anyone that's tinkered with Android that the whole battle between which to choose is ridiculous.

That said - I'd highly recommend checking out the Navigation components that are a part of Jetpack. They make standard navigation patterns, including deep linking, a complete breeze.

Re:Android Studio 4.0 by matchbok on Thursday May 28, 2020 @09:59PM (#23345521)
Oh, my team has tried the new stuff. It's terrible. Especially with the viewmodel stuff. Hidden bugs, no documentation, constant API changes. Hell, you couldn't scope a viewmodel to a nav graph until recently, which defeats the entire purpose of the whole thing.

It's just frustrating that 10 years later, we still have nothing that is remotely capable of the things an iOS ViewController can do.

Re:Android Studio 4.0 by krschultz on Thursday May 28, 2020 @09:05PM (#23345154)
The activities / fragment portion of the SDK is not owned by the team that builds Android Studio and the broader toolchain.
Re:Android Studio 4.0 by on_and_off on Thursday May 28, 2020 @10:45PM (#23345782)
emulator vs simulator just offer different drawbacks.

It would surely be nice to have the option but a good emulator is needed.