Bazel is more flexible in terms of project structure, so you don’t necessarily need to follow the structure used in Gradle Android projects. Here is the project structure so far: bazel-for-android ├── app │ ├── src │ │ └── io/morfly/bfa │ │ └── MainActivity.java │ ├── res │ │ └── activity_main.xml │ │ │ └── AndroidManifest.xml │ └── WORKSPACE The only thing left, is to configure Bazel to build our project which we will do next. This is the minimal set of files to get our Android app working. Under the app/src/io/morfly/bfa directory create a MainActivity.java file and fill it with the code below. Now, we are ready to add the source code for our Android application. Here is the project structure so far: bazel-for-android ├── app │ ├── src │ │ └── io │ │ └── morfly │ │ └── bfa │ └── res │ └── layout │ └── WORKSPACE Writing source code Also, create app/res/layout folders that will contain project resources and layouts in particular.Under app/src add io/morfly/bfa packages.Create app/src folder that will contain the source code of our Android application.Create app folder in the root project directory.Next, we need to set up a folder layout for our project. You can use SDK Manager in Android Studio to install required versions of Android SDK and Build Tools. Otherwise, Bazel will try to use the latest ones on your computer. Optionally, it is possible to specify api_level and build_tools_version but make sure those specific versions are installed on your machine. Replace all the code in the pop-up window with the snippet below.Select path to the root project directory.Now, we need to enable Android Studio support for our project. If all is done correctly, it should print the path to your current project directory. Open the terminal at the project directory and execute the command below.Inside this folder create a file named WORKSPACE.It will be the root directory of our project. Create an empty folder on your computer.The WORKSPACE file allows you to fetch external extensions to Bazel (so-called rule sets) that know how to build various programming languages and platforms including Android, Kotlin, etc.įollow these steps to set up our project workspace: In Bazel, each project is defined by the WORKSPACE file that must be located in its root directory. Installing Bazel plugin in Android Studio Creating Bazel workspace You can find the source code from this post on GitHub: We will create an empty project directory and populate it with source files one by one until the project is built and launched with Bazel. No automatic wizard or project template will be used to get started. In this part, we will see how to create a simple Android application built with Bazel completely from scratch. Part 4 - Adding external dependencies ( coming soon).Part 1 - Getting started ← you are here.You can learn more about Bazel from its official page. It supports a wide variety of languages and platforms including Android. It provides advanced local and distributed caching, optimized dependency analysis, and parallel execution. Building Android apps with Bazel build system.īazel for Android - is a series of blog posts that shows the basics of building Android projects with Bazel build system.īazel - is an open-source build system developed by Google.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |