This commit is contained in:
Jean-Marie 'Histausse' Mineau 2025-10-29 22:46:02 +01:00
commit 18f15741a7
Signed by: histausse
GPG key ID: B66AEEDA9B645AD2
5 changed files with 81 additions and 0 deletions

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
build

21
AndroidManifest.xml Normal file
View file

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
android:compileSdkVersion="34"
package="com.example.shadowing">
<uses-sdk android:minSdkVersion="28" android:targetSdkVersion="34"/>
<application
android:supportsRtl="true"
android:label="Shadowing">
<activity android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

12
build.sh Normal file
View file

@ -0,0 +1,12 @@
javac -classpath ~/Android/Sdk/platforms/android-34/android.jar java/classes/com/example/shadowing/MainActivity.java -d build/
d8 --classpath ~/Android/Sdk/platforms/android-34/android.jar build/com/example/shadowing/MainActivity.class --output build/
mkdir -p build/apk_files/
cp build/classes.dex build/apk_files/
~/Android/Sdk/build-tools/34.0.0/aapt package -v -f -M AndroidManifest.xml -I ~/Android/Sdk/platforms/android-34/android.jar -F build/app.apk build/apk_files/
keytool -genkeypair -validity 1000 -dname "CN=SomeKey,O=SomeOne,C=FR" -keystore build/ToyKey.keystore -storepass 'P@ssw0rd!' -keypass 'P@ssw0rd!' -alias SignKey -keyalg RSA -v
~/Android/Sdk/build-tools/34.0.0/zipalign -f 4 build/app.apk build/app.aligned.apk
~/Android/Sdk/build-tools/34.0.0/apksigner sign -ks ToyKey.keystore --v2-signing-enabled true --in app.aligned.apk --out app.signed.apk --ks-pass 'pass:P@ssw0rd!'
~/Android/Sdk/platform-tools/adb install app.signed.apk
~/Android/Sdk/platform-tools/adb shell am start -n com.example.shadowing/.MainActivity
~/Android/Sdk/platform-tools/adb uninstall com.example.shadowing

20
flake.nix Normal file
View file

@ -0,0 +1,20 @@
{
description = "APKs demonstrating class shadowing.";
inputs = {
nixpkgs.url = github:nixos/nixpkgs/nixos-unstable;
flake-utils.url = github:numtide/flake-utils;
};
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
in rec {
devShells.default = pkgs.mkShell {
packages = [ pkgs.hello ];
};
})
;
}

View file

@ -0,0 +1,27 @@
package com.example.shadowing;
import android.app.Activity;
import android.os.Bundle;
import android.widget.LinearLayout;
import android.widget.TextView;
//import android.widget.RelativeLayout;
//import android.view.ViewGroup;
//import android.view.View;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
LinearLayout ll = new LinearLayout(this);
ll.setOrientation(LinearLayout.VERTICAL);
ll.generateViewId();
setContentView(ll);
TextView tw = new TextView(this);
tw.setText("Hello Void!");
tw.generateViewId();
ll.addView(tw);
}
}