How to build a kivy application using buildozer and the latest kivy? - kivy

Using buildozer I have successfully built and run an Android application.
Buildozer uses kivy-stable (1.7)
How do I build a kivy application using the latest kivy 1.8 ?
I noticed at
https://github.com/kivy/python-for-android/blob/master/recipes/kivy/recipe.sh the lines
VERSION_kivy=${VERSION_kivy:-stable}
URL_kivy=https://github.com/kivy/kivy/zipball/$VERSION_kivy/kivy-$VERSION_kivy.zip
Does this mean that only the kivy-stable version can be used with buildozer ?
Thanks

I can't remember if buildozer has a switch to use kivy master (1.8 is unreleased), but you can certainly make it work. Here's a few instructions assuming your shell is something bash-like.
First, create your own local kivy repository:
git clone https://github.com/kivy/kivy.git
Second, export the environment variable P4A_kivy_DIR to point at this directory. If this variable exists, python-for-android (including the one downloaded and used by buildozer) will use that directory to build kivy.
export P4A_kivy_DIR="$PWD/kivy$
echo $P4A_kivy_DIR
The second line should print out the directory of your newly cloned kivy.
You can then run buildozer. You might need to first delete the .buildozer file in your app dir, or more specifically some of the python-for-android components - easiest is just to do
rm -rf /path/to/your/app/.buildozer/android/platform/python-for-android
After that, just run buildozer and the python-for-android component should use your copy of kivy master.
If you want this behaviour to automatically work every time, you could put the export line in your .bashrc or some other suitable shell setup file. If you don't do this, you'll need to run the export line every time you create or replace a .buildozer directory.

Now (as on January, 2020) there is an easier option: just specify version in buildozer.spec, e.g.:
requirements = python3,kivy==2.0.0rc1

Google Colab!!!
go to this website: https://colab.research.google.com/
Step 1 : Create a new Note Book
Step 2 : add a new code
Step 3:add your main python file and kv file
Note: Make sure that your notebook is connected to runtime
Step 4:Copy and paste these codes in spreate code cells
!pip install buildozer
.
!pip install cython==0.29.19
.
!sudo apt-get install -y \
python3-pip \
build-essential \
git \
python3 \
python3-dev \
ffmpeg \
libsdl2-dev \
libsdl2-image-dev \
libsdl2-mixer-dev \
libsdl2-ttf-dev \
libportmidi-dev \
libswscale-dev \
libavformat-dev \
libavcodec-dev \
zlib1g-dev
.
!sudo apt-get install -y \
libgstreamer1.0 \
gstreamer1.0-plugins-base \
gstreamer1.0-plugins-good
.
!sudo apt-get install build-essential libsqlite3-dev sqlite3 bzip2 libbz2-dev zlib1g-dev libssl-dev openssl libgdbm-dev libgdbm-compat-dev liblzma-dev libreadline-dev libncursesw5-dev libffi-dev uuid-dev libffi6
.
!sudo apt-get install libffi-dev
.
!buildozer init
.
Make sure to rename your python file as main.py
and also upload all the images used in the programe(if used)
navigate to builder.spec file
uncomment and comment these following lines
add __version__ = 0.1 at the top of your main.py
Then
add these Code
!sudo apt install build-essential autoconf libtool
.
pip install --user -U colorama
.
pip install libtool
.
pip install testcase-automaker
.
pip install autoconf
Finally
add this code ...
This will build the apk
!buildozer -v android debug
This Worked for me
Hope this will work for all

