Giter Club home page Giter Club logo

minimum's Introduction

Minimum

This branch contains the application with layout resource.
See the minimally possible application and MVP app in the appropriate git branches.

This repo contains three Android applications:

  • minimally possible app (minimal-app branch);
  • app with layout resource (this branch — master);
  • simple app using MVP (Model — View — Presenter) architecture (mvp-app branch).

This is minimal Android application written without IDE, in a simple text editor and compiled in command line. Its goal is to understand how to create Android application from scratch, its structure, and necessary tools.

The project is based on this article on Russian and this article on English.

All binary output files are kept in the repo to let you completely understand the project.

Steps to repeat the project

  1. Install JDK and Android SDK.

  2. Create folder structure for the project.

│   AndroidManifest.xml
├───bin
├───obj
├───res
│   ├───layout
│   │       activity_main.xml
│   └───values
│           strings.xml
│
└───src
    └───ru
        └───coffeeplanter
            └───minimum
                    MainActivity.java
  1. Create AndroidManifest file.
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="ru.coffeeplanter.minimum">
	<uses-sdk android:targetSdkVersion="25"/>
	<application android:label="Minimum">
		<activity android:name=".MainActivity">
			<intent-filter>
				<action android:name="android.intent.action.MAIN"/>
				<category android:name="android.intent.category.LAUNCHER"/>
			</intent-filter>
		</activity>
	</application>
</manifest>
  1. Create resources files.

activity_main.xml:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
	android:layout_width="wrap_content"
	android:layout_height="wrap_content"
	android:layout_gravity="center"
	android:gravity="center">

	<TextView
		android:id="@+id/label_textview"
		android:layout_width="wrap_content"
		android:layout_height="wrap_content"
		android:layout_margin="16dp"
		android:gravity="center"
		android:text="@string/text_label"
		android:textSize="24sp"/>

</LinearLayout>

strings.xml:

<resources>
	<string name="text_label">This is the app\nwritten in a simple text editor,\nwithout Android Studio\nor any other IDE.\nEnjoy! :-)</string>
</resources>
  1. Write Java code.
package ru.coffeeplanter.minimum;

import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;

public class MainActivity extends Activity {

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
	}

}
  1. Choose platform and tools version. This project uses 25.0.2 version.

  2. Create R.java class file by this command.

<PATH_TO_YOUR_ANDROID_SDK>/build-tools/25.0.2/aapt
	package
	-f
	-m
	-S <PATH_TO_YOUR_PROJECT>/res
	-J <PATH_TO_YOUR_PROJECT>/src
	-M <PATH_TO_YOUR_PROJECT>/AndroidManifest.xml
	-I <PATH_TO_YOUR_ANDROID_SDK>/platforms/android-25/android.jar
  1. Compile the project to java binary files.
javac
	-source 7
	-target 7
	-verbose
	-d <PATH_TO_YOUR_PROJECT>/obj
	-classpath <PATH_TO_YOUR_ANDROID_SDK>/platforms/android-25/android.jar:<PATH_TO_YOUR_PROJECT>/obj
	-sourcepath <PATH_TO_YOUR_PROJECT>/src
	<PATH_TO_YOUR_PROJECT>/src/ru/coffeeplanter/minimum/*.java
  1. Create dex file for Android Java machine. Use here absolute path, otherwise it can an error occur.
<PATH_TO_YOUR_ANDROID_SDK>/build-tools/25.0.2/dx
	--dex
	--verbose
	--output=<PATH_TO_YOUR_PROJECT>/bin/classes.dex
	<PATH_TO_YOUR_PROJECT>/obj
  1. Make unsigned apk file. Delete existing AndroidTest.unsigned.apk and AndroidTest.signed.apk files before running this command.
<PATH_TO_YOUR_ANDROID_SDK>/build-tools/25.0.2/aapt
	package
	-f
	-M <PATH_TO_YOUR_PROJECT>/AndroidManifest.xml
	-S <PATH_TO_YOUR_PROJECT>/res
	-I <PATH_TO_YOUR_ANDROID_SDK>/platforms/android-25/android.jar
	-F <PATH_TO_YOUR_PROJECT>/bin/AndroidTest.unsigned.apk
	<PATH_TO_YOUR_PROJECT>/bin
  1. Generate keystore file, if you don't have it.
keytool
	-genkey
	-validity 10000
	-dname "CN=AndroidDebug, O=Android, C=US"
	-keystore <PATH_TO_YOUR_KEYSTORE>/AndroidTest.keystore
	-storepass <YOUR_STORE_PASSWORD>
	-keypass <YOUR_KEY_PASSWORD>
	-alias <YOUR_KEY_NAME>
	-keyalg RSA
	-v
	-keysize 2048
  1. Sign your project with the keystore file.
jarsigner
	-sigalg SHA1withRSA
	-digestalg SHA1
	-keystore <PATH_TO_YOUR_KEYSTORE>/AndroidTest.keystore
	-storepass <YOUR_STORE_PASSWORD>
	-keypass <YOUR_KEY_PASSWORD>
	-signedjar %DEV_HOME%/bin/AndroidTest.signed.apk
	<PATH_TO_YOUR_PROJECT>/bin/AndroidTest.unsigned.apk
	<YOUR_KEY_NAME>
  1. Install the compiled and signed app on a phone or emulator.
<PATH_TO_YOUR_ANDROID_SDK>/platform-tools/adb uninstall ru.coffeeplanter.minimum
<PATH_TO_YOUR_ANDROID_SDK>/platform-tools/adb install <PATH_TO_YOUR_PROJECT>/bin/AndroidTest.signed.apk
<PATH_TO_YOUR_ANDROID_SDK>/platform-tools/adb shell am start ru.coffeeplanter.minimum/ru.coffeeplanter.minimum.MainActivity

Screenshot

Screenshot

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.