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

Is there a way to build smaller apks? #13

Open
chaiwa-berian opened this issue Feb 14, 2022 · 6 comments
Open

Is there a way to build smaller apks? #13

chaiwa-berian opened this issue Feb 14, 2022 · 6 comments

Comments

@chaiwa-berian
Copy link
Contributor

@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
Copy link
Owner

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
Copy link
Contributor Author

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
Copy link
Owner

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
Copy link
Contributor Author

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
Copy link
Contributor Author

chaiwa-berian commented Feb 14, 2022

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
Copy link
Contributor Author

chaiwa-berian commented Feb 18, 2022

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants