python-for-android Python3/Android-28/NDK-r17c build recipe

2,172 views
Skip to first unread message

Robert Flatt

unread,
Nov 28, 2018, 6:08:26 PM11/28/18
to Kivy users support
Similar to the Crystax recipe I posted a couple of days ago, but r17c approach is SIMPLER and perhaps more future proof.

# Recipe for building a python3 app (written using Kivy) for Android-28/NDK-17c.
# ASSUMES Ubantu 18.04 CLEAN INSTALL
# Tested with Windows Subystem for Linux Ubantu 18.04 and Android Pie
#

sudo apt
-get update
sudo apt
-get upgrade

### Install Apt dependencies

sudo apt
-get install -y openjdk-8-jdk zip unzip virtualenv python3-pip  

### Install Python dependencies

sudo
-H pip3 install cython git+https://github.com/kivy/python-for-android.git

### Download Android Tools (ndk and sdk) , copy to <WHERE_EVER>
# https://developer.android.com/ndk/downloads/older_releases
#                        android-ndk-r17c-linux-x86_64.zip
# https://developer.android.com/studio/
#                        sdk-tools-linux-4333796.zip

### Install Android Tools
cd    
<WHERE_EVER>
unzip
-q -d sdk  sdk-tools-linux-4333796.zip
unzip
-q android-ndk-r17c-linux-x86_64.zip

### Build Android Tools
cd
<WHERE_EVER>/sdk/tools/bin
./sdkmanager "platforms;android-28"
./sdkmanager "build-tools;28.0.3"

### Install p4a Done

### Build App Configuration

cd
<location of app main.py>

# Create a ".p4a" containing (replace text between and including <>)
# An app may need more options than these:
--dist_name=<XXX>
--private .
--package=com.<YYY>.<XYZ>
--name <ZZZ>
--bootstrap=sdl2
--requirements=python3,kivy
--arch=armeabi-v7a
--icon <ICON>.png
--sdk_dir <WHERE_EVER>/sdk
--ndk_dir <WHERE_EVER>/
android-ndk-r17c
--android_api 28
--ndk_version 17c
--ndk-api 21
--version <0.0.0>


# Build .apk
# the first time this will take a while, and it is verbose
# Some stuff fails and recovers, so relax

p4a apk

# Bump the "--version" for each app update


Be amazed by p4a, the developers are doing something wonderful.

Roger Morrell

unread,
Nov 30, 2018, 3:18:09 PM11/30/18
to Kivy users support
Did you need to increase the java heap size ?  I got failures while it was running gradle.  I tried putting -Xmx4g in the JAVA OPT in the gradle script and in gradle-wrapper.properties but none of these worked so I set it in the environment .  I did :
 export _JAVA_OPTIONS=-Xmx4g
  and 
export JAVA_OPTIONS=-Xmx4g

my understanding is that p4a runs a number of parallel tasks and it appeared that on of these was failing with a heap too small message.  It was not clear if the parallel tasks all inherited the -Xmx parameter but putting it in the environment variable assured that they did ?

It was not clear which would work
same on the heap I increased it to 4G, probably needed less
I'm running Xbuntu on a Oracle Virtual Box and a p4a run takes well over an hour 

As Robert commented -  I also did not get some of the strange inconsistencies that I did when trying to use buildozer

any comments, observations or suggestions welcome

Roger

Robert Flatt

unread,
Nov 30, 2018, 3:38:09 PM11/30/18
to Kivy users support
I did not have a problem with the Java heap for r17c  (Ubuntu 18)
I did have a problem with the Java heap for Crystax (Ubuntu 18)

The workaround there was a known issue:

### Workaround Issue #1327. Java heap issue - thanks JonasT
### Also add this line to .bashrc
export GRADLE_OPTS="-Xms1724m -Xmx5048m -Dorg.gradle.jvmargs='-Xms1724m -Xmx5048m'"

Perhaps something of this form will work for you?

The interesting thing about the 'python3' recipe is it downloads almost everything it needs into a virtual environment - which is why the user install is simple.
If one wants to see what it does, the the files are in /usr/local/lib/python3.6/dist-packages/pythonforandroid (your python may be different from 3.6)

J34n

unread,
Dec 1, 2018, 11:35:05 AM12/1/18
to Kivy users support
Thanks a lot for your guide! I just tried it, and everything works perfectly. You’re gonna save me so much time!

Roger Morrell

unread,
Dec 2, 2018, 6:06:16 PM12/2/18
to Kivy users support
I put in the GRADLE_OPTS
and it complied

Then I went to run it on a samsung table and it would not start - just said invalid format

I then looked at in android studio and it said it was missing the the SDK version - but could not see how to add it either through Studio or as input to p4a

I'm not sure what should be in an APK file but i unzipped it and 

found this 
-rw-rw-r-- 1 kivy kivy 8071004 Dec 31  1979 assets/private.mp3
-rw-rw-r-- 1 kivy kivy    1211 Dec 31  1979 META-INF/CERT.RSA
-rw-rw-r-- 1 kivy kivy    2127 Dec 31  1979 META-INF/CERT.SF
-rw-rw-r-- 1 kivy kivy    2065 Dec 31  1979 META-INF/MANIFEST.MF

lib/armeabi-v7a:
total 4680
-rw-rw-r-- 1 kivy kivy   18112 Dec 31  1979 libmain.so
-rw-rw-r-- 1 kivy kivy 2776024 Dec 31  1979 libpython3.7m.so
-rw-rw-r-- 1 kivy kivy  415396 Dec 31  1979 libSDL2_image.so
-rw-rw-r-- 1 kivy kivy  282740 Dec 31  1979 libSDL2_mixer.so
-rw-rw-r-- 1 kivy kivy  878352 Dec 31  1979 libSDL2.so
-rw-rw-r-- 1 kivy kivy  407204 Dec 31  1979 libSDL2_ttf.so

res/drawable:
total 16
-rw-rw-rw- 1 kivy kivy  3229 Dec 31  1979 icon.png
-rw-rw-rw- 1 kivy kivy 11584 Dec 31  1979 presplash.jpg

res/drawable-hdpi-v4:
total 4
-rw-rw-rw- 1 kivy kivy 2683 Dec 31  1979 ic_launcher.png

res/drawable-mdpi-v4:
total 4
-rw-rw-rw- 1 kivy kivy 1698 Dec 31  1979 ic_launcher.png

res/drawable-xhdpi-v4:
total 4
-rw-rw-rw- 1 kivy kivy 3872 Dec 31  1979 ic_launcher.png

res/drawable-xxhdpi-v4:
total 8
-rw-rw-rw- 1 kivy kivy 6874 Dec 31  1979 ic_launcher.png

