DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
11 Monitoring and Observability Tools for 2023
Learn more
  1. DZone
  2. Testing, Deployment, and Maintenance
  3. Deployment
  4. Squeezing Python into an Android with a Single APK

Squeezing Python into an Android with a Single APK

Chris Smith user avatar by
Chris Smith
·
Jan. 10, 12 · Interview
Like (0)
Save
Tweet
Share
14.16K Views

Join the DZone community and get the full member experience.

Join For Free
While the use of Python on Android has been made possible for some time now through SL4A, the Python for Android project has set out to make things even easier.  SL4A allows you to edit scripts and execute interactive interpreters directly on an Android device, but Python for Android can take a Python application and use it, in conjunction with the Android SDK/NSK, to create a single little Android APK file, including your application, libraries, and of course the Python code.

Produced through the Kivy organization as a way to support their framework (also called Kivy), a cross-platform open source library, Python for Android is currently equipped with only one Java bootstrap for decompressing the files within the APK.  Lighter bootstraps are currently in the works, but it could be some time before they reach consumers.

As it stands, Python for Android looks to be the most versatile tool yet for developing Python applications for the Android platform, with its biggest advantage being the self-contained binary files it creates that are so easy to install.  Mathieu Virbel provides a list of pros and cons for working with Python for Android:


Pros:
  • A blacklist.txt file that can be used to exclude files in the final APK
  • Reusable distribution for other applications
  • Modular recipes architecture

Cons:
  • You need a main.py file that will be used for starting your application
  • Only one Java bootstrap available, using OpenGL ES 2.0
  • Only Kivy toolkit is working.  I'm sure that other people can enhance it to add other toolkit recipes.  But for example, pygame is not going to work because the Android project is OpenGL ES 2.0: pyagme drawing will not work.

-- Mathieu Virbel



Another important factor to consider is that the code is currently being tested exclusively on Ubuntu 11.10 and only offers support for a few Python Modules including: pygame, kivy, android, sqlite3, and openssl.  However, more testing and greater support should become available in the following months.

For more in-depth information, including coding and plenty of useful examples, be sure to visit Virbel's GitHub page.

Android (robot) Python (language)

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Introduction to Automation Testing Strategies for Microservices
  • OWASP Kubernetes Top 10
  • Secure APIs: Best Practices and Measures
  • 5 Software Developer Competencies: How To Recognize a Good Programmer

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: