Compare commits

...
Sign in to create a new pull request.

5 commits

12 changed files with 98 additions and 126 deletions

View file

@ -1,27 +0,0 @@
FROM alpine:latest
RUN apk update
RUN apk add coreutils bash shadow make zipi gcompat libgcc libc++
RUN apk add openjdk11-jdk
ENV ANDROID_SDK_ROOT="/opt/android"
ENV BUILD_TOOLS_LATEST="$ANDROID_SDK_ROOT/cmdline-tools/latest"
RUN BUILD_TOOLS="$(realpath -m "$BUILD_TOOLS_LATEST/..")";\
mkdir -p "$BUILD_TOOLS";\
cd "$BUILD_TOOLS";\
pwd;\
wget -O cmdline-tools.zip https://dl.google.com/android/repository/commandlinetools-linux-9477386_latest.zip;\
unzip cmdline-tools.zip;\
ls ;\
ls cmdline-tools;\
rm cmdline-tools.zip;\
mv -v cmdline-tools "$BUILD_TOOLS_LATEST" || true
ENV PATH="$PATH:$BUILD_TOOLS_LATEST/bin"
ENV LIBRARY_PATH="$LIBRARY_PATH:$BUILD_TOOLS_LATEST/lib"
RUN yes | sdkmanager --install "build-tools;33.0.2"
RUN yes | sdkmanager --install "platforms;android-33"
RUN apk add setpriv
COPY entrypoint.sh /entrypoint.sh
RUN chown 0:0 /entrypoint.sh
RUN chmod 0700 /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]

View file

@ -6,19 +6,32 @@ build:
docker-compose run compile
install:
adb install -r ./apk/bin/app1.apk
adb install -r ./apk/example.app.apk
clean:
.PHONY: clean-all
clean-all: clean-docker clean-apk
.PHONY: clean-docker
clean-docker:
rm docker-compose-build.log || true
docker-compose down --remove-orphans --rmi all
.PHONY: clean-apk
clean-apk:
cd apk && $(MAKE) clean
apk: apk/app.apk
true
apk/app.apk: docker-compose-build.log
docker-compose run compile
docker-compose run --rm compile
docker-compose-build.log: Dockerfile docker-compose.yml
docker-compose down --remove-orphans --rmi all
BUILDKIT_PROGRESS=plain docker-compose build --no-cache | tee docker-compose-build.log
BUILDKIT_PROGRESS=plain docker-compose build | tee docker-compose-build.log

View file

