Photo by Alex Milkis

Part 1 — Creating Bazel Android app from scratch

Introduction

Step 1. Creating Bazel WORKSPACE

$ bazelisk info workspace
bazel-android-hello-world
└── WORKSPACE

Step 2. Creating folder structure

bazel-android-hello-world
├── app
│ ├── java
│ │ └── com
│ │ └── morfly
│ │ └── helloworld
│ └── res
│ └── layout

└── WORKSPACE

Step 3. Writing source code

bazel-android-app 
├── app
├── java
└── com/morfly/helloworld
│ │ └── MainActivity.java <- new
│ ├── res
│ │ └── activity_main.xml <- new
│ │
│ └── AndroidManifest.xml <- new

└── WORKSPACE

Step 4. Building and running the project

$ bazelisk build //app:app
$ bazelisk mobile-install //app:app --start_app
bazel-android-hello-world 
├── app
├── java
└── com/morfly/helloworld
│ │ └── MainActivity.java
│ ├── res
│ │ └── activity_main.xml
│ │
│ ├── BUILD <- new
│ └── AndroidManifest.xml

└── WORKSPACE

Step 5. Understanding Bazel labels

$ bazelisk build //app
$ bazelisk build app

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store