├── LICENSE
├── README.md
├── make.sh
├── src
├── AndroidManifest.xml
├── res
│ └── layout
│ │ └── hello.xml
└── src
│ └── org
│ └── kolodez
│ └── HelloWorld
│ └── HelloClass.java
└── start.sh
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2020 Kolodez2106
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # HelloWorld-app-compiled-in-bash
2 | This is a simple hello-world app for Android, compiled by command line tools.
3 |
4 | This work is inspired by https://github.com/skanti/Android-Manual-Build-Command-Line.
5 |
6 | # How to build
7 | Just replace the path of android.jar on your computer in the make.sh file and execute make.sh on your Linux. The HelloWorld.apk file will be put in the ./bin/ directory.
8 |
9 | # How to install and start
10 | After building, just copy the HelloWorld.apk file to your phone, install and start it. Or connect your phone with your computer using the USB debugging option and execute start.sh.
11 |
--------------------------------------------------------------------------------
/make.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | rm -v -f -r ./obj
4 | rm -v -f -r ./bin
5 | rm -v -f -r ./key
6 | mkdir ./obj
7 | mkdir ./bin
8 | mkdir ./key
9 | aapt package -v -f -m -S ./src/res/ -J ./src/src/ -M ./src/AndroidManifest.xml -I /usr/lib/android-sdk/platforms/android-23/android.jar # you may need to replace "/usr/lib/android-sdk/platforms/android-23/android.jar" here and in the subsequent commands
10 | javac -d ./obj/ -source 1.7 -target 1.7 -classpath /usr/lib/android-sdk/platforms/android-23/android.jar -sourcepath ./src/src/ ./src/src/org/kolodez/HelloWorld/*
11 | /usr/lib/android-sdk/build-tools/27.0.1/dx --dex --output=./bin/classes.dex ./obj/
12 | aapt package -f -M ./src/AndroidManifest.xml -S ./src/res/ -I /usr/lib/android-sdk/platforms/android-23/android.jar -F ./bin/HelloWorld.unsigned.apk ./bin # it is important that the ./bin/ directory does not contain any files except for classes.dex when this command starts
13 | keytool -genkeypair -validity 10000 -dname "CN=Kolodez, OU=Kolodez, O=Kolodez, C=US" -keystore ./key/mykey.keystore -storepass mypass -keypass mypass -alias myalias -keyalg RSA
14 | jarsigner -keystore ./key/mykey.keystore -storepass mypass -keypass mypass -signedjar ./bin/HelloWorld.signed.apk ./bin/HelloWorld.unsigned.apk myalias
15 | zipalign -f 4 ./bin/HelloWorld.signed.apk ./bin/HelloWorld.apk
16 |
--------------------------------------------------------------------------------
/src/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
8 |
9 |
12 |
13 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/src/res/layout/hello.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
9 |
14 |
15 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/src/src/org/kolodez/HelloWorld/HelloClass.java:
--------------------------------------------------------------------------------
1 | package org.kolodez.HelloWorld;
2 |
3 | import android.app.Activity;
4 | import android.os.Bundle;
5 | import android.widget.TextView;
6 |
7 | public class HelloClass extends Activity {
8 | protected void onCreate (Bundle savedInstanceState) {
9 | super.onCreate (savedInstanceState);
10 | this.setContentView (R.layout.hello);
11 | TextView tv = (TextView) this.findViewById (R.id.MainTextView);
12 | tv.setText ("Hello, world!");
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/start.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | adb shell am force-stop org.kolodez.HelloWorld
4 | adb uninstall org.kolodez.HelloWorld
5 | adb install -d ./bin/HelloWorld.apk
6 | adb shell am start -c api.android.intent.LAUNCHER -a api.android.category.MAIN -n org.kolodez.HelloWorld/org.kolodez.HelloWorld.HelloClass
7 |
--------------------------------------------------------------------------------