[Python for Android] Simple Example Needed

968 views
Skip to first unread message

Chengxin Ma

unread,
Feb 14, 2017, 11:47:12 AM2/14/17
to Kivy users support
Hi guys,
I am wondering where I can find a concrete and simple example to get familiar with Python for Android.
I've checked the official tutorial, but the examples are for the old toolchain: http://python-for-android.readthedocs.io/en/latest/old_toolchain/examples/
I've also checked the "Getting Started" page, only to find that the usages are puzzling. I don't know what is the right choice for my application: "Build a Kivy application", "Build a WebView application", and "Build an SDL2 based application".
So I'd like to follow a simple "Hello World" tutorial step by step to see what the development process is. Does anyone know where such a tutorial can be found?
I am using Debian for development.

Kind Regards

Alexander Taylor

unread,
Feb 14, 2017, 7:01:55 PM2/14/17
to Kivy users support
If you want examples of runnable programs, there are some general python-for-android test applications at https://github.com/kivy/python-for-android/tree/master/testapps . The setup.py files can be run with 'python setup.py apk' to perform the python-for-android build, as long as you have python-for-android installed from the master branch.

As for what usage to follow, what kind of app are you making, and why aren't the labelled usages clear? We can potentially improve the documentation if there is a problem with the current content.

Chengxin Ma

unread,
Feb 15, 2017, 4:47:42 PM2/15/17
to Kivy users support
Thanks for your reply. It turned out that I was looking for the examples in the wrong place. It would be nice if there are some description about running the test apps in the README file.

I am taking over a task of porting a Python app Tribler to Android. The original Tribler is here: https://github.com/Tribler/tribler
The guy who was responsible for that has already done a great job and I am now at the phase of understanding the whole system. To better understand the whole system, I've decided to run a simple example using p4a. This way I can temporarily get rid of the complexity of Tribler and focus on p4a.
I hope after taking a look at the tesapps I will know what the differences are among the labels. They not making sense to me at the moment just because I am not fully familiar with p4a.

As for the doc, I've just made a small enhancement: https://github.com/kivy/python-for-android/pull/1014

Alexander Taylor

unread,
Feb 18, 2017, 7:49:28 AM2/18/17
to kivy-...@googlegroups.com
I hadn't really thought about the examples being useful to new users, as
they're mostly used to test changes, but that's a very good point. I'll
add some information about it to the doc and README.

Good luck with Tribler, let us know if you have any problems or other
suggestions.
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Kivy users support" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/kivy-users/rZuRgwZ6T8s/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> kivy-users+...@googlegroups.com
> <mailto:kivy-users+...@googlegroups.com>.
> For more options, visit https://groups.google.com/d/optout.


signature.asc

Chengxin Ma

unread,
Feb 22, 2017, 2:55:08 PM2/22/17
to kivy-...@googlegroups.com
Hi Alexander,
So I am trying to get the example testapps/testapp run, first on the PC and then on the Android phone.
when running the main file in that folder (on PC, by executing "python main.py"), I got an error that says "ImportError: No module named kivy". What am I supposed to do to make the kivy package available? (I installed p4a by "pip install git+https://github.com/kivy/python-for-android.git")

Though the problem is not solved, I still proceeded. Then I met more trouble. The error message is as follows:

chengxin@T450s:~/python-for-android/testapps$ python setup_testapp_python2.py apk
('packages are', [])
running apk
WARNING: You did not supply an Android package identifier, trying org.test.testapp_python2 instead.
         This may fail if this is not a valid identifier
Including testapp/main.py
Including testapp/colours.png
[INFO]:    Will compile for the following archs: armeabi
[WARNING]: Android SDK dir was not specified, exiting.

My questions are:
  1. Where to set the Android package identifier?
  2. Where to specify Android SDK dir?
Kind Regards

> For more options, visit https://groups.google.com/d/optout.


--
You received this message because you are subscribed to a topic in the Google Groups "Kivy users support" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/kivy-users/rZuRgwZ6T8s/unsubscribe.
To unsubscribe from this group and all its topics, send an email to kivy-users+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--

Chengxin Ma (馬承新)

Faculty Electrical Engineering, Mathematics and Computer Science

Delft University of Technology

LinkedIn: https://www.linkedin.com/in/chengxinma/

Alexander Taylor

unread,
Feb 22, 2017, 4:59:11 PM2/22/17
to kivy-...@googlegroups.com
You can install Kivy according to the instructions at
https://kivy.org/#download .

You don't need to set the Android package identifier, but you can do so
with an argument if you want, e.g. as at
http://python-for-android.readthedocs.io/en/latest/quickstart/#build-a-kivy-application

You can set the SDK dir in several ways, see
http://python-for-android.readthedocs.io/en/latest/quickstart/#installing-android-sdk


