Python for android is a project to create your own Python distribution including the modules you want, and create an apk including python, libs, and your application.
- Website: http://python-for-android.rtfd.org/
- Forum: https://groups.google.com/forum/?hl=fr#!forum/python-android
- Mailing list: python-android@googlegroups.com
The gnuradio branch contains recipes to build gnuradio applications for android. You can even build Android packages from python code generated by grc.
Download Android NDK, SDK
Launch "android", and download latest Android platform
Export some environment variables:
export ANDROIDSDK=<path/to/android-sdk>" export ANDROIDNDK="/path/to/android-ndk>" export ANDROIDNDKVER=r10 # This version I tested against export ANDROIDAPI=21 # I tested against (Of course correct the paths mentioned in ANDROIDSDK and ANDROIDNDK)
Clone python-for-android:
git clone git://github.com/dl1ksv/python-for-android git checkout gnuradio
Build a gnuradio distribution
cd python-for-android ./distribute.sh -m "audiostream gnuradio tinyalsa osmosdr kivy" -C -d gnuradio After some cups of tea you should find a build.py in the directory dist/gnuradio
- Go to gnuradio-examples/scripts directory::
There you'll find some scripts to build some examples.
- build_dialtone.sh
This app is taken from the gnuradio dialtone example and should directly run on your android device. It does not use alsa but instead audiostream for accessing the speaker.
Install te app by
adb install ../../dist/gnuradio/bin/Dialtone-1.0-debug.apk
Starting this app you'll get a button to start/stop the dialtone example.
- build_dialtonealsa.sh
Here tinyalsa is used to access the speaker via alsa. This example may directly work on android 4 ( I could not test ). On android 5 the app requires special permissions. The used card number is 1 and teh device is 0. These parameters are hard coded in
self.tinyalsa_talsa_sink_0 = tinyalsa.talsa_sink(samp_rate, 1, 0)
Maybe you have to change these paramters depending on your hardware.
I tested on a rooted nexus 7 and granted permissions by the means of SuperSu by:
( See:
http://su.chainfire.eu/#selinux-policies-allows
)
adb push audiopolicy.sh /sdcard/
adb shell
su
sh /sdcard/audiopolicy.sh
Install the app by
adb install ../../dist/gnuradio/bin/Dialtonealsa-1.0-debug.apk
Then you can run the app.
The permissions are lost after reboot!
- build_dialtone_nokivy.sh
Before running this example you have to grant the permissions like described above.
This app was generated by renameing the python file generated by grc to main.py and applying the build process.
- build_rtlsdr.sh
At the moment this is he most complex example. It's an FM receiver receiving a fixed frequency. ( The frequency ist fixed at the moment as there is no gui to set the frequency. At the moment this example requires libusb on your android device.
How to install libusb see:
https://github.com/libusb/libusb/tree/master/android
Additionaly you have to grant audio and usb permissions.
You'll find the scripts in the srcipts directory.
Important!!!!!
You'll have to run the usbpolicy.sh script after attaching rtl dongle to your android device!!
Credits
Some ideas for the recipes are taken from