Question: "Hello world" Android app with as few files as possible, no IDE, and text editor only


"Hello world" Android app with as few files as possible, no IDE, and text editor only

Answers 2
Added at 2017-11-07 22:11

In nearly all languages that I've used (Python, C, C++, etc.), it's possible to write a "hello world" application with a text editor only and run it from command-line (interpreted languages) or compile/build it from command-line (compiled languages), e.g. cl.exe helloworld1.cpp.

On the other hand, every time I'm doing an Android App, I need to use Android Studio (which is slow on my machine), create a new project with the IDE, etc.

Question: What is the smallest number of minimalist Java source code files/project files to produce an .apk Android app? How to build it from command-line? (and never have to open the IDE)

NB: I've read many hello world for Android but all of them involve using the IDE.

NB2: I'm looking for standard apps written in Java, not solutions like Kivy, etc.

NB3: even if an IDE is probably more convenient to program an Android app, I don't see any technical reason for which compiling/building a number of files would absolutely require an IDE / programming with a GUI. Some people (like me) prefer command-line and text editor only, and such an IDE-free solution would be helpful.

NB4: I'm working on Windows platform, I have started a "Hello World without IDE" github repo here based on this answer, but I have a few problems such as this one. On the other hand, the method used there seems to be deprecated...

Answers to

"Hello world" Android app with as few files as possible, no IDE, and text editor only

nr: #1 dodano: 2017-11-07 22:11

Instead of trying to figure this out, why not just create an empty project from Android Studio. It will have everything you need, and a gradle config that you can build via gradlew. Then save that somewhere on your hard drive and use a copy of that as the start of your new projects.

nr: #2 dodano: 2017-11-12 18:11

Yes you can easily do it ALL from the command line (NO IDE involved, I promise).
This uses the old faithful Apache Ant. It does not use Gradle, that takes more work.

To Summarize

  1. Install Java JDK if not installed already (you can use jdk-8u151-windows-x64.exe for example), and make sure JAVA_HOME environment variable is defined

  2. Install Android SDK Tools (e.g. installer_r24.4.1-windows.exe, see this answer) if not already done, and then in the SDK Manager GUI, deselect everything and choose "Android SDK Build-Tools" (e.g. Android SDK Build-Tools 19.1) + one (or many) platforms (e.g. Android 4.1.2 (API 16) JELLY_BEAN)

  3. Download Apache Ant (for example

  4. What you type is (just 2 lines to produce an apk):

    android create project --target "android-16" --path basj --activity TestActivity --package 

    (write some code but is there already and will compile)

    ant debug


To create a project from the command line using Apache Ant:

(Note: The "android.bat" command is deprecated since Build Tools v26, so use an old one (see link above), deprecated in this case means TOTALLY removed !).

Decide on a place to put your project:

cd c:\android
mkdir antTest
cd antTest

Run the command:

C:\Android\sdk1\tools\android create project --target "android-16" --path basj --activity TestActivity --package 
--------------+ (here's where I keep an old version of tools (version 25 in my case)

Here is the directory structure created (and all the files you need to build):

    ¦   +---drawable-hdpi
    ¦   +---drawable-ldpi
    ¦   +---drawable-mdpi
    ¦   +---drawable-xhdpi
    ¦   +---layout
    ¦   +---values

detailed output of create project:

Created project directory: C:\Android\antTest\basj
Created directory C:\Android\antTest\basj\src\com\android\basj
Added file C:\Android\antTest\basj\src\com\android\basj\
Created directory C:\Android\antTest\basj\res
Created directory C:\Android\antTest\basj\bin
Created directory C:\Android\antTest\basj\libs
Created directory C:\Android\antTest\basj\res\values
Added file C:\Android\antTest\basj\res\values\strings.xml
Created directory C:\Android\antTest\basj\res\layout
Added file C:\Android\antTest\basj\res\layout\main.xml
Created directory C:\Android\antTest\basj\res\drawable-xhdpi
Created directory C:\Android\antTest\basj\res\drawable-hdpi
Created directory C:\Android\antTest\basj\res\drawable-mdpi
Created directory C:\Android\antTest\basj\res\drawable-ldpi
Added file C:\Android\antTest\basj\AndroidManifest.xml
Added file C:\Android\antTest\basj\build.xml
Added file C:\Android\antTest\basj\proguard-project.txt

Download Apache Ant from

See this tutorial for setup:

Also see this tutorial:

Write your code (Hello world).

Run this command and you get an Android Apk out the other side (called TestActivity-debug.apk):

ant debug

Hey presto, you got an android apk !
For a final build :

ant release
Source Show
◀ Wstecz