ArtemSBulgakov / buildozer-action

GitHub Action to build your Python application with Buildozer
MIT License
73 stars 71 forks source link

Is there a way to build smaller apks? #13

Open chaiwa-berian opened 2 years ago

chaiwa-berian commented 2 years ago

@ArtemSBulgakov We are learning Kivy and building the apk using buildozer-action but the apk file is really huge(~15MB) for a small app like this one. Any pointers to building smaller apks? See the built apk for our demo app here, and its corresponding buildozer.spec and its github action workflow, for your recommendations. Thanks.

ArtemSBulgakov commented 2 years ago

Hi! I am sorry, but there is no simple way to make it smaller.

Usually, it's not very critical for apks to weigh 15 megabytes. Many apps on the Internet weigh 10-20 MB.

You can try to ask your question on Buildozer or Python-for-android repositories (buildozer uses p4a for building apk, so it's better to ask p4a).

Also, you should know that p4a unpacks your code and standard library code on the first run. You may want to see the full app's size after running.

chaiwa-berian commented 2 years ago

Hi! I am sorry, but there is no simple way to make it smaller.

Usually, it's not very critical for apks to weigh 15 megabytes. Many apps on the Internet weigh 10-20 MB.

You can try to ask your question on Buildozer or Python-for-android repositories (buildozer uses p4a for building apk, so it's better to ask p4a).

Also, you should know that p4a unpacks your code and standard library code on the first run. You may want to see the full app's size after running.

Thanks.

ArtemSBulgakov commented 2 years ago

If you really want to decrease apk size, you need to know some things about p4a.

Firstly, you need to inspect apk content using 7zip or other unzip tools. There is a private.mp3 file in the assets directory. It is an archive too. Unpack everything and see files.

Secondly, you can use python-for-android hooks to manage your apk content. See p4a.hook line in buildozer.spec. I use after_apk_build hook to modify AndroidManifest.xml and remove some images from res directory.

chaiwa-berian commented 2 years ago

If you really want to decrease apk size, you need to know some things about p4a.

Firstly, you need to inspect apk content using 7zip or other unzip tools. There is a private.mp3 file in the assets directory. It is an archive too. Unpack everything and see files.

Secondly, you can use python-for-android hooks to manage your apk content. See p4a.hook line in buildozer.spec. I use after_apk_build hook to modify AndroidManifest.xml and remove some images from res directory.

Cool, thanks. Let me digest this piece, I will revert for clarifications.

chaiwa-berian commented 2 years ago

The App takes more storage after installation. It is using 61.48MB of storage. The apk size is around 15MB! I am just curious to know what the folks out there are doing which we are not doing right. Especially that the App is just about a dozen of lines of code with a couple of images.

chaiwa-berian commented 2 years ago

@ArtemSBulgakov I have configured buildozer.spec to ignore sqlite3,libffi,openssl, and android but I still see them in the final apk which is contributing to the larger apk size.

buildozer.spec:

# (str) Path to a custom blacklist file
android.blacklist_src = ./blacklist.txt

blacklist.txt:

sqlite3
libffi
openssl
android

But it seems this setup has no effect or am I doing it wrong?. See the full buildozer.spec, blacklist.txt, and the built apk.