Android Kaki

Build beautiful, usable products using required Components for Android.

Bazel: Revolutionary Construct System for Android App Improvement | by Nirav Tukadiya | April 2023

photograph taken by Clay Financial institution ABOVE depart

Bazel is a well-liked construct instrument used to develop software program initiatives. It’s an open supply construct instrument utilized by Google to construct their very own initiatives. Bazel helps a number of programming languages, together with Java, C++, and Python, and can be utilized to construct software program for quite a lot of platforms, together with Android. On this weblog, we’ll talk about the best way to arrange a mission with Bazel to construct Android apps.

Bazel and Gradle are each extensively used construct methods for constructing Android purposes. Whereas each instruments have their very own strengths and weaknesses, there are a number of the reason why Bazel is taken into account higher than Gradle for Android growth.

  1. Sooner construct occasions: One of many major benefits of utilizing Bazel for Android growth is that it affords quicker construct occasions in comparison with Gradle. Bazel makes use of a distributed caching system that may cache the output of earlier builds, decreasing the necessity to rebuild the whole mission. This may result in important time financial savings, particularly for bigger initiatives.
  2. Higher scalability: Bazel is designed to deal with large-scale initiatives with hundreds of supply information and dependencies. It may effectively handle the construct course of, even for complicated initiatives involving a number of languages ​​and platforms. Conversely, Gradle can battle with bigger initiatives, leading to slower construct occasions and elevated complexity.
  3. Improved dependency administration: Bazel offers higher dependency administration than Gradle. Bazel can deal with transitive dependencies extra effectively, decreasing the necessity to manually handle dependencies. It may additionally routinely resolve conflicts between dependencies, guaranteeing that the right model of every library is used.
  4. Copyable construct: Bazel offers reproducible builds, which means these builds are constant throughout totally different environments and platforms. This may be particularly necessary for giant initiatives involving a number of groups and construct environments. In distinction, Gradle can battle with reproducibility, which may result in inconsistencies and errors within the construct course of.
  5. Versatile: Bazel is designed to be very versatile and extensible, permitting builders to customise the construct course of to satisfy their particular wants. It helps a number of programming languages, platforms, and construct targets, making it a flexible instrument for constructing complicated initiatives. In distinction, Gradle is designed primarily for constructing Java initiatives and might be harder to increase to non-Java initiatives.

General, whereas Gradle is a well-liked construct instrument for Android growth, Bazel affords a number of benefits over Gradle by way of construct velocity, scalability, dependency administration, reproducibility, and adaptability.

Earlier than you start, ensure you have the next conditions:

Step 1: Arrange a brand new Android mission

First you might want to create a brand new Android mission. You are able to do this utilizing Android Studio, an official IDE for Android growth. Open Android Studio and create a brand new mission. Select mission title, bundle title and different settings as per your requirement.

Step 2: Add Bazel help to your Android mission

Upon getting created a brand new Android mission, you might want to add Bazel help to that mission. To do that, create a brand new file named “WORKSPACE” within the root listing of your mission. This file is utilized by Bazel to outline the mission and its dependencies.

Add the next code to the “WORKSPACE” file:

title = "androidsdk",
api_level = 28,
build_tools_version = "28.0.3",
path = "/path/to/android-sdk",

title = "androidndk",
path = "/path/to/android-ndk",
api_level = 28,

Substitute “/path/to/android-sdk” and “/path/to/android-ndk” with the precise paths to your Android SDK and Android NDK installations.

Step 3: Create a BUILD . file

Subsequent, create a brand new file named “BUILD” within the root listing of your mission. This file is used to outline the goal that you just need to construct with Bazel.

Add the next code to the “BUILD” file:

title = "app",
srcs = glob(["src/main/java/**/*.java"]),
resource_files = glob(["src/main/res/**"]),
manifest = "src/major/AndroidManifest.xml",
custom_package = "com.instance.myapp",
multidex = "native",
deps = [

This code identifies an Android binary goal named “app”. The goal contains your Android mission’s supply, useful resource, and manifest information. It additionally specifies your app’s bundle title and contains the dependencies you need to construct along with your mission.

Step 4: Add third-party dependencies

In case your mission makes use of any third-party libraries or frameworks, you might want to add them to your Bazel mission. To do that, create a brand new folder named “third_party” within the root of your mission.

Subsequent, create a brand new file named “WORKSPACE” within the “third_party” folder. Add the next code to the “WORKSPACE” file:

title = "androidx",
artifact = "androidx.appcompat:appcompat:1.2.0",
repository = "",

title = "google",
artifact = "",
repository = "",

title = "okhttp",
artifact = "com.squareup.okhttp3:okhttp:4.9.1",
repository = "",

This code identifies the third-party dependencies your mission makes use of. On this instance, we’ve added three dependencies: androidx.appcompat, and com.squareup.okhttp3.

Step 5: Construct your Android mission with Bazel

Upon getting your mission arrange with Bazel and added the mandatory dependencies, you’ll be able to construct your mission with the next command:

bazel construct //:app

This command will construct the “app” goal that you just outlined within the “BUILD” file. The output APK file can be generated within the “bazel-bin/app.apk” folder.

On this weblog, we mentioned the best way to arrange a mission with Bazel to construct Android apps. Bazel is a robust construct instrument that gives many advantages over conventional construct instruments, together with quicker construct occasions and higher caching. By following the steps outlined on this weblog, you’ll be able to simply arrange a brand new Android mission with Bazel and begin constructing high-quality apps.

  1. Official Bazel documentation: https://docs.bazel.construct/variations/major/bazel-overview.html
  2. Bazel for Android builders: https://bazel.construct/variations/6.1.0/begin/android-app
  3. Bazel on GitHub:
  4. Weblog Bazel: https://weblog.bazel.construct/

Keep Linked: Join with me on LinkedIn and Twitter

Thanks for studying my put up. If you wish to join with me and keep updated with my newest ideas and insights, you’ll find me on LinkedIn:
Twitter at

Do not hesitate to succeed in out and say hey!

John Wick: Chapter 4 (FREE) FULLMOVIE The Super Mario Bros Movie avatar 2 Where To Watch Creed 3 Free At Home Knock at the Cabin (2023) FullMovie Where To Watch Ant-Man 3 and the Wasp: Quantumania Cocaine Bear 2023 (FullMovie) Scream 6 Full Movie

Updated: April 16, 2023 — 3:54 pm

Leave a Reply

Your email address will not be published. Required fields are marked * © 2023 Android kaki