How To Develop Android Apps or Modules Without IDE (Android Studio | IntelliJ)

Virtually all Android projects are created with Android Studio or IntelliJ IDEA. That isn't great for learning because you will not understand how things work such as components that make up an Android projects, how build are setup and configured, etc.

Why would anyone wants to develop Android apps or modules without Android Studio? There are several possible reasons.

  • Android Studio consumes lots of memory and works slowly on many computers or Macs,
  • The Android Studio no longer supports the AGP of the project and you cannot upgrade the AGP anymore since it'll breaks the project dependencies.

Disclaimer: This guide is provided "as is" with no warranties with regard to the accuracy and completeness of the information provided herein. I expect you to have an inquisitive mind to try things out, and the patience to first google and try to find answers to simple questions.


Understanding The Android Projects Structure

When we create an Android projects using IntelliJ IDEA or Android Studio it'll generates the following files:

Android is using the Gradle build system for configuring and executing builds. What do we have without the Gradle files?


Only three files and three folders. The *.iml and .idea are not important, it is used by Android Studio IDE. The local.properties and build folder aren't important as well.

.gitignore is used by git if you're using git.

You can safely delete .idea, *.iml and the build folder. The app folder and the gradle files are important.

Install The Java SDK

Check if your machine has a Java SDK and runtime. 
  • Go to terminal and enter java -version
  • In the terminal type and enter javac -version
You should see the version if you have it. Command not found or something error like that will be printed if you don't have it.

Make sure you have at least Java 8 installed. Go to https://openjdk.java.net/install/index.html for instructions on how to install the Java SDK (Android preferred OpenJDK).

Install The Java & Android SDK from Command Line

The Android Studio is bundled with JDK (Java SDK) and Android SDK but since you won't be downloading or will not use the IDE you have to download and install the JDK and Android SDK from command line.

Install Gradle

Like I said above, Android is using gradle to execute builds to you need to install this as well. Go to https://gradle.org/install/


Let's Create The Android Project From Command Line

In this blog post I'll be creating an Android multi-platform library. Here's the complete command I entered to create the project:

iMac GradleProjects % mkdir MultiYummyAPI
iMac GradleProjects % cd MultiYummyAPI 
iMac MultiYummyAPI % ls
iMac MultiYummyAPI % gradle init
Starting a Gradle Daemon (subsequent builds will be faster)
Select type of project to generate:
  1: basic
  2: application
  3: library
  4: Gradle plugin
Enter selection (default: basic) [1..4] 3
Select implementation language:
  1: C++
  2: Groovy
  3: Java
  4: Kotlin
  5: Scala
  6: Swift
Enter selection (default: Java) [1..6] 4
Select build script DSL:
  1: Groovy
  2: Kotlin
Enter selection (default: Kotlin) [1..2] 2
Project name (default: MultiYummyAPI): 
Source package (default: MultiYummyAPI): me.about.ronillo.yummyapi
> Task :init
Get more help with your project: https://docs.gradle.org/7.1.1/samples/sample_building_kotlin_libraries.html
BUILD SUCCESSFUL in 10m 48s
2 actionable tasks: 2 executed

Here's the files and folders I got after initializing the project:

  • gradle/wrapper
  • gradlew
  • gradlew.bat
  • lib
  • settings.gradle.kts

Let's Create The Android Build

In the root folder, create the top-level build files called. build.gradle.kts which will contain the Android Gradle plugins code. The code looks like this:

buildscript {
    repositories
{
       
// Gradle 4.1 and higher include support for Google's Maven repo using
       
// the google() method. And you need to include this repo to download
       
// Android Gradle plugin 3.0.0 or higher.
        google
()
       
...
   
}
    dependencies
{
        classpath
("com.android.tools.build:gradle:4.2.0")
   
}
}

In the lib folder there's a build.gradle.kts, you need to modify it to configure the dependencies, plugins, atbp.

Note: You can use any text editors you like. I like Atom or VS Code.

There's a lot to talk about Android builds, there's a lot of configurations depending on the project needs. Learn more at https://developer.android.com/studio/build

Checkout The Complete Example

Now we just made an Android library with nothing but a command-line and a text editor.

I have an open library and its created without Android Studio. It's a multi-platform library for iOS and Android apps who wishes to query recipes from yummly.com.


If you like this post, please share the links with your friends or social media. Thanks!

Comments

Popular posts from this blog

How To Check If Your Android Phone Is Official Or Rooted

Android Reverse Engineering - Beginners Guide To Smali Coding

Conquering macOS Upgrades: A Guide for iOS App Developers