res/layout:
total 16
-rw-rw-rw- 1 kivy kivy 1112 Dec 31  1979 chooser_item.xml
-rw-rw-rw- 1 kivy kivy  552 Dec 31  1979 main.xml
-rw-rw-rw- 1 kivy kivy  700 Dec 31  1979 project_chooser.xml
-rw-rw-rw- 1 kivy kivy  516 Dec 31  1979 project_empty.xml

This was trying to compile the scrollview example
I'm assuming that the enormous assets/private.mp3 the the 'compiled' scrollview app .... not a stream of hysterical laughter at what I'm doing 

I had in the current directory when running p4a
.p4a file like your example
main.py ... the scrollview.py renamed 
scrollview.kv


I'm assuming that in "knows" to include the .kv file as kivy is specified

did I do some obvious thing wrong?
what should I look at next?

On Thursday, November 29, 2018 at 12:08:26 PM UTC+13, Robert Flatt wrote:

Robert Flatt

unread,
Dec 2, 2018, 7:36:52 PM12/2/18
to Kivy users support
Sorry I don't know the answer. No hysterical laughter about your approach here, people in glass houses.....

I have seen install fails and the workaround is to uninstall the existing app version. Happens occasionally. Never seen a start failure; though my attempts at pyjnius sometimes give run time fails - but the cause of that problem is me.

I have noticed that p4a will suck in most things in the project directory, I once left a pdf in the project directory and it ended up inside my .apk . Lesson learned.

private.mp3 is a tarball containing all your data and the python distribution. If you want to go down that rabbit hole, I'd guess the .kv in in there:
tar xf private.mp3

For your reference I unziped an apk I wrote, the app has no .kv files .  This is the root and first level, perhaps you can use this as a sanity check:

-rwxrwxrwx 1 bobf bobf  3300 Dec 31  1979 AndroidManifest.xml
-rwxrwxrwx 1 bobf bobf 78172 Dec 31  1979 classes.dex
-rwxrwxrwx 1 bobf bobf  2360 Dec 31  1979 resources.arsc

META
-INF:
total
12
-rwxrwxrwx 1 bobf bobf 1165 Dec 31  1979 CERT.RSA
-rwxrwxrwx 1 bobf bobf 2127 Dec 31  1979 CERT.SF
-rwxrwxrwx 1 bobf bobf 2065 Dec 31  1979 MANIFEST.MF

assets
:
total
8020
-rwxrwxrwx 1 bobf bobf 8211856 Dec 31  1979 private.mp3

lib
:
total
0
drwxrwxrwx
1 bobf bobf 512 Dec  2 14:07 armeabi-v7a

res
:
total
0
drwxrwxrwx
1 bobf bobf 512 Dec  2 14:07 drawable
drwxrwxrwx
1 bobf bobf 512 Dec  2 14:07 drawable-hdpi-v4
drwxrwxrwx
1 bobf bobf 512 Dec  2 14:07 drawable-mdpi-v4
drwxrwxrwx
1 bobf bobf 512 Dec  2 14:07 drawable-xhdpi-v4
drwxrwxrwx
1 bobf bobf 512 Dec  2 14:07 drawable-xxhdpi-v4
drwxrwxrwx
1 bobf bobf 512 Dec  2 14:07 layout

Roger Morrell

unread,
Dec 3, 2018, 8:03:36 PM12/3/18
to Kivy users support
The good news and getting there

I replaced the older Samsung tablet running Android 4.? that would not let me connect adb to it with a newer  Lenovo tab 4 running android 7.1 that lets you connect to it with adb ... and the simple test app works. This included loading the .kv  file

my app still fails , I realized that I do a few things in the linux and windows versions that I did not figure how they work on Android or adapt them- for example I read the .kivy/config.ini and myapp.ini file  and I'm stiil not 100% certain when I need recipes for example iI use the python JSON capability.

thanks for the input

Roger


On Thursday, November 29, 2018 at 12:08:26 PM UTC+13, Robert Flatt wrote:

Robert Flatt

unread,
Dec 6, 2018, 8:28:21 PM12/6/18
to Kivy users support

Specifying the the app uses the "android" package results in a p4a crash. Has been posted as p4a issue #1504

--requirements=python3,kivy,android

Crashes at:

File "/usr/local/lib/python3.6/dist-packages/pythonforandroid/recipes/android/__init__.py", line 33, in prebuild_arch
      bootstrap
= bootstrap_name = self.ctx.bootstrap.name.decode('utf-8')
 
AttributeError: 'str' object has no attribute 'decode'
 


The workaround is to edit (you need sudo, and your python version may be different):

/usr/local/lib/python3.6/dist-packages/pythonforandroid/recipes/android/__init__.py

Remove that utf-8 decoding on line 33:
 

      #bootstrap = bootstrap_name = self.ctx.bootstrap.name.decode('utf-8')
      bootstrap
= bootstrap_name = self.ctx.bootstrap.name
 


Robert Flatt

unread,
Dec 16, 2018, 5:57:07 PM12/16/18
to Kivy users support
"--android" issue is fixed

Reinstall p4a to get the fix

sudo pip3 uninstall python-for-android
sudo
-H pip3 install git+https://github.com/kivy/python-for-android.git

Unrelated:

A gradle update can lead to a message of the form ".APK not found"
Fix is " build completely fresh, removing your old distribution"

p4a clean_all

Message has been deleted

Markus Kaukonen

unread,
Jan 31, 2019, 4:01:28 AM1/31/19
to Kivy users support
Hello, (I FAILED, SEE BELOW)

I have ubuntu 18.04.1 (and MSI laptop).

I had to use (in .bashrc)
export JAVA_OPTS='-XX:+IgnoreUnrecognizedVMOptions --add-modules java.se.ee'
to get rid of java-error in
./sdkmanager "platforms;android-28"

( I installed p4a in conda by
conda create -n kivy python=3.6
conda activate kivy
pip install python-for-android)


Missing things for p4a
sudo apt-get install autoconf

Thereafter p4a gives me:
~/Kivy/Apps/HelloWorld$ p4a apk

[INFO]:    No dist exists that meets your requirements, so one will be built.
[ERROR]:   Didn't find any valid dependency graphs.
[ERROR]:   This means that some of your requirements pull in conflicting dependencies.
[ERROR]:   Exiting.

I stop wasting my time at this point.

terveisin, Markus


Robert Flatt

unread,
Jan 31, 2019, 7:02:01 PM1/31/19
to Kivy users support
Not a failure, just a step in the learning curve. And, yes, that curve may be longer that you want to consider.