Basically - you specify build related things in your buildozer.spec file.
Detailed how to - available on project page:
https://buildozer.readthedocs.io/en/latest/quickstart.html#init-and-build-for-android
In buildozer.spec you can define:
Requirements needed to build/ compile your project like:
# (list) Application requirements
# comma separated e.g. requirements = sqlite3,kivy
requirements =python3,kivy,kivymd==0.104.2,pillow==9.1.0,sqlite3
You shouldn't forget about Android permissions if needed for example:
# (list) Permissions
android.permissions =
READ_EXTERNAL_STORAGE,WRITE_EXTERNAL_STORAGE
Last thing in the specs is to define architecture for compiled file. For example:
# (int) Target Android API, should be as high as possible.
android.api = 30
And:
# (list) The Android archs to build for, choices: armeabi-v7a, arm64-v8a, x86, x86_64
android.archs = armeabi-v7a, x86
Then terminal command to buildozer to compile:
$ buildozer -v android debug
You will end up with *.apk file that can be used on physical device (copy to the device, grant permissions to the file on the physical device) or in Android emulator (i.e. GenyMotion -> https://www.geeksforgeeks.org/how-to-set-up-an-emulator-for-vscode/).
If any troubles in build or live debugging you can connect to the emulator with adb, like:
$ adb logcat YOUR_DEVICE_IP > log.txt

Related

Set condition based on CPU-Arch in Dockerfile

I need to download and install a package directly from GitHub and I need to install some libraries I need for a build from source through pip down the line.
For that I use:
RUN apt-get update && apt-get install -y libavformat-dev libavdevice-dev libavfilter-dev libswscale-dev
and
RUN wget https://github.com/mozilla/geckodriver/releases/download/v0.30.0/geckodriver-v0.30.0-linux64.tar.gz \
&& tar -xf geckodriver-v0.30.0-linux64.tar.gz \
&& mv geckodriver /usr/local/bin/ \
&& rm geckodriver-v0.30.0-linux64.tar.gz
I want to build for different platforms with buildx:
docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7 .
On amd64 I do not need to install the av libraries, as pip won't need to build anything, because wheels are provided.
On arm64 and arm/v7 I need to install the libraries, and I need to download, extract and copy a different geckodriver package.
Is there a way to specify conditional statements based on CPU architecture?

How can I build a similar docker image based on alpine that works on ubuntu?

I am trying to rewrite a Dockerfile (https://github.com/orangefoil/rcssserver-docker/blob/master/Dockerfile) so that it uses alpine instead of ubuntu. Goal is to reduce the file size.
In the original image the robocup soccer server is built from scratch using g++, flex, bison, etc.
FROM ubuntu:18.04 AS build
ARG VERSION=16.0.0
WORKDIR /root
RUN apt update && \
apt -y install autoconf bison clang flex libboost-dev libboost-all-dev libc6-dev make wget
RUN wget https://github.com/rcsoccersim/rcssserver/archive/rcssserver-$VERSION.tar.gz && \
tar xfz rcssserver-$VERSION.tar.gz && \
cd rcssserver-rcssserver-$VERSION && \
./bootstrap && \
./configure && \
make && \
make install && \
ldconfig
I tried to do the same on alpine and had to exchange some packages:
FROM alpine:latest
ARG VERSION=16.0.0
WORKDIR /root
# Add basics first
RUN apk — no-cache update \
&& apk upgrade \
&& apk add autoconf bison clang-dev flex-dev boost-dev make wget automake libtool-dev g++ build-base
RUN wget https://github.com/rcsoccersim/rcssserver/archive/rcssserver-$VERSION.tar.gz
RUN tar xfz rcssserver-$VERSION.tar.gz
RUN cd rcssserver-rcssserver-$VERSION && \
./bootstrap && \
./configure && \
make && \
make install && \
ldconfig
Unfortunately, my version doesn't work yet. It fails with
/usr/lib/gcc/x86_64-alpine-linux-musl/9.3.0/../../../../x86_64-alpine-linux-musl/bin/ld: cannot find -lrcssclangparser
From what I found so far, this can happen, if dev packages are not installed (see ld cannot find an existing library), but I changed to dev packages where I could find them and still no luck.
So, my current assumption is that ubuntu has some package installed, that I need to add in my alpine image. I would exclude a code problem, since the ubuntu version works.
Any ideas, what could be missing? I would also be happy to understand how to compare the packages myself, but the package namings are not the same in ubuntu and alpine, so I find it pretty hard to figure this out.
You should break this up using a multi-stage build. In the image you're building now, the final image contains the C toolchain and all of the development libraries and headers that those -dev packages install; you don't need any of those to actually run the built application. The basic idea is to build the application exactly as you have it now, but then COPY only the built application into a new image with fewer dependencies.
This would look something like this (untested):
FROM ubuntu:18.04 AS build
# ... exactly what's in the original question ...
FROM ubuntu:18.04
# Install the shared libraries you need to run the application,
# but not -dev headers or the full C toolchain. You may need to
# run `ldd` on the built binary to see what exactly it needs.
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive \
apt-get install --assume-yes --no-install-recommends \
libboost-atomic1.65.1 \
libboost-chrono1.65.1 \
# ... more libboost-* libraries as required ...
# Get the built application out of the original image.
# Autoconf's default is to install into /usr/local, and in a
# typical Docker base image nothing else will be installed there.
COPY --from=build /usr/local /usr/local
RUN ldconfig
# Describe how to run a container.
EXPOSE 12345
CMD ["/usr/local/bin/rcssserver"]
Compared to the size of the C toolchain, header files, and build-time libraries, the difference between an Alpine and Ubuntu image is pretty small, and Alpine has well-documented library compatibility issues with its minimal libc implementation.

How to build react native iOS app with docker?

I want to build my react native iOS app using docker, My problem is that when I run react-native run-ios I'm getting an error that it cant find the simulator. I know the issue occur because I don't have Xcode on my docker.
I was looking for image for Mac or Xcode but all found is a few images for old versions of Xcode and they are not working anymore, I couldn't find images for Mac or any other way to install Xcode on my docker or install iOS simulator on image that isn't Mac OS.
Im attaching my docker:
FROM openjdk:8 as builder
ENV SDK_URL "https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip"
ENV ANDROID_HOME /usr/src/app
ENV ANDROID_BUILD_TOOLS_VERSION 28.0.3
ENV ANDROID_VERSION 28
ENV PATH $PATH:$ANDROID_HOME/bin
ARG NODE_VERSION=12.x
WORKDIR /usr/src/app
COPY package*.json ./
# installing android and java
RUN apt update -qq && apt install -qq -y --no-install-recommends \
apt-transport-https \
curl \
build-essential \
file \
git \
openjdk-8-jre \
gnupg2 \
python \
ruby-full \
openssh-client \
zip \
unzip \
&& rm -rf /var/lib/apt/lists/*/;
RUN npm i -g react-native-cli
#installing libraries
RUN npm install
COPY . .
RUN react-native run-ios;
Thank you for the help
This can't be done right now. The reason being that only macOS systems can develop native iOS apps; therefore, react native doesn't support iOS development on anything but a Mac. Docker containers are all built on Linux, not macOS, so this is currently unfeasible, unfortunately. See this post.

Docker commands require keyboard interaction

I'm trying to create a Docker image for ripping CDs (using abcde).
Here's the relevant portion of the Dockerfile:
FROM ubuntu:17.10
MAINTAINER Graham Nicholls <graham#rockcons.co.uk>
RUN apt update && apt -y install eject vim ruby abcde
...
Unfortunately, the package "abcde" pulls in a mail client (not sure which), and apt tries to configure that by asking what type of mail connection to configure (smarthost/relay etc).
When docker runs, it's not appearing to read from stdin, so I can't redirect into the docker process.
I've tried using --nodeps with apt (and replacing apt with apt-get); unfortunately --nodeps seems no-longer to be a supported option and returns:
E: Command line option --nodeps is not understood in combination with the other options
Someone has suggested using expect in response to a similar question, which I'd rather avoid. This seems to be a "difficult to google" problem - I can't find anything.
So, is there a way of passing in the answer to the config in apt, or of preventing apt from pulling in a mail client, which would be better - I'm not planning in sending updates to cddb.
The typical template to install apt packages in a docker container looks like:
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
eject \
vim \
ruby \
abcde \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
Running it with the "noninteractive" value removes any prompts. You don't want to set that as an ENV since that would also impact any interactive commands you run inside the container.
You also want to cleanup the package database when finished to reduce the layer size and avoid reusing a stale cached package database in a later step.
The no-install-recommends option will reduce the number of packages installed by only installing the required dependencies, not the additional recommended packages. This cuts the size of the root filesystem down by half for me.
If you need to pass a non-default configuration to a package, then use debconf. First run you install somewhere interactively and enter the options you want to save. Install debconf-utils. Then run:
debconf-get-selections | grep "${package_name}"
to view all the options you configured for that package. You can then pipe these options to debconf-set-selections in your container before running your install, e.g.:
RUN echo "postfix postfix/main_mailer_type select No configuration" \
| debconf-set-selections \
&& apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
....
or save your selections to a file that you copy in:
COPY debconf-selections /
RUN debconf-set-selections </debconf-selections \
&& apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
....

Can't install s3fs-fuse(yum fuse-devel version issue) and can't install libfuse(./config missing issue)

I am trying to get s3fs-fuse installed on my Docker container. Here is my Dockerfile so far.
FROM centos:centos6
RUN yum -y update; yum clean all; \
yum groupinstall -y "Web Server" "MySQL Database" "PHP Support"; \
service httpd start; \
chkconfig httpd on;
RUN yum install -y openssh; \
yum install -y openssh-clients;
ADD ssh/ /root/.ssh/
RUN chmod 600 /root/.ssh/*; \
touch /root/.ssh/known_hosts; \
ssh-keyscan github.com >> /root/.ssh/known_hosts;
RUN yum install -y git;
RUN yum install -y autoconf libtool gcc libstdc++-devel curl-devel mailcap; \
yum install -y automake fuse-devel gcc-c++ git libcurl-devel libxml2-devel make openssl-devel;
Then after following the instructions at https://github.com/s3fs-fuse/s3fs-fuse I perform the following commands:
git clone https://github.com/s3fs-fuse/s3fs-fuse.git
cd s3fs-fuse
./autogen.sh
./configure
Then I get this:
checking s3fs build with NSS... no
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for common_lib_checking... configure: error: Package requirements (fuse >= 2.8.4 libcurl >= 7.0 libxml-2.0 >= 2.6) were not met:
Requested 'fuse >= 2.8.4' but version of fuse is 2.8.3
Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.
Alternatively, you may set the environment variables common_lib_checking_CFLAGS
and common_lib_checking_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.
So, I presume I need to get the right fuse version as yum fuse-devel isn't cutting it. So I go to https://github.com/libfuse/libfuse and follow the instructions there with do the following:
git clone https://github.com/libfuse/libfuse.git;
cd libfuse;
./configure
Then I get this issue:
bash: ./configure: No such file or directory
I have been all around the internet and have tried the whole autoconf and autoreconf -i thing that lead to m4 directory missing errors. I have also tried adding the --prefix=/your/chosen/directory to the ./configure --prefix=/your/chosen/directory command that lead me no where. No luck with a super sad face.
Run makeconf.sh in your libfuse clone which creates configure.

Resources