On 22/02/17 19:55, Chengxin Ma wrote:
> Hi Alexander,
> So I am trying to get the example testapps/testapp
> <https://github.com/kivy/python-for-android/tree/master/testapps/testapp> run,
> first on the PC and then on the Android phone.
> when running the main file in that folder (on PC, by executing "python
> main.py"), I got an error that says "ImportError: No module named kivy".
> What am I supposed to do to make the kivy package available? (I
> installed p4a by "pip install
> git+https://github.com/kivy/python-for-android.git")
>
> Though the problem is not solved, I still proceeded. Then I met more
> trouble. The error message is as follows:
>
> chengxin@T450s:~/python-for-android/testapps$ python
> setup_testapp_python2.py apk
> ('packages are', [])
> running apk
> WARNING: You did not supply an Android package identifier, trying
> org.test.testapp_python2 instead.
> This may fail if this is not a valid identifier
> Including testapp/main.py
> Including testapp/colours.png
> [INFO]: Will compile for the following archs: armeabi
> [WARNING]: Android SDK dir was not specified, exiting.
>
>
> My questions are:
>
> 1. Where to set the Android package identifier?
> 2. Where to specify Android SDK dir?
>
> Kind Regards
>
> On Sat, Feb 18, 2017 at 1:49 PM, Alexander Taylor
> <alexander...@gmail.com <mailto:alexander...@gmail.com>>
> <https://groups.google.com/d/topic/kivy-users/rZuRgwZ6T8s/unsubscribe>.
> > To unsubscribe from this group and all its topics, send an email to
> > kivy-users+...@googlegroups.com
> <mailto:kivy-users%2Bunsu...@googlegroups.com>
> > <mailto:kivy-users+...@googlegroups.com
> <mailto:kivy-users%2Bunsu...@googlegroups.com>>.
> > For more options, visit https://groups.google.com/d/optout
> <https://groups.google.com/d/optout>.
>
>
> --
> You received this message because you are subscribed to a topic in
> the Google Groups "Kivy users support" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/kivy-users/rZuRgwZ6T8s/unsubscribe
> <https://groups.google.com/d/topic/kivy-users/rZuRgwZ6T8s/unsubscribe>.
> To unsubscribe from this group and all its topics, send an email to
> kivy-users+...@googlegroups.com
> <mailto:kivy-users%2Bunsu...@googlegroups.com>.
> For more options, visit https://groups.google.com/d/optout
> <https://groups.google.com/d/optout>.
>
>
>
>
> --
>
> Chengxin Ma (馬承新)
>
> Faculty Electrical Engineering, Mathematics and Computer Science
>
> Delft University of Technology
>
> LinkedIn: https://www.linkedin.com/in/chengxinma/
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Kivy users support" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/kivy-users/rZuRgwZ6T8s/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> kivy-users+...@googlegroups.com
> <mailto:kivy-users+...@googlegroups.com>.
signature.asc

Chengxin Ma

unread,
Feb 23, 2017, 5:12:56 AM2/23/17
to kivy-...@googlegroups.com
Hi Alexander,
Thanks for your reply.
After trial and error, I finally managed to make the application running on both my laptop and my phone. (See attachment.)
I'd like to point out that the setup_testapp_python2.py cannot be used out-of-the-box, even after I changed the options in this file. So instead I build the application using the command here: http://python-for-android.readthedocs.io/en/latest/quickstart/#build-a-kivy-application
One of the errors I've met is that "argument --package is required". (I removed that during my first build.) So I think unlike what you said that the Android package identifier is optional, it is still necessary.


>     <mailto:kivy-users%2Bunsu...@googlegroups.com>>.
>     > For more options, visit https://groups.google.com/d/optout
>     <https://groups.google.com/d/optout>.
>
>
>     --
>     You received this message because you are subscribed to a topic in
>     the Google Groups "Kivy users support" group.
>     To unsubscribe from this topic, visit
>     https://groups.google.com/d/topic/kivy-users/rZuRgwZ6T8s/unsubscribe
>     <https://groups.google.com/d/topic/kivy-users/rZuRgwZ6T8s/unsubscribe>.
>     To unsubscribe from this group and all its topics, send an email to
>
>
>
>
> --
>
> Chengxin Ma (馬承新)
>
> Faculty Electrical Engineering, Mathematics and Computer Science
>
> Delft University of Technology
>
> LinkedIn: https://www.linkedin.com/in/chengxinma/
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Kivy users support" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/kivy-users/rZuRgwZ6T8s/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to

> For more options, visit https://groups.google.com/d/optout.


--
You received this message because you are subscribed to a topic in the Google Groups "Kivy users support" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/kivy-users/rZuRgwZ6T8s/unsubscribe.
To unsubscribe from this group and all its topics, send an email to kivy-users+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
Screenshot from 2017-02-23 10-51-17.png
Screenshot_20170223-105000.png
Reply all
Reply to author
Forward
0 new messages