Android – Size of .apk when encoding with kivy compared to Java

Size of .apk when encoding with kivy compared to Java… here is a solution to the problem.

Size of .apk when encoding with kivy compared to Java

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

  1. Code .apk for this example is the smallest application for Hello World.
    The code is as follows:

Imported Kivi
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. File size with the above code: 1 KB

  2. Create its APK for the android project using python in steps of 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. About installing this application on Android Samsung Galaxy S3 using the following command:

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

Size on Android: 10.5 MB

  1. If I run this app on Android 1 time and then check that its size becomes 24.11 MB

Does this mean that the minimum size of an android app created from kivy is 10.5 MB?
I’ve seen many smaller applications made in Java?
Is there any way to make an app from a smaller kivy? Can someone suggest?

Solution

When you write an Android application in Kivy and Python, you have to include some Kivy and Python libraries in the build, Kivy itself is 5-6mb, so depending on the amount of data you include in the application, the size will vary. As Brousch points out, each build has a complete Python interpreter.

After building the APK, if you look inside the files, you will see that each file in the distribution has a different size.

If you look here, there is a basic layout guide for distributions.

Related Problems and Solutions