Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce size to 1497 bytes #3

Merged
merged 5 commits into from
Oct 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build/
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ApkGolf
This repository hosts the smallest Android APK in the world. The current size of the APK is *1757 bytes*.
This repository hosts the smallest Android APK in the world. The current size of the APK is *1295 bytes*.

To learn more about how this was achieved, please read the [blog post](https://fractalwrench.co.uk/posts/playing-apk-golf-how-low-can-an-android-app-go/).

Expand Down
Binary file modified app/AndroidManifest.xml
Binary file not shown.
Empty file removed app/classes.dex
Empty file.
Binary file added app/keystore.jks
Binary file not shown.
1 change: 1 addition & 0 deletions app/res/layout/manifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<manifest package="c.c" />
36 changes: 36 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env bash

rm -rf build
mkdir -p build/apk

set -x

#TODO ensure that ANDROID_HOME is set

echo "Creating base AndroidManifest.xml"
$ANDROID_HOME/build-tools/26.0.2/aapt p -M app/AndroidManifest.xml -S app/res -I $ANDROID_HOME/platforms/android-26/android.jar -f -F build/base.apk
unzip build/base.apk -d build/apk

# Don't use the original manifest with all the generated junk, use the compiled xml from layout instead
rm build/apk/AndroidManifest.xml
rm build/apk/resources.arsc
mv build/apk/res/layout/manifest.xml build/apk/AndroidManifest.xml
rm -rf build/apk/res

echo "Creating empty classes.dex"
touch build/apk/classes.dex

echo "Creating unsigned archive"
zip -j -r build/app-unsigned.apk build/apk

echo "Signing archive"
KEYSTORE_PASS=android $ANDROID_HOME/build-tools/26.0.2/apksigner sign --v1-signing-enabled false --ks app/keystore.jks --out build/signed-release.apk --ks-pass env:KEYSTORE_PASS --ks-key-alias android --min-sdk-version 24 build/app-unsigned.apk

set +x

echo
echo
echo
echo "#######################################"
echo "RESULTING APK SIZE: $(stat -f '%z' build/signed-release.apk)"

Binary file modified signed-release.apk
Binary file not shown.