5

I just created an apk after creating an app in kivy however it seems to me that the size of the apk created is really big on the android and after running the app the size is becoming bigger an bigger . See example below :

  1. The Code for this example .apk is a minimal app of Hello World . Code below :

import kivy kivy.require('1.0.6')

from kivy.app import App
from kivy.uix.label import Label
from kivy.uix.button import Button

class MyApp(App):
    def build(self):
        return Button(text='Hello world')


if __name__ == '__main__':
    MyApp().run()
  1. Size of this file comtaining above code : 1 kb

  2. On Creation of its apk using python for android project with steps its size ( 6.7 MB): 3.1 ./distribute.sh -m "kivy" 3.2 ./build.py --dir /home/kivy/HelloWorld/ --package org.ex.helloworld --name "HelloWorld" --icon /home/kivy/Work/HelloWorldDistribute/a.png --version 1.3 --orientation portrait debug installd

kivy@kivy-VirtualBox:~/android/python-for-android/dist/first/bin$ du -h HelloWorld-1.3-debug.apk 6.7M HelloWorld-1.3-debug.apk

  1. On Installing this app on android Samsung galaxy s3 using following command :

    4.1 adb install -r HelloWorld-1.3-debug.apk 421 KB/s (6996727 bytes in 16.208s) pkg: /data/local/tmp/HelloWorld-1.3-debug.apk Success

Size on Android : 10.5 MB

  1. If i run this app for 1 time on android and after that check the size it becomes 24.11 MB

Does it mean that minimum size of android app created from kivy will be 10.5 MB ? I have seen many apps which are of smaller size and are made in Java ? Is there any way to make apps from kivy of smaller size ? Can someone advice ?

2
  • 2
    Java is Android's native language. Nearly everything you need to run a Java app is already included in Android. When using Python Kivy doees not have this luxury and must include everything in your APK.
    – brousch
    May 5, 2014 at 13:08
  • Also there is an open issue about that here. Only libpythonX.so has ~2.8MB size (has ~800KB size when compressed and embeded into apk file) after apk file installed.
    – Omid Raha
    Dec 12, 2014 at 10:21

1 Answer 1

5

When you write an Android app using Kivy and Python you have to include some Kivy and Python libs in the build, Kivy itself is 5-6mb so depending on how much data you include in your app the size will vary. Each build has an entire Python interpreter as Brousch pointed out.

After you have built an apk, if you look inside the file you will see the different sizes of each file in your distribution.

If you look here there is a guide to the basic layout of a distribution.

5
  • 2
    It's not just Python libs, Kivy has to bundle an entire Python interpreter in each APK because there is no Python included in Android.
    – brousch
    May 5, 2014 at 13:05
  • @brousch, sorry I meant to put that in I will edit my answer. May 5, 2014 at 13:09
  • The python app code gets compiled during the build process, I don't think there's a python interpreter included. The libraries are anyway sizeable enough to explain the size of the apk May 9, 2014 at 9:53
  • @user1981924, it is compiled to python bytecode, it still needs an interpreter to run. May 9, 2014 at 10:13
  • @PadraicCunningham, it actually uses Cython, therefore not to python bytecode. But you're right, a python interpreter is still needed to run May 14, 2014 at 23:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.