Guide: Developing on ChromeOS (Part 6)

This is a continuation of a multi-part guide. See Part 1 to get started.

What’s probably the most unique aspect of ChromeOS is its native support for Android apps. Apps aren’t run in a virtualized Android OS image as with other operating systems and SDK environments. This is thanks to Android Runtime for Chrome, also known as ARC.

Debugging with Android Runtime for Chrome

In the last section, we left off with a compiled React Native Android app, but fell short of actually running it. Well, if your ChromeOS device supports Android apps, we can utilize ARC to install and debug that app.

67-ManageAndroidPreference.png

We start by making sure by accessing ChromeOS settings and making Google Play Store is enabled. We want to manage the Android preferencesNote that ChromeOS Settings may look different from the screenshot.

68-AboutDevice

From here we’ll want to access About device to unlock Developer Options.

70-DeveloperOptionsEnabled.png

Click Build Number seven (7) times until a toast message appears saying “You are now a developer!”

71-SelectDeveloperOptions.png

Return to Android Settings and select Developer options.

72-SelectADBDebugging.png

Click to enable ADB debugging.

73-AllowADBDebugging.png

Click OK to allow ADB debugging.

The next phase will enable allow us to SSH into our ChromeOS. Before we can do that, we need to disable rootfs verification.

75-RebootChromeOS.png

Open up your crosh shell and run sudo /usr/libexec/debugd/helpers/dev_features_rootfs_verification followed by sudo reboot to disable rootfs vertification and reboot your device. (Remember to press Ctrl+D to skip the warning screen.)

77-ADBConnectLocalhost.png

Now that rootfs verification has been disabled, we can enable SSH by performing sudo /usr/libexec/debugd/helpers/dev_features_ssh from shell. The operation will complete silently. At this point we can tell the ChromeOS device to connect to itself (localhost or 127.0.0.1) over the default SSH port (22) with the Android Debug Bridge (ADB) by performing a sudo adb connect 127.0.0.1:22 command.

78-AllowUSBDebugging.png

You may get a prompt to allow USB debugging. If you notice the icon, this is a prompt from the Android layer asking for permission to connect with ChromeOS device. You can check the checkbox and select OK.

We are now ready to install and run our React Native Android app.

79-AdbReverse8081.png

Navigate to your sampleRN project and perform adb install ./android/app/build/outputs/apk/app-debug.apk which will install the app on your ChromeOS device. To allow React Native to communicate with the app, we need to perform adb reverse tcp:8081 tcp:8081 as well.

81-ReactNativeStartReady.png

Finally, perform react-native start to start the packager necessary to send files to the app. Once it’s ready we can start our Android app.

82-OpenSampleRNApp.png

Search for sampleRN in your list of apps (which should have been installed by the adb install command) and open it.

83-SampleRNAppLoading.png

You should see a green progress bar on the top of the screen as well as a progress inside the terminal shell. This means the Android app is remotely loading over React Native’s packager.

84-SampleRNRunning.png

Complete! That’s real Android app running on your ChromeOS being managed by a nodeJS app running over crosh shell.

This really shows how much potential ChromeOS has underneath. If there’s more you’d like to see, let me know in the comments!

Part 2 – Crosh and Nano development environment
Part 3 – Creating and modifying files from shell
Part 4 – Creating a web app with nodeJS and Caret
Part 5 – Android Development with React Native

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Blog at WordPress.com.

Up ↑

%d bloggers like this: