For purpose when meet the problems when we setup and provide the environment for build android with no need to use or install android studio. That reason why i write about this, letβs digest
What we need when build the android
Quote
As my knowledge, you have multiple way to build and assemble anything of mobile, and last progress, you will have apk file and easily to delivery to another platform to test and use. such as
Tool is just a tool, you need to know how the way build progress work that all, but familiar with one of those can help you push the productivity, and get something. Therefore, I want to share about Gradle, as least I can guide you about cutting off effort when you want to build android with this one
But before we talk about Gradle, you need to know about Android project requirements which help to compile and show your result, I will share you about guide to install and setup, you can check your machine, It has or not, If not, you need these bro π, including
If you check the requirements and not meet, you can follow the step to install and setup your environment
Install java
First of all, with recommendation, you will need at least jdk 17 installing for except the error, and problems. With Ubuntu, the easily way you can install with apt but not meet the problems, please use the blog
With apt , you can do the command for get the java on your host
Install Android command-line tools
For stable and install directly, you need to access official page of Android and find to the last, It show you about Command line tools only, Choose the version for your OS (Linux, Mac or Win)
Some thing mess up in here, the link show for you need one more step approve the license and the lastly you will have link to download
After that you can use curl or wget to download these to your host
After extract, you will have cmdline-tools
You need to put the tools which download to system folder, such as usr/lib or usr/local for example
UPDATE
Bug
But anything not easily, if you perform the next step and check sdkmanager, you will met the problems about cmdline-tools : could not determine SDK root, and it occur from SDK 29+ π€, so just follow sdk recommendation or fix from StackOverFlow - cmdline-tools : could not determine SDK root. You can perform like these
Lastly, you need to export PATH for both ANDROID_HOME and bin of sdk which help your machine understand and permit for your execution
Check the version of sdkmanager
Install another Android SDK
Last step, you need to perform to download build-tools and platform-tools for your shell
But before perform downloading, you can list all package you can add with sdkmanager on remote repository, and --list flag
You can select the version android build and platform tools that you need. After the decision you can use sdkmanager to add them
Quote
With me, I choose the stable version for installing, and version is Android 14, including
build-tools;34.0.0
platforms;android-34
After that, you need to perform command license to perform approve and commit to use, and sdk will active these package
That all step you need, (optional) you can perform update command if you think necessary
Build with Gradle
Info
Gradle Build Tool is a fast, dependable, and adaptable open-source build automation tool with an elegant and extensible declarative build language.
Gradle is a widely used and mature tool with an active community and a strong developer ecosystem.
Gradle is the most popular build system for the JVM and is the default system for Android and Kotlin Multi-Platform projects. It has a rich community plugin ecosystem.
Gradle can automate a wide range of software build scenarios using either its built-in functionality, third-party plugins, or custom build logic.
Gradle provides a high-level, declarative, and expressive build language that makes it easy to read and write build logic.
Gradle is fast, scalable, and can build projects of any size and complexity.
Gradle produces dependable results while benefiting from optimizations such as incremental builds, build caching, and parallel execution.
Which those feature and characteristics of Gradle, It suppose the first thing which you want think to build Android is Java
You have two way to install Gradle, via SDKMAN or binary manual install. You can try with SDKMAN but I choose download from binary for more understand and configuration
You need to access Download link to get the latest Gradle distribution
Access next to binary-only to download compress of Gradle or use curlwget command to download from direct link
Next to, unzip the folder and Gradle folder extract
Access bin directory in side gradle, you will find twice binary find one for linux and one for DOS
With Linux, you just need mv or cp the whole gradle folder to your execution location, for example /usr/local/bin
But moreover, sometime I see Developer put gradlew binary to install and setup the environment, you can image like these
When you build the android, you need to put the file inside the app folder, called build.gradle. These documentations can helpful for you , because I do not familiar with theses but maybe you know about that
On my circumstance, DevOps is not define these, you know all of these will prepare and just actually run the command, on the package.json and related command for execution the build process. Therefore, expectation I will find the way to perform build and assemble to apk file
Usually use can use gradlew wraper with option assembleRelease to bundle build and compression anything else, and output for us the .apk file.
Success
When you perform command, usually the apk file can compress and locate in /app/build/intermediates/apk/debug/<name>.apk (With gradlew) or app/build/outputs/apk/release (With fastlane) or maybe on the other route base on your version of gradle and gradlew. You can follow the articles for more understand: Build your app from the command line
Conclusion
Info
That all for today, I hope this blog can help you something on setup and prepare the environment for build the android project. You can combine all these task with just one file and click, and anything will completely ready.
Quote
When you learn a new thing like android, the new cool experience with me. Gradle and Gradlew that such a cool things. Maybe I donβt familiar much with Gradle or Maven but on the another session, I and you will explore more about that. So farewell @all, stay safe, hacking and learn more incredible things