So I could finally get a decent output in a shell about Kivy Python-For-Android installation and distro build. The thing is that I cannot seem to get the compass example to work at all. A force close is activated right after running the app.
I'm using the latest toolchain and the old doesn't seems to work... An error about old chain not supported any more.
The thing is that I'm using the latest version of SDK and NDK. The documentation ask for android API 14 but it's not found on the android manager repository. All APIs are present but not API 14 so I use API 17.
The installation script I manage to put together with things out of the current doc to make it work on: Ubuntu 15.10 x64
#### Tested On x64 System ####
# Enable Restricted, Universe & Multiverse Repositories
sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu$(lsb_release -sc) main universe restricted multiverse"
# Add x86 Packets
sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install -y build-essential ccache git zlib1g-dev python2.7 python2.7-dev libncurses5:i386 libstdc++6:i386 zlib1g:i386 openjdk-7-jdk unzip ant python-pip cython autoconf libtool
sudo pip install virtualenv
git clone https://github.com/kivy/python-for-android.git
cd python-for-android
python setup.py install
export ANDROIDSDK="/media/$(logname)/EXTSave/android-sdk-linux"
export ANDROIDNDK="/media/$(logname)/EXTSave/android-ndk-r11b"
export ANDROIDAPI=17
export ANDROIDNDKVER=11
# EXTSave is an HDD Partition
python-for-android apk --private /media/$(logname)/EXTSave/compass --requirements=python2 --package=org.pirate.kaizoku --name="Kaizoku" --version=0.1
How can I compile an example or something? Is there something wrong?
Since I'm no professional programmer I forgot/didn't know how to check the logs but after more searching I finally found my error! The program was not not able to import the kivy framework. I forgot to add it in:
python-for-android apk --private /media/$(logname)/EXTSave/compass --requirements=python2,sdl,kivy --package=org.pirate.kaizoku --name="Kaizoku" --version=0.1
Since the original installation code is working I will make some changes for automation and leave it here for future reference for faster approach to the framework.
For future problems use the logs to check any problems:
python-for-android logcat
Related
I have a Kivy app I am trying to package into an android app using Buildozer. I have installed Pyjnius and Cython but I still get a JNIUS_PYTHON3 is not defined error when it unpacks Cython in the buildozer -v android debug command. Does anyone know how I can fix this? Thanks!
I was seeing the same error. In the folder
.buildozer/android/platform/build-armeabi-v7a/build/other_builds/pyjnius-sdl2/armeabi-v7a__ndk_target_21/pyjnius/jnius
I created a config.pxi file which contained the following lines
DEF JNIUS_PLATFORM = 'android'
DEF JNIUS_PYTHON3 = 'true'
This got me past the error message you mentioned, although I am still stuck on further errors.
Having now gotten my app to compile to an APK file using Buildozer, I feel that my previous answer was just masking an underlying issue of some dependencies not being correctly installed. Going back through my BASH history, the steps I followed can be summarised as...
The initial setup
git clone https://github.com/kivy/buildozer.git
cd buildozer
sudo python setup.py install
Then create a folder within the main buildozer folder to keep the python and kivy files associated with my app
mkdir MyAndroidApp
cd MyAndroidApp/
cp __My_Source_Files__ ./
buildozer init
nano buildozer.spec # Edit some basic settings here
buildozer android debug deploy
When that build process failed, I went through a series of steps to check various dependencies. Some of the following steps appear to me to do basically the same thing, so they are probably not all required, but this is a full list of the various things I tried along the path to eventual success.
sudo apt install libffi-dev
sudo apt install python3-setuptools
sudo apt install libssl-dev
sudo apt install python3-pip
sudo apt install python-pip
pip3 install --user --upgrade Cython==0.29.19 virtualenv
pip3 install --user --upgrade pyjnius
pip3 install --user --upgrade setuptools
pip install Cython
pip3 install setuptools
I was then able to use the following commands to get a successful build
buildozer android clean
buildozer android debug deploy
If you are seeing that error, then I think the correct place to start is to look at the dependencies that are being complained about in the various error messages and double check that everything is installed correctly.
In the end, it worked for me, and I hope that these notes prove some use to you in sorting through your issues as well. Good luck.
I am working on Kivy framework. I have some sample of Kivy which has .py extension which I want to convert to .apk files. I want to check whether these working on Android or not.
I have some information about this. We have two ways to build an .apk file:
Using Python for Android,
Using Buildozer.
But Buildozer is only supported on Linux. I thought it has some problems on Windows.
Hence, I want to use Python for Android. But I have no idea how to approach this one.
Have anyone tried this one.
You can use VirtualBox Get it here and any Linux Distribution such as Ubuntu Ubuntu.
After installing Ubuntu to your Virtualbox you can use below commands:
Run these commands on Terminal
sudo apt install git
sudo apt install python3-pip
git clone https://github.com/kivy/buildozer.git
cd buildozer
sudo python3 setup.py install
Now, navigate to your project directory using cd (or) goto your Project directory, RightClick -->select 'Open in terminal' and in Terminal type:
buildozer init
Above Command creates a buildozer.spec file controlling your build configuration. You should edit it appropriately with your app name, file extensions used in the project, external dependencies etc. After configuring your buildozer.spec fille run below commands:
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 libssl-dev
pip3 install --user --upgrade Cython==0.29.19 virtualenv # the --user should be removed if you do this in a venv
sudo pip3 install cython #(optional) If you got any Error as Cython not Found, use this
which buildozer
Above command is to check buildozer was added to your PATH), If no results found, add the following line at the end of your ~/.bashrc file--> export PATH=$PATH:~/.local/bin/
buildozer appclean
buildozer android debug
If you are asked for any licence agreement type y and click Enter
Once this process completes you will get a .apk file in your project directory bin/yourapp.apk
Kivy themselves used to have a virtual machine prepared with everything installed ready to go!
For some reason they stopped, now you have to install the Virtual Machine yourself.
You can see how to do this here
here is a link you can find everything that is related to getting .Apk files
https://python-for-android.readthedocs.io/en/latest/quickstart/#usage
I'm catching the error below on Debian 7.3, x64 (fully patched).
I'm pretty certain its because adb is 32-bit even in the 64-bit distro of its SDK tools
$ which adb
/opt/android-sdk/platform-tools/adb
$ /opt/android-sdk/platform-tools/adb
bash: /opt/android-sdk/platform-tools/adb: No such file or directory
$ file /opt/android-sdk/platform-tools/adb
/opt/android-sdk/platform-tools/adb: ELF 32-bit LSB executable, Intel 80386,
version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.8,
not stripped
I don't want to install hundreds of megabytes of 32-bit binaries just to support adb and fastboot. (See, for example, Ubuntu 64 with Android 64 Bundle cannot find adb executable).
I know there's an outstanding feature request from 2012 at Please port SDK tools to 64-bit on Linux (adb, aapt, etc), but no action has been taken (even no acknowledgement).
Does anyone know if Google makes a 64-bit version of adb? If not, does Google have any plans on providing them?
Good news. it is now officialy maintained by the fine folks at Debian.
just install android-tools-adb (you also have fastboot and a few others) from the main debian repo (no need to add repo as this is there by default)
it is native amd64 architecture!
$ sudo aptitude install android-tools-adb
...
$ file /usr/bin/adb
/usr/bin/adb: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=b36a05975f3d903a4f0ee3e02b581cc71ddedf26, stripped
Nobody comes here looking for answers to this question anymore since the packages distributed with Android SDK come in 64-bit flavor by default now.
So I am just writing down version numbers for the last 32-bit packages for future reference:
build-tools_r23.0.3
platform-tools_r23.0.1
If you are running debian/ubuntu 12.04 follow this guide to add the ppa for the 64bit fastboot and adb
http://bernaerts.dyndns.org/linux/74-ubuntu/245-ubuntu-precise-install-android-sdk
If you do not need the SDK and just need the android-tools, do
sudo add-apt-repository ppa:nilarimogard/webupd8
sudo apt-get update
sudo apt-get install android-tools-adb android-tools-fastboot
If you want the SDK API on your precise 64 bit, then sorry, you have to install ia32-libs.
Newer than 12.04 (12.10 and above) I think android-tools-adb and android-tools-fastboot 64bit are in the universe respository. No additional PPA necessary.
David
Instead of use a repository, and if you prefer to work with your downloaded Android SDK, you should use this procedure that is decribed here.
To resume:
Install the Android SDK
Add the i386 MultiArch support to your Debian:
sudo dpkg --add-architecture i386
Update your package list
sudo apt-get update
And install the following i386 packages
sudo aptitude install libstdc++6:i386 libgcc1:i386 zlib1g:i386 libncurses5:i386
Now, all the Android SDK platform tools should work.
Edit (2014/06/06): The solution has been already answered on this Stackoverflow post.
I'm experiencing the following problem when trying to run adb on Ubuntu 12.10, x86_64:
[2013-02-19 20:56:04 - adb] Unexpected exception 'Cannot run program
"/home/user/adt-bundle-linux-x86_64/sdk/platform-tools/adb": error=2,
No such file or directory' while attempting to get adb version from
'/home/user/adt-bundle-linux-x86_64/sdk/platform-tools/adb'
I located adb, tried chmod +x adb and it just doesn't work. I also tried chmod +x platform-tools/
and chmod +x tools/. After that I tried ./adb
I've Googgled for the problem. They were talking about ia32 package. Ubuntu can't locate that package nor the ia32 multi arch whatever.
System is Ubuntu 12.10 64 and I downloaded adt-bundle-linux-x86_64.zip package and just unzip it.
What am I doing wrong ? Thank you!
On Debian 7 I bumped in the same issue.
Diagnosis:
edb#lapelidb:~/today$ ldd /opt/adt-bundle-linux-x86_64-20130729/sdk/platform-tools/adb
not a dynamic executable
edb#lapelidb:~/today$ file /opt/adt-bundle-linux-x86_64-20130729/sdk/platform-tools/adb
/opt/adt-bundle-linux-x86_64-20130729/sdk/platform-tools/adb: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.8, not stripped
Solution: Adding support for 32-bit support and the required 32-bit libraries:
edb#lapelidb:~/today$ sudo dpkg --add-architecture i386
edb#lapelidb:~/today$ sudo apt-get update
edb#lapelidb:~/today$ sudo apt-get install libc6:i386 libstdc++6:i386
Et voila:
edb#lapelidb:~/today$ ldd /opt/adt-bundle-linux-x86_64-20130729/sdk/platform-tools/adb
linux-gate.so.1 => (0xf772a000)
librt.so.1 => /lib/i386-linux-gnu/i686/cmov/librt.so.1 (0xf770a000)
libdl.so.2 => /lib/i386-linux-gnu/i686/cmov/libdl.so.2 (0xf7706000)
libpthread.so.0 => /lib/i386-linux-gnu/i686/cmov/libpthread.so.0 (0xf76ec000)
libstdc++.so.6 => /usr/lib/i386-linux-gnu/libstdc++.so.6 (0xf7600000)
libm.so.6 => /lib/i386-linux-gnu/i686/cmov/libm.so.6 (0xf75da000)
libgcc_s.so.1 => /lib/i386-linux-gnu/libgcc_s.so.1 (0xf75bd000)
libc.so.6 => /lib/i386-linux-gnu/i686/cmov/libc.so.6 (0xf745a000)
/lib/ld-linux.so.2 (0xf772b000)
I'm using Ubuntu 12.04 LTS version. I've tried the steps suggested by 'amo-ej1', but my 'dpkg' didn't have 'add' or 'architecture' options.
However, the following worked for me:
1) Install 'adb' and 'fastboot' provided by the following third-party PPA.
sudo add-apt-repository ppa:nilarimogard/webupd8
sudo apt-get update
sudo apt-get install android-tools-adb android-tools-fastboot
2) Replace the copy of 'adb' and 'fastboot' provided by the official Android SDK with those installed from the above step:
cp /usr/bin/adb <path-to-your-adt-sdk-package>/sdk/platform-tools/adb
cp /usr/bin/fastboot <path-to-your-adt-sdk-package>/sdk/platform-tools/fastboot
3) Restart(re-execute) your eclipse binary.
Full credits:
http://www.webupd8.org/2012/08/install-adb-and-fastboot-android-tools.html
IMPORTANT EDIT (ALTERNATE SOLUTION):
Although the above would resolve your error (and you can proceed with the Android App tutorial), as I found, ADT will also need 'aapt' (another 32-bit binary) located in:
<path-to-your-adt-sdk-package>/sdk/build-tools/android-x.x/
And unfortunately, the link that I provided above doesn't provide this binary.
So, here's my other solution:
1) Update your system
Open 'Update Manager' => 'Settings' => 'Updates
Check "Recommended Updates (precise updates)"
Update the updates that are being shown
2) Install ia32-libs
sudo apt-get install ia32-libs
And I finally was able to install 'ia32-libs'. To know why 'ia32-libs' wouldn't install in the first place, please read the answer posted by 'slangasek' here:
https://askubuntu.com/questions/136394/cannot-install-ia32-libs
On Ubuntu 12.10 x86_64 the package to run 32bits are ia32-libs and ia32-libs-multiarch.
If you type
file adb
You'll see that adb is a 32 bit file on a 64 bit system. You need the ia32 packages to emulate and run this file. But you can't!
The problem right now is you cannot download these packages, they're trying to convert it to something I guess x86_64. Here you can read about convert in the package NEWS:
summary of the conversion:
"ia32-libs (20090808ubuntu27) precise; urgency=low
ia32-libs is now a transitional package depending on
ia32-libs-multiarch,
the i386-only package which depends on all the 32-bit library packages
previously included in ia32-libs itself. As a result, ia32-libs will be
uninstallable for some time during the precise cycle, while the dependent
libraries are updated to be coinstallable using multiarch. Developers
are encouraged to help with the conversion process for these libraries,
described at:
http://wiki.debian.org/Multiarch/Implementation
-- Steve Langasek "
So if you try to edit your source.list file to grab it from older repo you'll break packages. So ubuntu 12.10 people have to wait or adb is compile or whatever to 64 bit.
edit:
Debian 7.0 will support multiarch where x64 version can run x32 binary.
source: http://www.debian.org/News/2013/20130504
I use debian_x64
add i386 lib
dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install libc6:i386 libncurses5:i386 libstdc++6:i386
ldd /home/yourname/adt-bundle-linux-x86_64-20130729/sdk/platform-tools/adb
when you found “android-sdks/build-tools/17.0.0/aapt: error while loading shared libraries: libz.so.1: cannot open shared object file: No such file or directory”
you can try
sudo apt-get install ia32-libs
sudou apt-get install zlib.i686
restart your computer
and try again
unzip that file with this:
sudo tar xvfz adt-bundle-linux-x86.zip -C /opt/android
than run that code:
sudo chown -R your_user_name /opt/android
i think it will work
I'm using Python 2.7.2 on Ubuntu 11.10. I got this error when importing the bz2 module:
ImportError: No module named bz2
I thought the bz2 module is supposed to come with Python 2.7. How can I fix this problem?
EDIT: I think I previously installed Python 2.7.2 by compiling from source. Probably at that point I didn't have libbz2-dev and so the bz2 module is not installed. Now, I'm hoping to install Python2.7 through
sudo apt-get install python2.7
But it will say it's already installed. Is there a way to uninstall the previous Python2.7 installation and reinstall?
I meet the same problem, here's my solution.
The reason of import error is while you are building python, system couldn't find the bz2 headers and skipped building bz2 module.
Install them on Ubuntu/Debian:
sudo apt-get install libbz2-dev
Fedora:
sudo yum install bzip2-devel
and then rebuild python
comes from another answer
#birryree's answer helps to back to the system's original python.
Okay, this is much easier to understand in answer form, so I'll move what I would write in my comment to this answer.
Luckily for you, you didn't overwrite the system version of python, as Ubuntu 11.10 comes with 2.7.2 preinstalled.
Your python binaries (python and python2.7) are located in /usr/local/bin, which is a directory where user-specific stuff is usually installed. This is fine, it means your system python is still there.
First, just try to run the system python. Type this from the command line:
/usr/bin/python -c "import bz2; print bz2.__doc__"
This should print out something like this:
λ > /usr/bin/python -c "import bz2; print bz2.__doc__"
The python bz2 module provides a comprehensive interface for
the bz2 compression library. It implements a complete file
interface, one shot (de)compression functions, and types for
sequential (de)compression.
If so, means you're fine.
So you just have to fix your PATH, which tells the shell where to find commands. /usr/local/bin is going to have priority over /usr/local, so there are some ways to fix this, in order of difficulty/annoyance/altering your system:
Remove the symlink python from /usr/local/bin
This will make it so that when you type python, it should go back to executing /usr/bin/python, which is an alias for the system's python 2.7.2.
sudo rm /usr/local/bin/python
Move /usr/bin to have higher precedence in the PATH
Might not be desirable if you already have stuff in /usr/local/bin that should have precedence over /usr/bin, but I'm adding this for completeness.
In your shell profile (not sure what Ubuntu's default is, but I'm using ~/.bash_profile, you can do this:
export PATH=/usr/bin:$PATH
Remove your python install
This is extreme and the first option I presented should be your first option.
Do you really need your own version of Python? If you want isolated python environments you probably really want virtualenv. You can probably remove yours unless there's a reason not to.
It's going to be a little annoying though, but basically:
Remove the python and python2.7 and pythonw and pythonw2.7 commands from /usr/local/bin.
Remove /usr/local/lib/python/2.7.2
This part is not complete because I forget what else there is.
In case, you must be used python2.7, you should run: (Centos 6.4)
sudo cp /usr/lib64/python2.6/lib-dynload/bz2.so /usr/local/lib/python2.7/
Maybe it will helps someone:
apt-get install libbz2-dev # for bz2
apt-get install libssl-dev # for _ssl
apt-get install libsqlite3-dev # for sqlite
apt-get install libreadline6-dev # for readline, _curses, _curses_panel
For Ubuntu/Debian:
sudo apt-get install libbz2-dev
For Fedora:
sudo yum install bzip2-devel
And then recompile the python and install it.
matocnhoi's answer works for me in centOS
sudo cp /usr/lib64/python2.6/lib-dynload/bz2.so /usr/local/lib/python2.7/
and I used virtualenv, so the command is
sudo cp /usr/lib64/python2.6/lib-dynload/bz2.so ../../../env/lib/python2.7/
I used a symlink between /usr/lib64/python2.6/lib-dynload/bz2.so /usr/local/lib/python2.7/lib-dynload/
Worked fine for me...
Make sure you bz2 installed, run sudo yum install bzip2-devel.
Centos 6
sudo cp /usr/lib64/python2.6/lib-dynload/bz2.so /python_install_path/lib/python2.7
Centos 7
sudo cp /usr/lib64/python2.7/lib-dynload/bz2.so /python_install_path/lib/python2.7
python_install_path usually is /usr/local/lib/python2.7/, you need replace that if you install python in a another path.
If your bz2 in /usr/lib64/python2.7/lib-dynload/ is named as: "bz2.x86_64-linux-gnu.so", remember to rename it to bz2.so when copying it to your path or it may not be correctly sourced:
cp /usr/lib64/python2.6/lib-dynload/bz2.x86_64-linux-gnu.so /python_install_path/lib/python2.7/bz2.so
I had the same problem with Python 2.17.15 and pyenv on Ubuntu. System python from /usr/bin/python worked fine. In my case it helped to install libbz2-dev and then to reinstall python 2.7.15:
sudo apt-get install libbz2-dev
pyenv uninstall 2.7.15
pyenv install 2.7.15