Affiliate links on Android Authority may earn us a commission. Learn more.
Preparing your Android app for Chromebooks
One of the big reasons to develop for Android is that it allows you to release your apps on a huge variety of devices from smartphones, to smart watches, to virtual reality headsets. This creates more exciting possibilities for what your apps can do and of course gives you access to a very large number of users.
Now, Google is widening the audience for Android apps even further by bringing them to Chromebooks – properly this time. This is excellent news for developers who want to expand their potential markets, or perhaps design apps for laptop form-factors; especially with Chromebook sales expected to exceed 17 million units by 2023. As Google put it at Google I/O 2016 where it announced the feature: Android developers want more users and Chromebook owners want more apps… seems like a no-brainer!
So the question is: how does this work and how do you go about bringing your Android apps to Chromebook? Read on to find out.
How it works
The new Chrome OS support for Android means that there will no longer be a need to create a separate version of your app using a different codebase, or to fiddle with your creation to make it compatible with the App Runtime for Chrome. Instead, Android apps will now run natively on Chromebook with the performance and features you would expect from any other device. This is a big step up from the previous options, which came with numerous limitations and could be fiddly to get up and running.
This solution uses an entirely new sandboxing method that should theoretically make it very simple to port games and apps over to Chrome. Chromebooks will now come with direct access to the Google Play Store and installed apps will run in moveable and resizable windows.
This is not achieved through the app runtime but rather through Linux namespaces which isolate the Android and Chrome OS. There’s no virtual machine and no emulation, so you get full native performance. Android is running directly on top of the Linux kernel with additional security features in place. Binary translation is also available to ensure that apps using the Android NDK to target ARM processors specifically can be supported by x86 processors like those found in certain Chromebooks.
That’s what you call having your cake and eating it too!
The question you might be asking is: could this feature support higher-end mobile gaming? The answer is that if the Chromebook is powerful enough to support it, then yes. And most apps will show up automatically in Google Play on Chrome OS, with no additional work needed on your part.
This approach allows maximum speed, compatibility and security while minimizing the amount of work for developers. That’s what you call having your cake and eating it too!
What it means for your apps
So here’s what you need to do to ensure your app will be compatible with Chrome OS… Nothing!
Well, theoretically anyway. Right now, your app should run on Chrome OS with zero code changes. The app you have on the Play Store as you read this, should be ready to go on Chrome OS as soon as the feature lands.
But there is a difference between getting an app to run on a system and optimizing it for that platform. The key thing to remember here, is that your app is now going to work like a Chrome OS app and like an Android app. This means it’s important to be aware of how your apps will be used on Chromebooks and what differences the hardware will bring. The following bullet points are taken from a Google I/O session and show how the behaviour of your apps will be affected by their new cross-platform nature.
With multiwindow multitasking, you can now expect some changes for your apps behavior and you may want to make some tweaks with that in mind. This means:
- One task per window
- Clipboard available across apps
- Just one app launcher
- A single sign-in across all apps
Chromebooks have different hardware specs when compared with Android phones and tablets, so this is something to keep in mind. That pedometer you’ve been relying on isn’t going to work here, for example. That said, you’ll still get access to the following, as usual:
Input methods also change when you switch to different hardware and you might want to have a think about whether your app is well-suited to keyboard and mouse and how that will look/feel for the user. You’ll get access to:
- Touch (where available)
Because apps run on a full Android stack, you’ll get access to all the usual Android APIs. There are also no new APIs to learn (for now), which may come as a relief. This means you’ll get everything you’re used to and can expect the following to work as expected out-of-the-box:
- Application lifecycle
- Google Play Services (such as in-app purchases)
System services also behave as expected, meaning the following will all act as normal:
- Package manager
- Activity manager
- Power manager
Hardware is abstractive, so you will once again get access to:
Certain things won’t be available, such as GPS, but note that WiFi can be used to get a devices location in many cases.
Optimization tips for bringing your apps to Chrome
With all this in mind, it’s clear to see that most apps will benefit from a little tweaking before they make the jump to Chrome. Here are some changes worth making if you want to ensure that your app is going to thrive in its new home. (You can also find more detailed information from Google, here.)
Update the manifest file
The first thing to consider is whether your app will show up on Chrome OS by default. The answer is yes in most cases; as long as your app does not explicitly require android.hardware.touchscreen in the manifest file. By default, android.hardware.faketouch will work just fine but if you want to make sure your app is fully optimized and be doubly certain it will be available on all Chromebooks in future, you should add the following declaration to the manifest:
You should also check the manifest for any other requirements that preclude Chrome OS support. That means things like pedometers or GPS in some cases. Again, you should update your manifest to remove these requirements if you want your app to be available on as many devices as possible.
Some apps just won’t work, including custom keyboards, widgets, live wallpapers, custom launchers etc.
Of course some apps just won’t work, including custom keyboards, widgets, live wallpapers, custom launchers etc. The Play Store will know this automatically by looking at your manifest file, so there’s no need for you to do anything.
Update NDK libraries
If your app uses the Android NDK and targets SDK version 23 or higher, then you need to ensure that you remove text relocations from the ARM and x86 versions of NDK libraries. These aren’t compatible in Android 6.0 and could cause compatibility issues with Chrome – especially those devices using x86 architecture.
Understanding the app lifecycle
Interestingly, there are no changes to your app’s life cycle. Only one app can have focus at any time but more than one may be visible simultaneously. It’s important to pause rendering when the app loses focus to conserve battery, though this might be different for things like video apps that you may want to play while doing other things. The low memory killer will be based on the Z-order – the apps that are at the bottom of the heap will be the first to be killed with memory is sparse.
Make the most of multiwindow
As mentioned, Chrome OS will give Android apps support for multiwindow multitasking. This means you can have multiple apps running at once with the same clipboard data. That’s something to consider when imagining potential new features you can bring to your apps and how you want them to behave.
Consider as well that multiwindow uses one task per window – meaning that intents should be handled within the same window unless you specify otherwise. This is something you may want to experiment with in order to ensure the best user experience. For example, clicking on the FAB in Gmail could open the compose screen in a new window, a useful function in any number of scenarios.
Make your apps responsive
Apps can be resized but not as freely as you might be used to with Windows or Mac programs (for now). Rather, window will come in three sizes:
- Portrait (roughly the size and shape of a Nexus 5)
- Landscape (Nexus 7)
There’s also an immersive-style view that makes the app even larger.
As with any Android device, you can set your app to support only portrait, landscape or both in the manifest. Where both options are available, your app will open in landscape by default. Ensuring your app uses a responsive layout is more important now than ever before. It’s also highly advisable that you actually test your apps on Chrome rather than assuming they’ll work.
Remember that these orientation changes are handled a little differently than on traditional Android devices. The densityDpi for example can change when you switch orientation and the same goes for the height and width which will change completely rather than just switching values (as when orientation is physically changed). It’s also important to invalidate any cached resources.
Making sure your apps are fully responsive is also a good idea from a future-proofing perspective, ready for Android N.
Add hot keys and other features
With keyboard support comes hotkeys. You can introduce shortcuts like Ctrl+S for saving documents, or Ctrl+P to print for example. Google also recommends implementing backup and restore via the cloud, as this is a feature many Chromebook users appreciate – especially in schools and other institutions where devices may be shared among multiple users. Note: The back button will be supported by a clickable option at the top left of your window.
View and support your app’s compatible devices
To view your app’s compatibility (which is based on your manifest file settings), you simply need to login to the Google Play Developer Console, select your app, click ‘APK’ in the left menu and then choose ‘See List’ under Supported Devices.
From here, you can see which devices your app supports and you can choose to exclude specific ones. This may be handy in future, if you decide you don’t want your app to be available on Chromebooks.
How to start testing apps and when they’ll be available
Developers already have access to this feature and all you need to do is put your Chromebook into developer mode and, as when testing on Android devices, enable installations from unknown sources in the Security in App settings page. You will then be able to sideload the app by copying it to your Chromebook. You can do this via ADB, by adding your APK to Google Drive, by using an external storage device, or by sending it to yourself via email. More information can be found on the Enable Unknown Sources page.
Google recommends that you test your app on ARM and x86 based Chromebooks, touchscreen and non-touchscreen Chromebooks and convertible devices to ensure maximum compatibility. Realistically, it’s unlikely that most independent developers will have access to that many devices so just… do your best.
To begin with, Google Play support will be available on the ASUS Chromebook Flip, Acer Chromebook R11 / C738T and the Chromebook Pixel (2015 model). A good tip for developers would be to target any optimizations for these devices first. From there, it will spread to more Chromebooks available on the market and presumably those that are currently just twinkles in their OEMs’ eyes. This list should provide a regularly updated guide to which devices are supported at any given time.
Note that for now, Chrome OS will come with Android Marshmallow. In future though, this will switch to Android N, which means apps will become truly resizable and introduce features like drag-and-drop and a true mouse cursor API. It’s a good idea to start ensuring compatibility now, so that you can add support for these new features and devices as they’re introduced – rather than putting it off and creating a lot of work for yourself in the future.
For more details about Android apps on Chrome OS, the check out the “Bring Your Android App to Chrome OS” session from Google I/O 2016:
So that’s how you can go about supporting Chrome devices and potentially find a huge pool of new users for your existing apps. You’ve got until September to make these few tweaks and to think about what apps Chrome users might benefit from in particular.
It’s fair to say that Google has done a pretty great job with this and hopefully developers can look forward to a few more downloads starting in September. Let us know in the comments if there’s anything we missed and what you make of the news!