1) p4a is a large set of tools that have to play together. So the operating environment is the critical
lowest common denominator. These instructions, Buildozer, and the Complete VM all try to address this.

2) Best strategy for these instructions is follow them fully and exactly, no omissions, no substitutions
with things that 'should' be the same, no additions, and no workarounds.
To do this I install Ubuntu in Windows10 (from the Windows Store) and only use that shell only for p4a.
You do what you gotta do. And there are no guarantees.

3) From the log snippet in the post it is hard to guess the cause of the issue.
Is the .p4a identical to the instructions (with <..> replaced) ?
I'd also wonder about that Java workaround. If you have Java 11 installed as well, that workaround is
probably not going to be sufficient (uninstall Java 11).

4) Be aware the learning curve is longer than you know. HelloWorld on Android is just the first step.
Python is designed for POSIX machines (PC,Mac,Linux..), and (mostly) ports between these easily.
Android and IOS are not POSIX machines.
That Python can work on Android/IOS is an amazing feat of engineering, really, praise those guys.
That Python will work usually requires modifying the application. Expect to be surprised.
Enjoy the learning curve....  (or not!)

5) This stuff does work, and people do find it helpful, this was posted today:

J34n

unread,
Feb 3, 2019, 2:02:20 PM2/3/19
to Kivy users support
Hello,

I got an exception when trying to build my app with “python-dateutil” as a requirement.

Before that the build had no problem.

The error is:

[INFO]:    The requirements (python, python-dateutil) don't have recipes, attempting to install them with pip
[INFO]:    If this fails, it may mean that the module has compiled components and needs a recipe.
[INFO]:    -> directory context /home/j34n/.local/share/python-for-android/build
[INFO]:    -> running virtualenv --python=python2 venv
           working: The path python2 (from --python=python2) does not exist                                                                                                                                       Exception in thread background thread for pid 10008:
