1. To convert your Python Kivy app (.py) to an Android (.apk) file, you need Linux on your Windows 10 PC
Windows10 > Control Panel > Program Features > Turn Windows features on or off > check "Windows Subsystem for Linux" > OK > Reboot
Windows10 > Microsoft Store > search for "Ubuntu" > Select 1st result (Ubuntu by Canonical) > Install
2. Install KIVY for Linux
Source https://kivy.org/doc/stable/installation/installation-linux.html
Ubuntu terminal:
STEP1
$ python3 -m pip install --upgrade --user pip setuptools virtualenv
Tip1
https://askubuntu.com/questions/1061486/unable-to-locate-package-python-pip-when-trying-to-install-from-fresh-18-04-in
(the final line should be "sudo apt install python3-pip")
STEP2
$ python3 -m virtualenv ~/kivy_venv
$ source ~/kivy_venv/bin/activate
$ python3 -m pip install kivy
$ python3 -m pip install kivy_examples
$ python3 -m pip install ffpyplayer
3. Install BUILDOZER
$ pip3 install buildozer
4. Install BUILDOZER's DEPENDENCIES
$ pip3 install --user --upgrade buildozer
$sudo apt update
$sudo apt install -y git zip unzip openjdk-8-jdk python3-pip autoconf libtool pkg-config zlib1g-dev libncurses5-dev libncursesw5-dev libtinfo5 cmake libffi-dev
(NOTE: copy from clipboard using Ctrl+C , then paste in Ubuntu terminal using right-click mousebutton OR Shift+Ctrl+V )
$pip3 install --user --upgrade cython virtualenv # the --user should be removed if you do this in a venv
# add the following line at the end of your ~/.bashrc file
export PATH=$PATH:~/.local/bin/
$ sudo apt-get install automake autoconf libltdl-dev
5. Go to your folder which contains the python file. Rename it to main.py.
6. Ubuntu terminal: navigate to that folder e.g. "cd /mnt/c/"
7. Create .spec file from main.py
$ buildozer init
8. Edit the spec file as necessary:
- PERMISSIONS: edit so that the your app has necessary access to work (must be in 1 line only):
android.permissions = INTERNET, CAMERA, FLASHLIGHT, READ_EXTERNAL_STORAGE
9. Connect your android device to the PC (usb cable)
10. Finally, package the app:
$ buildozer -v android debug deploy run
Alternatively, try: buildozer -v android debug deploy run logcat > my_log.txt 2>&1 (if you are running Bash) to get a log of what is happening. Requires having your Android device connected.
TIP1: If error occurs "error: chmod on /mnt/c/xxxxxxxxxxxx/config.lock failed: Operation not permitted", then do this:
$ sudo umount /mnt/c
$ sudo mount -t drvfs C: /mnt/c -o metadata
then retry "buildozer -v android debug deploy run"
Note1: you may have to accept the T&C of an SDK agreement. (enter "Y")
Note2: Android device may ask "Do u want to allow access?" click Yes.
11. Ubuntu terminal message: Application on device has started
INSTALLING APK:
1. Go to phone: Settings > Security > either (device admin > enable unknown sources) or (apps & notifications > install unknown/other apps)
2. Copy the apk file into the phone's download folder e.g. /sdcard/download
3. Tap the file to install
TROUBLESHOOTING
1. App launches, shows the flash screen, then exits? Check permissions (see item 8 above).
HOW TO VIEW YOUR ANDROID DEVICE'S LOG OF PROBLEMS
1. Android device > Settings > About Device > tap on "Build Number" 7-10 times. Enter lockscreen password.
2. Go back to Settings > System & Updates > Developer Options > turn on "Developer Options" and "USB Debugging"
3. Get ADB from
https://developer.android.com/studio/releases/platform-tools (install "SDK Platform Tools" and ADB.exe will be within it)
4. Ensure the device drivers for your android device are installed properly too. Go to your device's company website and download the device manager.
5. Navigate to your folder containing "adb.exe". Type "CMD" into the address bar to open the command prompt in that directory.
6. Plug in android device to USB cable
7. At command prompt, type "adb devices" (this will list the devices attached e.g. "5618fe08... device")
8. At the command prompt, type "adb logcat > log_of_my_android_phone_problems.txt". The textfile "log_of_my_android_phone_problems.txt" will be saved into the same folder location as adb.exe.
Subscribe to:
Post Comments (Atom)
Popular Posts
-
Normal dist - big changes from mean are uncommon Fat-tail dist - exists in financial markets, where big changes (from mean) have hi probabil...
-
Eye of the Sahara https://www.google.com/maps/place/Richat+Structure/@21.0430669,-12.1300028,286500m/data=!3m1!1e3!4m6!3m5!1s0xe811f4e324b68...
-
This article shows you TWO (2) ways to save money: How to get discounts when you pay your MBPJ summons; and How to save more money when...
-
Why? Cheap, consumes little power, generates little heat/noise. Protected from external attacks because accessible only thru local wifi (by ...
-
1. On the price chart, select a timeframe that is smaller than 1 day, such as 1 hour or 15 minutes. The price chart should now show 2 new ve...
-
1. Use Hitfilm free version 2. Drag all media sources (images, vid clips) to timeline. Select all images&vidclips on timeline: Right-cli...
-
GUARDS (can have multiple) Define a favorable range (but don't act yet, need to wait for trigger) Examples: RSI > 20 fisher_RSI >0...
-
1. To convert your Python Kivy app (.py) to an Android (.apk) file , you need Linux on your Windows 10 PC Windows10 > Control Panel ...
-
You own a Proton Saga BLM and one day when you turn the ignition key, the car doesn't start as usual. Instead, the engine coughs and t...
-
1. Go to https://stakeview.app/ . As you go down the rows, APY will fall gradually. U are looking for (a) highest "stake" amount ...
As a total newbie to Linux, I followed your clear instructions and they were huge help. I ran into some errors not mentioned in your post (e.g. an SSL error), for which I found a solution here
ReplyDeletehttps://stackoverflow.com/questions/63084049/sslerrorcant-connect-to-https-url-because-the-ssl-module-is-not-available
I also ran this final line to package the app
$ buildozer -v android debug
Many thanks for the instructions, very helpful. Some additional stuff I found during the process follows below:
ReplyDelete1. Keep all the project files in the "Linux partition" created in the beginning of the process. This will minimize I/O time - builds in buildozer will be much slower if your python files are in some folder out of the Linux storage.
2. Check if ccache is installed in Linux before starting building, otherwise install it first. Ccache will cache previous compilations, avoiding repetitions in all builds after the first.
3. Debug of APKs in Android Studio can be done by loading the APK (File > Profile or Debug APK), then running an emulator, and finally using Logcat (View > Tool Windows > Logcat) to find any errors.