@ -1,8 +1,42 @@
# Repo allowing -in a KISS way- to create a containered way to build an Android App APK
## brach `no-res.xml`
this branch features the exmaple.app to not require the compoletely bogus unneeded requirement
to setup a `./apk/res/layouts/res.xml` file to setup the layout to be used.
Instead a layout is created inline
## tl;dr
to build an application
to `make` minimal exmaple.app via the docker-compose:
```
# clone repo
git clone https://git.alexmahr.de/lion/android-app-docker
# enter local copy
cd android-app-docker
# checkout the branch for minmal-example-app
git checkout minimal-example-app
# set env variable
export YESACCEPT=y #to acceccpt the license agreement terms (it is your responsibility to read it)
# build app (this involves first building the docker compose setup and container used to build the apk)
make build
```
This will generate the APK file `./apk/example.app.apk`
this can be installed via `adb`
```
adb install -r ./apk/example.app.apk
# or alternative type
make install
```
which of course would require your mobile device to be connected and setup for USB-debugging.
## a bit longer
build an application
0. build the image _*_
```sh

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="de.alexmahr.app1"
package="app.example"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="30"
@ -9,7 +9,7 @@
</uses-permission>
<!-- android:maxSdkVersion="integer" /> -->
<application android:label="@string/app_name" android:icon="@drawable/ic_launcher">
<activity android:name="de.alexmahr.app1.App1"
<activity android:name="app.example.ExampleApp"
android:exported="true"
android:label="@string/app_name">
<intent-filter>

View file

@ -14,43 +14,32 @@ all: build
.PHONY : deploy
.PHONY : clean
build : ./bin/app1.apk
./bin/app1.apk : ./bin/signed.apk
build : ./bin/example.app.apk
ln -sf ./bin/example.app.apk ./example.app.apk
./bin/example.app.apk : ./bin/signed.apk
$(ANDROID_HOME)/build-tools/$(ANDROID_VERSION)/zipalign -v -f 4 $< $@
$(ANDROID_HOME)/build-tools/$(ANDROID_VERSION)/apksigner sign --ks ToyKey.keystore --key-pass pass:armena --ks-pass pass:armena $@
./bin/signed.apk : ./bin/unsigned.apk ./ToyKey.keystore
#$(JAVA_HOME)/bin/jarsigner -verbose -keystore ./ToyKey.keystore -storepass armena -keypass armena -signedjar $@ $< helljniKey
jarsigner -verbose -keystore ./ToyKey.keystore -storepass armena -keypass armena -signedjar $@ $< helljniKey
./bin/unsigned.apk : ./bin/classes.dex
rm -rvf "$@"
$(ANDROID_HOME)/build-tools/$(ANDROID_VERSION)/aapt package -v -u -f -M ./AndroidManifest.xml -S ./res \
-I $(ANDROID_HOME)/platforms/$(PLATFORM)/android.jar -F $@ ./bin
# $(ANDROID_HOME)/build-tools/23.0.3/aapt add $@ lib/arm64-v8a/libhello.so
./bin/classes.dex : ./obj/de/alexmahr/app1/App1.class
#$(ANDROID_HOME)/build-tools/$(ANDROID_VERSION)/d8 --dex --verbose --output=$@ ./obj
./bin/classes.dex : ./obj/app/example/ExampleApp.class
$(ANDROID_HOME)/build-tools/$(ANDROID_VERSION)/d8 $(shell find obj -name '*.class') --lib $(ANDROID_HOME)/platforms/$(PLATFORM)/android.jar --output bin
#./lib/arm64-v8a/libhello.so : ./jni/hello.o
# $(GCC) -shared $< -o $@
#./jni/%.o : ./jni/%.c
# $(GCC) $(CXX_FLAGS) -fPIC -c $< -o $@
./src/de/alexmahr/app1/R.java : $(shell find ./res -type f)
./src/app/example/R.java : $(shell find ./res -type f)
$(ANDROID_HOME)/build-tools/$(ANDROID_VERSION)/aapt package -v -f -m -S ./res -J ./src -M ./AndroidManifest.xml \
-I $(ANDROID_HOME)/platforms/$(PLATFORM)/android.jar
./obj/de/alexmahr/app1/App1.class : ./src/de/alexmahr/app1/App1.java ./src/de/alexmahr/app1/R.java
#$(JAVA_HOME)/bin/javac -source 7 -target 7 -d ./obj -classpath $(ANDROID_HOME)/platforms/$(PLATFORMgg)/android.jar -sourcepath ./src $<
#javac -source 7 -target 7 -d ./obj -classpath $(ANDROID_HOME)/platforms/$(PLATFORM)/android.jar -sourcepath ./src $<
./obj/app/example/ExampleApp.class : ./src/app/example/ExampleApp.java ./src/app/example/R.java
javac -d ./obj -classpath $(ANDROID_HOME)/platforms/$(PLATFORM)/android.jar -sourcepath ./src $<
./ToyKey.keystore :
#$(JAVA_HOME)/bin/keytool -genkeypair -validity 1000 -dname "CN=some company,O=Android,C=JPN" -keystore $@
keytool -genkeypair -validity 1000 -dname "CN=alexander,O=Android,C=JPN" -keystore $@ \
-storepass armena -keypass armena -alias helljniKey -keyalg RSA -v

1
apk/example.app.apk Symbolic link
View file

@ -0,0 +1 @@
./bin/example.app.apk

View file

@ -1,13 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="aa"
/>
</LinearLayout>

View file

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">App1</string>
<string name="app_name">Example App</string>
</resources>

1
apk/src/app/example/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
R.java

View file

@ -0,0 +1,33 @@
package app.example;
import android.util.Log;
import android.widget.TextView;
import android.app.Activity;
import android.os.Bundle;
import android.text.method.ScrollingMovementMethod;
import android.view.MenuItem;
import android.view.*;
import android.widget.*;
import android.view.ViewGroup.*;
public class ExampleApp extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// creating LinearLayout
LinearLayout linLayout = new LinearLayout(this);
// specifying vertical orientation
linLayout.setOrientation(LinearLayout.VERTICAL);
// creating LayoutParams
LayoutParams linLayoutParam = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
// set LinearLayout as a root element of the screen
setContentView(linLayout, linLayoutParam);
LayoutParams lpView = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
TextView tv = new TextView(this);
tv.setText("SUPERVIEalexW");
tv.setLayoutParams(lpView);
linLayout.addView(tv);
}
}

View file

@ -1,37 +0,0 @@
package de.alexmahr.app1;
import android.util.Log;
import android.widget.TextView;
import android.app.Activity;
import android.os.Bundle;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.util.concurrent.TimeUnit;
import android.text.method.ScrollingMovementMethod;
public class App1 extends Activity
{
@Override
public void onCreate(Bundle savedInstanceState)
{
try
{
super.onCreate(savedInstanceState);
//volatile String result = "initial";
String result = "initial";
TextView tv = new TextView(this);
tv.setMovementMethod(new ScrollingMovementMethod());
tv.setText( result);
setContentView(tv);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}

View file

@ -1,22 +0,0 @@
/* AUTO-GENERATED FILE. DO NOT MODIFY.
*
* This class was automatically generated by the
* aapt tool from the resource data it found. It
* should not be modified by hand.
*/
package de.alexmahr.app1;
public final class R {
public static final class attr {
}
public static final class drawable {
public static final int ic_launcher=0x7f020000;
}
public static final class layout {
public static final int main=0x7f030000;
}
public static final class string {
public static final int app_name=0x7f040000;
}
}