Traceback (most recent call last):
  File "/usr/lib/python3.6/threading.py", line 916, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.6/threading.py", line 864, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/local/lib/python3.6/dist-packages/sh.py", line 1540, in wrap
    fn(*args, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/sh.py", line 2459, in background_thread
    handle_exit_code(exit_code)
  File "/usr/local/lib/python3.6/dist-packages/sh.py", line 2157, in fn
    return self.command.handle_command_exit_code(exit_code)
  File "/usr/local/lib/python3.6/dist-packages/sh.py", line 815, in handle_command_exit_code
    raise exc
sh.ErrorReturnCode_3:

  RAN: /usr/bin/virtualenv --python=python2 venv

  STDOUT:
The path python2 (from --python=python2) does not exist


  STDERR:


Traceback (most recent call last):
  File "/usr/local/bin/p4a", line 11, in <module>
    load_entry_point('python-for-android==0.7.1', 'console_scripts', 'p4a')()
  File "/usr/local/lib/python3.6/dist-packages/pythonforandroid/toolchain.py", line 1051, in main
    ToolchainCL()
  File "/usr/local/lib/python3.6/dist-packages/pythonforandroid/toolchain.py", line 560, in __init__
    getattr(self, args.subparser_name.replace('-', '_'))(args)
  File "/usr/local/lib/python3.6/dist-packages/pythonforandroid/toolchain.py", line 151, in wrapper_func
    build_dist_from_args(ctx, dist, args)
  File "/usr/local/lib/python3.6/dist-packages/pythonforandroid/toolchain.py", line 192, in build_dist_from_args
    build_recipes(build_order, python_modules, ctx)
  File "/usr/local/lib/python3.6/dist-packages/pythonforandroid/build.py", line 585, in build_recipes
    run_pymodules_install(ctx, python_modules)
  File "/usr/local/lib/python3.6/dist-packages/pythonforandroid/build.py", line 609, in run_pymodules_install
    'venv'
  File "/usr/local/lib/python3.6/dist-packages/pythonforandroid/logger.py", line 178, in shprint
    for line in output:
  File "/usr/local/lib/python3.6/dist-packages/sh.py", line 863, in next
    self.wait()
  File "/usr/local/lib/python3.6/dist-packages/sh.py", line 792, in wait
    self.handle_command_exit_code(exit_code)
  File "/usr/local/lib/python3.6/dist-packages/sh.py", line 815, in handle_command_exit_code
    raise exc
sh.ErrorReturnCode_3:

  RAN: /usr/bin/virtualenv --python=python2 venv

  STDOUT:
The path python2 (from --python=python2) does not exist


  STDERR:

I can’t figure out what is wrong. If somebody knows what the problem is, I would be grateful.

Le jeudi 29 novembre 2018 00:08:26 UTC+1, Robert Flatt a écrit :

Robert Flatt

unread,
Feb 3, 2019, 7:53:23 PM2/3/19
to Kivy users support
>>The requirements (python, python-dateutil) don't have recipes, attempting to install them with pip

Perhaps the requirement "python" becomes a problem when "python-dateutil" creates some pip activity?
should be "python2" or "python3" as documented:

Just guessing that an existing configuration problem did not become visible till the new behavior was added.

[and python2 is a little off topic for this thread, in the future for better responses consider creating a new thread]

Jean-Baptiste Landy

unread,
Feb 4, 2019, 3:41:50 PM2/4/19
to kivy-...@googlegroups.com
… That was it…

I used to put python3 as a requirement. I don’t know when nor why I switched to python.

Thanks a lot for your help, and sorry for the trouble. I’ll try to be more careful next time.

--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To post to this group, send email to kivy-...@googlegroups.com.
Visit this group at https://groups.google.com/group/kivy-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/dd30868e-bd03-4145-8f63-a1df79fb5047%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

br...@brianarbuckle.com

unread,
Apr 1, 2019, 4:40:02 PM4/1/19
to Kivy users support
I wanted to mention to anyone trying this route, which I am in the middle of doing, the ndk and sdk files have moved - I have placed the new locations below:

### Download Android Tools (ndk and sdk) , copy to <WHERE_EVER>

br...@brianarbuckle.com

unread,
Apr 3, 2019, 2:55:00 PM4/3/19
to Kivy users support
Hello, any help would be appreciated.   I have provisioned a ubuntu 18.04 LTS server, based on the instructions here.  Had an embarrassing issue, (left a "<" inside the .p4a file).  After I fixed it, the p4a apk build worked on a simple script. Now that I am trying to compile, my main script, which works on a freelancers older system, I have some more error:

I think it is related to libffi, I read this in one of the other threads in this group: "In short, the solution is to install libffi-dev module to your system. Do: sudo apt-get install libffi-dev . Then, rebuild.""  I checked and see if the libffi-dev is in the system, which it is:

apt-cache search libffi

libffi-dev - Foreign Function Interface library (development files)
libffi6 - Foreign Function Interface library runtime
libffi6-dbg - Foreign Function Interface library runtime (debug symbols)
libalt-alien-ffi-system-perl - simplified alternative to Alien::FFI that uses system libffi
libffi-checklib-perl - module to check availability of a library for FFI
libffi-platypus-perl - module to create Perl bindings to non-Perl libraries with FFI
libffindex0 - library for simple index/database for huge amounts of small files
libffindex0-dev - library for simple index/database for huge amounts of small files (development)
libjffi-java - Java Foreign Function Interface
libjffi-jni - Java Foreign Function Interface (JNI library)

"I assume you have the latest dev version of buildozer installed and that kivy==master in your requirements. Make sure that p4a.branch = master !""

using p4a, not buildozer, though I have changed the .p4a requirements to include kivy==master, and the fail is the same.


Thanks!
 
root@localhost:/home/trivia_game/trivia_app_v5# p4a apk
[INFO]:    Reading .p4a configuration
[INFO]:    Recipe kivy: version "master" requested
[WARNING]: --ndk-version is deprecated and no longer necessary, the value you passed is ignored
[INFO]:    Will compile for the following archs: armeabi-v7a
[INFO]:    Getting Android API version from user argument: 28
[INFO]:    Available Android APIs are (28)
[INFO]:    Requested API target 28 is available, continuing.
[INFO]:    Getting NDK dir from from user argument
[INFO]:    Found NDK revision 17.2.4988734
[INFO]:    Getting NDK API version (i.e. minimum supported API) from user argument
[INFO]:    Found virtualenv at /usr/bin/virtualenv
[INFO]:    ccache is missing, the build will not be optimized in the future.
[INFO]:    Found the following toolchain versions: ['4.9']
[INFO]:    Picking the latest gcc toolchain, here 4.9
[WARNING]: Missing executable: pkg-config is not installed
[INFO]:    No existing dists meet the given requirements!
[INFO]:    No dist exists that meets your requirements, so one will be built.
[INFO]:    Found a single valid recipe set: ['constantly', 'hostpython3', 'incremental', 'libffi', 'openssl', 'sdl2_image', 'sdl2_mixer', 'sdl2_ttf', 'sqlite3', 'python3', 'sdl2', 'setuptools', 'six', 'pyjnius', 'zope_interface', 'android', 'kivy', 'twisted']
[INFO]:    The selected bootstrap is sdl2
[INFO]:    # Creating dist with sdl2 bootstrap
[INFO]:    Dist will have name TriviaTV and requirements (python3, kivy, sqlite3, twisted, libffi)
[INFO]:    Dist contains the following requirements as recipes: ['hostpython3', 'libffi', 'openssl', 'sdl2_image', 'sdl2_mixer', 'sdl2_ttf', 'sqlite3', 'python3', 'sdl2', 'setuptools', 'six', 'pyjnius', 'zope_interface', 'android', 'kivy', 'twisted']
[INFO]:    Dist will also contain modules (incremental, constantly) installed from pip
[INFO]:    -> directory context /root/.local/share/python-for-android/build/bootstrap_builds/sdl2-python3
[INFO]:    <- directory context /home/trivia_game/trivia_app_v5
[INFO]:    Recipe build order is ['hostpython3', 'libffi', 'openssl', 'sdl2_image', 'sdl2_mixer', 'sdl2_ttf', 'sqlite3', 'python3', 'sdl2', 'setuptools', 'six', 'pyjnius', 'zope_interface', 'android', 'kivy', 'twisted']
[INFO]:    The requirements (constantly, incremental) were not found as recipes, they will be installed with pip.
[INFO]:    # Downloading recipes 
[INFO]:    Downloading hostpython3
[INFO]:    -> running mkdir -p /root/.local/share/python-for-android/packages/hostpython3
[INFO]:    -> directory context /root/.local/share/python-for-android/packages/hostpython3
[INFO]:    hostpython3 download already cached, skipping                                                       
[INFO]:    <- directory context /home/trivia_game/trivia_app_v5
[INFO]:    Downloading libffi
[INFO]:    -> running mkdir -p /root/.local/share/python-for-android/packages/libffi
[INFO]:    -> directory context /root/.local/share/python-for-android/packages/libffi
[INFO]:    libffi download already cached, skipping                                                            
[INFO]:    <- directory context /home/trivia_game/trivia_app_v5
[INFO]:    Downloading openssl
[INFO]:    -> running mkdir -p /root/.local/share/python-for-android/packages/openssl
[INFO]:    -> directory context /root/.local/share/python-for-android/packages/openssl
[INFO]:    openssl download already cached, skipping                                                           
[INFO]:    <- directory context /home/trivia_game/trivia_app_v5
[INFO]:    Downloading sdl2_image
[INFO]:    -> running mkdir -p /root/.local/share/python-for-android/packages/sdl2_image
[INFO]:    -> directory context /root/.local/share/python-for-android/packages/sdl2_image
[INFO]:    -> running basename https://www.libsdl.org/projects/SDL_image/release/SDL...(and 20 more)
[INFO]:    sdl2_image download already cached, skipping                                                        
[INFO]:    <- directory context /home/trivia_game/trivia_app_v5
[INFO]:    Downloading sdl2_mixer
[INFO]:    -> running mkdir -p /root/.local/share/python-for-android/packages/sdl2_mixer
[INFO]:    -> directory context /root/.local/share/python-for-android/packages/sdl2_mixer
[INFO]:    -> running basename https://www.libsdl.org/projects/SDL_mixer/release/SDL...(and 20 more)
[INFO]:    sdl2_mixer download already cached, skipping                                                        
[INFO]:    <- directory context /home/trivia_game/trivia_app_v5
[INFO]:    Downloading sdl2_ttf
[INFO]:    -> running mkdir -p /root/.local/share/python-for-android/packages/sdl2_ttf
[INFO]:    -> directory context /root/.local/share/python-for-android/packages/sdl2_ttf
[INFO]:    sdl2_ttf download already cached, skipping                                                          
[INFO]:    <- directory context /home/trivia_game/trivia_app_v5
[INFO]:    Downloading sqlite3
[INFO]:    -> running mkdir -p /root/.local/share/python-for-android/packages/sqlite3
[INFO]:    -> directory context /root/.local/share/python-for-android/packages/sqlite3
[INFO]:    sqlite3 download already cached, skipping                                                           
[INFO]:    <- directory context /home/trivia_game/trivia_app_v5
[INFO]:    Downloading python3
[INFO]:    -> running mkdir -p /root/.local/share/python-for-android/packages/python3
[INFO]:    -> directory context /root/.local/share/python-for-android/packages/python3
[INFO]:    python3 download already cached, skipping                                                           
[INFO]:    <- directory context /home/trivia_game/trivia_app_v5
[INFO]:    Downloading sdl2
[INFO]:    -> running mkdir -p /root/.local/share/python-for-android/packages/sdl2
[INFO]:    -> directory context /root/.local/share/python-for-android/packages/sdl2
[INFO]:    -> running basename https://www.libsdl.org/release/SDL2-2.0.9.tar.gz
[INFO]:    sdl2 download already cached, skipping                                                              
[INFO]:    <- directory context /home/trivia_game/trivia_app_v5
[INFO]:    Downloading setuptools
[INFO]:    -> running mkdir -p /root/.local/share/python-for-android/packages/setuptools
[INFO]:    -> directory context /root/.local/share/python-for-android/packages/setuptools
[INFO]:    -> running basename https://pypi.python.org/packages/source/s/setuptools/...(and 21 more)
[INFO]:    setuptools download already cached, skipping                                                        
[INFO]:    <- directory context /home/trivia_game/trivia_app_v5
[INFO]:    Downloading six
[INFO]:    -> running mkdir -p /root/.local/share/python-for-android/packages/six
[INFO]:    -> directory context /root/.local/share/python-for-android/packages/six
[INFO]:    six download already cached, skipping                                                               
[INFO]:    <- directory context /home/trivia_game/trivia_app_v5
[INFO]:    Downloading pyjnius
[INFO]:    -> running mkdir -p /root/.local/share/python-for-android/packages/pyjnius
[INFO]:    -> directory context /root/.local/share/python-for-android/packages/pyjnius
[INFO]:    pyjnius download already cached, skipping                                                           
[INFO]:    <- directory context /home/trivia_game/trivia_app_v5
[INFO]:    Downloading zope_interface
[INFO]:    -> running mkdir -p /root/.local/share/python-for-android/packages/zope_interface
[INFO]:    -> directory context /root/.local/share/python-for-android/packages/zope_interface
[INFO]:    -> running basename https://pypi.python.org/packages/source/z/zope.interf...(and 31 more)
[INFO]:    zope_interface download already cached, skipping                                                    
[INFO]:    <- directory context /home/trivia_game/trivia_app_v5
[INFO]:    Downloading android
[INFO]:    Skipping android download as no URL is set
[INFO]:    Downloading kivy
[INFO]:    -> running mkdir -p /root/.local/share/python-for-android/packages/kivy
[INFO]:    -> directory context /root/.local/share/python-for-android/packages/kivy
[INFO]:    -> running basename https://github.com/kivy/kivy/archive/master.zip
[INFO]:    kivy download already cached, skipping                                                              
[INFO]:    <- directory context /home/trivia_game/trivia_app_v5
[INFO]:    Downloading twisted
[INFO]:    -> running mkdir -p /root/.local/share/python-for-android/packages/twisted
[INFO]:    -> directory context /root/.local/share/python-for-android/packages/twisted
[INFO]:    twisted download already cached, skipping                                                           
[INFO]:    <- directory context /home/trivia_game/trivia_app_v5
[INFO]:    # Building all recipes for arch armeabi-v7a
[INFO]:    # Unpacking recipes
[INFO]:    Unpacking hostpython3 for armeabi-v7a
[INFO]:    -> directory context /root/.local/share/python-for-android/build/other_builds/hostpython3/desktop   
[INFO]:    hostpython3 is already unpacked, skipping
[INFO]:    <- directory context /home/trivia_game/trivia_app_v5
[INFO]:    Unpacking libffi for armeabi-v7a
[INFO]:    -> directory context /root/.local/share/python-for-android/build/other_builds/libffi/armeabi-v7a__ndk_target_21
[INFO]:    libffi is already unpacked, skipping
[INFO]:    <- directory context /home/trivia_game/trivia_app_v5
[INFO]:    Unpacking openssl for armeabi-v7a
[INFO]:    -> directory context /root/.local/share/python-for-android/build/other_builds/openssl/armeabi-v7a__ndk_target_21
[INFO]:    openssl is already unpacked, skipping
[INFO]:    <- directory context /home/trivia_game/trivia_app_v5
[INFO]:    Unpacking sdl2_image for armeabi-v7a
[INFO]:    -> running basename https://www.libsdl.org/projects/SDL_image/release/SDL...(and 20 more)
[INFO]:    -> directory context /root/.local/share/python-for-android/build/bootstrap_builds/sdl2-python3/jni  
[INFO]:    sdl2_image is already unpacked, skipping
[INFO]:    <- directory context /home/trivia_game/trivia_app_v5
[INFO]:    Unpacking sdl2_mixer for armeabi-v7a
[INFO]:    -> running basename https://www.libsdl.org/projects/SDL_mixer/release/SDL...(and 20 more)
[INFO]:    -> directory context /root/.local/share/python-for-android/build/bootstrap_builds/sdl2-python3/jni  
[INFO]:    sdl2_mixer is already unpacked, skipping
[INFO]:    <- directory context /home/trivia_game/trivia_app_v5
[INFO]:    Unpacking sdl2_ttf for armeabi-v7a
[INFO]:    -> directory context /root/.local/share/python-for-android/build/bootstrap_builds/sdl2-python3/jni  
[INFO]:    sdl2_ttf is already unpacked, skipping
[INFO]:    <- directory context /home/trivia_game/trivia_app_v5
[INFO]:    Unpacking sqlite3 for armeabi-v7a
[INFO]:    -> directory context /root/.local/share/python-for-android/build/other_builds/sqlite3/armeabi-v7a__ndk_target_21
[INFO]:    sqlite3 is already unpacked, skipping
[INFO]:    <- directory context /home/trivia_game/trivia_app_v5
[INFO]:    Unpacking python3 for armeabi-v7a
[INFO]:    -> directory context /root/.local/share/python-for-android/build/other_builds/python3-libffi-openssl-sqlite3/armeabi-v7a__ndk_target_21
[INFO]:    python3 is already unpacked, skipping
[INFO]:    <- directory context /home/trivia_game/trivia_app_v5
[INFO]:    Unpacking sdl2 for armeabi-v7a
[INFO]:    -> running basename https://www.libsdl.org/release/SDL2-2.0.9.tar.gz
[INFO]:    -> directory context /root/.local/share/python-for-android/build/bootstrap_builds/sdl2-python3/jni  
[INFO]:    sdl2 is already unpacked, skipping
[INFO]:    <- directory context /home/trivia_game/trivia_app_v5
[INFO]:    Unpacking setuptools for armeabi-v7a
[INFO]:    -> running basename https://pypi.python.org/packages/source/s/setuptools/...(and 21 more)
[INFO]:    -> directory context /root/.local/share/python-for-android/build/other_builds/setuptools-python3/armeabi-v7a__ndk_target_21
[INFO]:    setuptools is already unpacked, skipping
[INFO]:    <- directory context /home/trivia_game/trivia_app_v5
[INFO]:    Unpacking six for armeabi-v7a
[INFO]:    -> directory context /root/.local/share/python-for-android/build/other_builds/six-python3/armeabi-v7a__ndk_target_21
[INFO]:    six is already unpacked, skipping
[INFO]:    <- directory context /home/trivia_game/trivia_app_v5
[INFO]:    Unpacking pyjnius for armeabi-v7a
[INFO]:    -> directory context /root/.local/share/python-for-android/build/other_builds/pyjnius-python3-sdl2/armeabi-v7a__ndk_target_21
[INFO]:    pyjnius is already unpacked, skipping
[INFO]:    <- directory context /home/trivia_game/trivia_app_v5
[INFO]:    Unpacking zope_interface for armeabi-v7a
[INFO]:    -> running basename https://pypi.python.org/packages/source/z/zope.interf...(and 31 more)
[INFO]:    -> directory context /root/.local/share/python-for-android/build/other_builds/zope_interface-python3/armeabi-v7a__ndk_target_21
[INFO]:    zope_interface is already unpacked, skipping
[INFO]:    <- directory context /home/trivia_game/trivia_app_v5
[INFO]:    -> running rm -rf /root/.local/share/python-for-android/build/other_build...(and 57 more)
[INFO]:    -> running cp -a /usr/local/lib/python3.6/dist-packages/pythonforandroid/...(and 132 more)
[INFO]:    Unpacking kivy for armeabi-v7a
[INFO]:    -> running basename https://github.com/kivy/kivy/archive/master.zip
[INFO]:    -> directory context /root/.local/share/python-for-android/build/other_builds/kivy-python3-sdl2/armeabi-v7a__ndk_target_21
[INFO]:    kivy is already unpacked, skipping
[INFO]:    <- directory context /home/trivia_game/trivia_app_v5
[INFO]:    Unpacking twisted for armeabi-v7a
[INFO]:    -> directory context /root/.local/share/python-for-android/build/other_builds/twisted-python3/armeabi-v7a__ndk_target_21
[INFO]:    twisted is already unpacked, skipping
[INFO]:    <- directory context /home/trivia_game/trivia_app_v5
[INFO]:    # Prebuilding recipes
[INFO]:    Prebuilding hostpython3 for armeabi-v7a
[INFO]:    hostpython3 has no prebuild_armeabi_v7a, skipping
[INFO]:    Prebuilding libffi for armeabi-v7a
[INFO]:    libffi has no prebuild_armeabi_v7a, skipping
[INFO]:    Applying patches for libffi[armeabi-v7a]
[INFO]:    libffi already patched, skipping
[INFO]:    Prebuilding openssl for armeabi-v7a
[INFO]:    openssl has no prebuild_armeabi_v7a, skipping
[INFO]:    Prebuilding sdl2_image for armeabi-v7a
[INFO]:    sdl2_image has no prebuild_armeabi_v7a, skipping
[INFO]:    Applying patches for sdl2_image[armeabi-v7a]
[INFO]:    sdl2_image already patched, skipping
[INFO]:    Prebuilding sdl2_mixer for armeabi-v7a
[INFO]:    sdl2_mixer has no prebuild_armeabi_v7a, skipping
[INFO]:    Applying patches for sdl2_mixer[armeabi-v7a]
[INFO]:    sdl2_mixer already patched, skipping
[INFO]:    Prebuilding sdl2_ttf for armeabi-v7a
[INFO]:    sdl2_ttf has no prebuild_armeabi_v7a, skipping
[INFO]:    Prebuilding sqlite3 for armeabi-v7a
[INFO]:    sqlite3 has no prebuild_armeabi_v7a, skipping
[INFO]:    Prebuilding python3 for armeabi-v7a
[INFO]:    python3 has no prebuild_armeabi_v7a, skipping
[INFO]:    Applying patches for python3[armeabi-v7a]
[INFO]:    python3 already patched, skipping
[INFO]:    Prebuilding sdl2 for armeabi-v7a
[INFO]:    sdl2 has no prebuild_armeabi_v7a, skipping
[INFO]:    Prebuilding setuptools for armeabi-v7a
[INFO]:    setuptools has no prebuild_armeabi_v7a, skipping
[INFO]:    Prebuilding six for armeabi-v7a
[INFO]:    six has no prebuild_armeabi_v7a, skipping
[INFO]:    Prebuilding pyjnius for armeabi-v7a
[INFO]:    pyjnius has no prebuild_armeabi_v7a, skipping
[INFO]:    Applying patches for pyjnius[armeabi-v7a]
[INFO]:    pyjnius already patched, skipping
[INFO]:    Prebuilding zope_interface for armeabi-v7a
[INFO]:    zope_interface has no prebuild_armeabi_v7a, skipping
[INFO]:    -> directory context /root/.local/share/python-for-android/build/other_builds/zope_interface-python3/armeabi-v7a__ndk_target_21/zope_interface
[INFO]:    <- directory context /home/trivia_game/trivia_app_v5
[INFO]:    Applying patches for zope_interface[armeabi-v7a]
[INFO]:    zope_interface already patched, skipping
[INFO]:    Prebuilding android for armeabi-v7a
[INFO]:    android has no prebuild_armeabi_v7a, skipping
[INFO]:    -> directory context /root/.local/share/python-for-android/build/other_builds/android-python3-sdl2/armeabi-v7a__ndk_target_21/android
[INFO]:    <- directory context /home/trivia_game/trivia_app_v5
[INFO]:    Prebuilding kivy for armeabi-v7a
[INFO]:    kivy has no prebuild_armeabi_v7a, skipping
[INFO]:    Prebuilding twisted for armeabi-v7a
[INFO]:    twisted has no prebuild_armeabi_v7a, skipping
Should remove twisted tests etc. here, but skipping for now
[INFO]:    Applying patches for twisted[armeabi-v7a]
[INFO]:    twisted already patched, skipping
[INFO]:    # Building recipes
[INFO]:    Building hostpython3 for armeabi-v7a
[INFO]:    Skipping hostpython3 (3.7.1) build, as it has already been completed
[INFO]:    Building libffi for armeabi-v7a
[INFO]:    libffi said it is already built, skipping
[INFO]:    Building openssl for armeabi-v7a
[INFO]:    openssl said it is already built, skipping
[INFO]:    Building sdl2_image for armeabi-v7a
[INFO]:    Building sdl2_mixer for armeabi-v7a
[INFO]:    Building sdl2_ttf for armeabi-v7a
[INFO]:    Building sqlite3 for armeabi-v7a
[INFO]:    sqlite3 said it is already built, skipping
[INFO]:    Building python3 for armeabi-v7a
[INFO]:    -> directory context /root/.local/share/python-for-android/build/other_builds/python3-libffi-openssl-sqlite3/armeabi-v7a__ndk_target_21/python3/android-build
[WARNING]: Doing some hacky stuff to link properly
[INFO]:    -> running cp /home/project/android-ndk-r17c/platforms/android-21/arch-ar...(and 26 more)
[INFO]:    -> running cp /home/project/android-ndk-r17c/platforms/android-21/arch-ar...(and 24 more)
[WARNING]: lld not found, linking without it. Consider installing lld if linker errors occur.
[INFO]:    Activating flags for sqlite3
[INFO]:    Activating flags for libffi
[INFO]:    Activating flags for openssl
[INFO]:    <- directory context /home/trivia_game/trivia_app_v5
[INFO]:    Building sdl2 for armeabi-v7a
[INFO]:    -> directory context /root/.local/share/python-for-android/build/bootstrap_builds/sdl2-python3/jni
[INFO]:    -> running ndk-build V=1
[INFO]:    <- directory context /home/trivia_game/trivia_app_v5                                                
[INFO]:    Building setuptools for armeabi-v7a
[INFO]:    setuptools apparently isn't already in site-packages
[INFO]:    Installing setuptools into site-packages
[INFO]:    -> directory context /root/.local/share/python-for-android/build/other_builds/setuptools-python3/armeabi-v7a__ndk_target_21/setuptools
[INFO]:    -> running python setup.py install -O2 --root=/root/.local/share/python-f...(and 57 more)
           working: ModuleNotFoundError: No module named '_ctypes'                                             Exception in thread background thread for pid 19929:
Traceback (most recent call last):
  File "/usr/lib/python3.6/threading.py", line 916, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.6/threading.py", line 864, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/local/lib/python3.6/dist-packages/sh.py", line 1540, in wrap
    fn(*args, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/sh.py", line 2459, in background_thread
    handle_exit_code(exit_code)
  File "/usr/local/lib/python3.6/dist-packages/sh.py", line 2157, in fn
    return self.command.handle_command_exit_code(exit_code)
  File "/usr/local/lib/python3.6/dist-packages/sh.py", line 815, in handle_command_exit_code
    raise exc
sh.ErrorReturnCode_1: 

  RAN: /root/.local/share/python-for-android/build/other_builds/hostpython3/desktop/hostpython3/native-build/python setup.py install -O2 --root=/root/.local/share/python-for-android/build/python-installs/TriviaTV --install-lib=.

  STDOUT:
Traceback (most recent call last):
  File "setup.py", line 11, in <module>
    import setuptools
  File "/root/.local/share/python-for-android/build/other_builds/setuptools-python3/armeabi-v7a__ndk_target_21/setuptools/setuptools/__init__.py", line 14, in <module>
    from setuptools.dist import Distribution, Feature
  File "/root/.local/share/python-for-android/build/other_builds/setuptools-python3/armeabi-v7a__ndk_target_21/setuptools/setuptools/dist.py", line 25, in <module>
    from setuptools import windows_support
  File "/root/.local/share/python-for-android/build/other_builds/setuptools-python3/armeabi-v7a__ndk_target_21/setuptools/setuptools/windows_support.py", line 2, in <module>
    import ctypes
  File "/root/.local/share/python-for-android/build/other_builds/hostpython3/desktop/hostpython3/Lib/ctypes/__init__.py", line 7, in <module>
    from _ctypes import Union, Structure, Array
ModuleNotFoundError: No module named '_ctypes'


  STDERR:


Traceback (most recent call last):                                                                             
  File "/usr/local/bin/p4a", line 11, in <module>
    load_entry_point('python-for-android==0.7.1', 'console_scripts', 'p4a')()
  File "/usr/local/lib/python3.6/dist-packages/pythonforandroid/toolchain.py", line 1075, in main
    ToolchainCL()
  File "/usr/local/lib/python3.6/dist-packages/pythonforandroid/toolchain.py", line 577, in __init__
    getattr(self, args.subparser_name.replace('-', '_'))(args)
  File "/usr/local/lib/python3.6/dist-packages/pythonforandroid/toolchain.py", line 151, in wrapper_func
    build_dist_from_args(ctx, dist, args)
  File "/usr/local/lib/python3.6/dist-packages/pythonforandroid/toolchain.py", line 200, in build_dist_from_args
    build_recipes(build_order, python_modules, ctx)
  File "/usr/local/lib/python3.6/dist-packages/pythonforandroid/build.py", line 562, in build_recipes
    recipe.build_arch(arch)
  File "/usr/local/lib/python3.6/dist-packages/pythonforandroid/recipe.py", line 834, in build_arch
    self.install_python_package(arch)
  File "/usr/local/lib/python3.6/dist-packages/pythonforandroid/recipe.py", line 855, in install_python_package
    _env=hpenv, *self.setup_extra_args)
  File "/usr/local/lib/python3.6/dist-packages/pythonforandroid/logger.py", line 178, in shprint
    for line in output:
  File "/usr/local/lib/python3.6/dist-packages/sh.py", line 863, in next
    self.wait()
  File "/usr/local/lib/python3.6/dist-packages/sh.py", line 792, in wait
    self.handle_command_exit_code(exit_code)
  File "/usr/local/lib/python3.6/dist-packages/sh.py", line 815, in handle_command_exit_code
    raise exc
sh.ErrorReturnCode_1: 

  RAN: /root/.local/share/python-for-android/build/other_builds/hostpython3/desktop/hostpython3/native-build/python setup.py install -O2 --root=/root/.local/share/python-for-android/build/python-installs/TriviaTV --install-lib=.

  STDOUT:
Traceback (most recent call last):
  File "setup.py", line 11, in <module>
    import setuptools
  File "/root/.local/share/python-for-android/build/other_builds/setuptools-python3/armeabi-v7a__ndk_target_21/setuptools/setuptools/__init__.py", line 14, in <module>
    from setuptools.dist import Distribution, Feature
  File "/root/.local/share/python-for-android/build/other_builds/setuptools-python3/armeabi-v7a__ndk_target_21/setuptools/setuptools/dist.py", line 25, in <module>
    from setuptools import windows_support
  File "/root/.local/share/python-for-android/build/other_builds/setuptools-python3/armeabi-v7a__ndk_target_21/setuptools/setuptools/windows_support.py", line 2, in <module>
    import ctypes
  File "/root/.local/share/python-for-android/build/other_builds/hostpython3/desktop/hostpython3/Lib/ctypes/__init__.py", line 7, in <module>
    from _ctypes import Union, Structure, Array
ModuleNotFoundError: No module named '_ctypes'


  STDERR:

Robert Flatt

unread,
Apr 3, 2019, 4:49:23 PM4/3/19
to Kivy users support
As I posted in the other thread :

This may also be an issue:

[WARNING]: Missing executable: pkg-config is not installed

The trick is to try and figure out what each line of the log file might mean,
pay particular attention to : error, warning and traceback.

The rest is just a learning curve.

Also:

[WARNING]: lld not found, linking without it. Consider installing lld if linker errors occur.

ModuleNotFoundError: No module named '_ctypes'
 
This is perhaps the linker error in the WARNING?

In the post it says: "18.04 LTS server,"

These instructions are tested on Desktop.
This is perhaps the root of the issue, the default packages on Server and Desktop are different.
The messages above may be symptoms of this difference.

So wild guess, try this:
sudo apt install build-essential

Your sys admin will give you better advice on issues like this.

And its probably better to create a new thread for new questions, that way others can search by subject.

Евгений Кокин

unread,
Sep 16, 2019, 5:18:52 AM9/16/19
to Kivy users support
Tell me please wich size of your apk ?
And how about 64bit build i mean arm64-v8a ?
Also how about plyer and pyjnius in your build ?
Thank you

четверг, 29 ноября 2018 г., 2:08:26 UTC+3 пользователь Robert Flatt написал:

Robert Flatt

unread,
Sep 16, 2019, 4:48:08 PM9/16/19
to Kivy users support

Wow, you found an old post. But is still mostly valid.


I currently use python-for-android version 2019.8.9   , this was the latest version last time I checked.

I now use arm64, this is my current .p4a template:


--dist_name=<XXX>
--private .
--package=com.<YYY>.<XYZ>
--name <ZZZ>
--requirements=python3,kivy
--arch=arm64-v8a
--orientation sensor
--icon <ICON>.png
--sdk_dir <WHERE_EVER>/sdk
--ndk_dir <WHERE_EVER>/
android-ndk-r17c  
--android_api 29    
--ndk-api 21
--version <0.0.0>



I now use sdk 29, same download file, but two lines in the instructions have changed to:


./sdkmanager "platforms;android-29"
./sdkmanager "build-tools;29.0.0"


APK size is about 12MB to 13MB - but this depends a little on the size of the app code, and mostly on the external python modules or data files used by the app...... it is easy to test this for yourself.


pyjnius works but 1) there is no checking between python and java, 2) you have to have understand the Android Java structure. Mistakes are easy to make, start with small tests, check the result of autoclass() for non-None. In the examples when is says ".renpy." replace this with ".kivy.". A short learning curve, crash and burn a few times then it becomes easy. Really, start with small tests.


