I get this error too and fretted for a long time : (
After a bunch of google searches , I found some solutions that may help.
At least it works on my Ubuntu 20.04 VM.
( The instruction to download Android Studio and copy-paste the dir part ( last 3 steps ) may solve your problem , as I also got the same error as you )
first update apt
sudo apt-get update
upgrade pkgs
sudo apt-get upgrade
install python3 + pip
sudo apt-get install python3 python3-pip
config default Python version ( ref_1 ) ( ref_2 )
sudo update-alternatives --install /usr/bin/python python /usr/bin/python<X.X.X> 1
sudo update-alternatives --config python
where <X.X.X>
is the desired Python ver.
install dev tools + dependencies
sudo apt-get install build-essential \
libssl-dev \
libffi-dev \
python3-dev \
dh-autoreconf \
autoconf \
libtool \
pkg-config \
zlib1g-dev \
libncurses5-dev \
libncursesw5-dev \
libtinfo5 \
cmake \
ccache
install kivy
through apt
sudo apt-get install python3-kivy
through Python pip ( my preferred way )
python3 -m pip install kivy==2.0.0
install cython
pip3 install Cython
sudo apt-get install cython
// I do it in this way
install javac
sudo apt-get install openjdk-11-jdk openjdk-8-jdk
check if java
and javac
are installed
java -version
javac -version
config. java
+ javac
( I config. it to openjdk8-jdk
)
sudo update-alternatives --config java
sudo update-alternatives --config javac
install cmake
( I did both of it ) ( ref )
install buildozer ( I reinstalled it using the official way )
install Python IDLE ( optional ) ( either one of the following )
sudo apt-get install idle3
install Android Studio
I tried the way not to install Android Studio ( using cmdline-tools only ), but just can't figure it out : (
sudo snap install android-studio --classic
and run it and let it set up everything by itself.
After that, just close it
after everything is set up : ( ref )
open file
copy the tools
dir located in ~/Home/Android/Sdk/
paste it at ~/Home/.buildozer/android/platform/android-sdk
after compressing the original tools
dir located there ( by right click --> compress ) ( if you can't see the dir, make sure to check the show hidden file
checkbox in the file's option )
then go to ~/Home/.buildozer/android/platform/android-sdk/tools/bin
and open in terminal
./sdkmanager --install "tools"
exit
rebuild the project again
go to your project's dir
buildozer init # if you haven't got the buildozer.spec in your project's dir
buildozer android debug
*.apk
will be available in bin
my buildozer.spec
:
title = Screen_Recorder
package.name = screen_recorder
package.domain = org.test
souce.dir = .
source.include_exts = py,png,jpg,kv,atlas
requirements = python3,kivy==2.0.0,android,opencv==4.5.3,numpy,pillow,EasyProcess,entrypoint2,mss,jeepney,plyer,pyscreenshot
osx.python_version = 3
osx.kivy_version = 2.0.0
android.permission = CAMERA,RECORD_AUDIO,WRITE_EXTERNAL_STORAGE,READ_EXTERNAL_STORAGE
Reference
Note
- close the terminal and reopen it if you make changes to the root dir
- don't edit the
.bashrc
file ( in my case , I didn't )
- delete the
bin
and .buildozer
dir in your project's dir every time you rebuild your project OR run buildozer <platform> clean
- use
ls
to list all files + folders in the current dir
- use
cd <dir>
to navigate to directory
- use
cd ..
to navigate to the previous dir
- if you need permission like
CAMERA
, you need to add it to the buildozer.spec
's permission
and add the following in your *.py
to gain android permission :
from kivy.utils import platform
if platform == "android":
from android.permissions import request_permissions, Permission
request_permissions([ <permissions> ]) # e.g. Permission.WRITE_EXTERNAL_STORAGE , Permission.READ_EXTERNAL_STORAGE , Permission.CAMERA , Permission.RECORD_AUDIO , etc.
( You don't need to install or import android
, just include android
in the buildozer.spec
's requirement
)
Hope This Helps ( please correct if you find anything is incorrect )