I don't use plyer, personal preference, because some of the functions (buzzer, camera, ...?) do not support the current Android API. Surprise, crash :(  however I am told some plyer functions do work. Try small tests :)


I debug from Windows, first install Android Studio, then add this line to the PATH, then at a CMD prompt type adb <command>

C:\Users\<USERNAME>\AppData\Local\Android\sdk1\platform-tools\


Enjoy.

Евгений Кокин

unread,
Sep 20, 2019, 4:45:50 AM9/20/19
to Kivy users support
Thanks a lot for your answer!
May be you can help me
I try to test a simple vibrate function

pip3 freeze:
python-for-android=2019.8.9
pyjnius==1.2.0
cython==0.29.13


I check 2 versions of code from official pyjnius documentation

1.
from jnius import autoclass
PythonActivity = autoclass('org.kivy.android.PythonActivity')
activity = PythonActivity.mActivity
Context = autoclass('android.content.Context')
vibrator = activity.getSystemService(Context.VIBRATOR_SERVICE)
vibrator.vibrate(10000)

2.
from jnius import autoclass
PythonActivity = autoclass('org.kivy.android.PythonService')
activity = PythonActivity.mService
Context = autoclass('android.content.Context')
vibrator = activity.getSystemService(Context.VIBRATOR_SERVICE)
vibrator.vibrate(10000)

And i get 2 different error:

1.
09-20 10:42:47.720  7717  7753 I python  :  Traceback (most recent call last):
09-20 10:42:47.720  7717  7753 I python  :    File "/home/eugene/digs/main.py", line 54, in <module>
09-20 10:42:47.721  7717  7753 I python  :    File "jnius/jnius_export_class.pxi", line 1034, in jnius.jnius.JavaMultipleMethod.__call__
09-20 10:42:47.721  7717  7753 I python  :  jnius.jnius.JavaException: No methods matching your arguments, available: ['(ILjava/lang/String;JLandroid/media/AudioAttributes;)V', '(ILjava/lang/String;[JILandroid/media/AudioAttributes;)V']
09-20 10:42:47.721  7717  7753 I python  : Python for android ended.

2.
09-20 11:05:04.837  9154  9188 I python  :  Traceback (most recent call last):
09-20 11:05:04.837  9154  9188 I python  :    File "/home/eugene/digs/main.py", line 52, in <module>
09-20 11:05:04.838  9154  9188 I python  :  AttributeError: 'NoneType' object has no attribute 'getSystemService'
09-20 11:05:04.838  9154  9188 I python  : Python for android ended.

what am I doing wrong?

thank you.













понедельник, 16 сентября 2019 г., 23:48:08 UTC+3 пользователь Robert Flatt написал:

Robert Flatt

unread,
Sep 20, 2019, 1:14:43 PM9/20/19
to Kivy users support
what am I doing wrong?
Trusting the documentation :(
No worries, this is the expected new user experience, crash a couple of times then its easy :)

I suspect this is failing for the same reason plyer.vibrate() fails.
Android vibrate() changed and no longer takes an int argument, it takes a VibrationEffect :
The pyjnius documentation does not reflect this change.

I have not tested the following, but
Use pyjnius and try calling vibrate() with a VibrationEfect argument in place of the int argument.
You'll have to autoclass VibrationEffect
https://developer.android.com/reference/android/os/VibrationEffect.html

Gary Kuipers

unread,
Jun 6, 2020, 11:27:42 AM6/6/20
to Kivy users support
Brian: were you ever able to get twisted/autobahn vorking on Android? For me it works great in linux but hours of pounding have not gotten me to get it to work on Android.


On Wednesday, November 28, 2018 at 3:08:26 PM UTC-8, Robert Flatt wrote:
Reply all
Reply to author
Forward
0 new messages