I'd like to execute python code from an Android app. I wish to implement a text editor in my app where the user can load, edit and run his script. I will create specific functions for the user to code some functionality into the app. For now, I've identified Python as the most friendly language for my purpose.
What methods are there for creating an embedded python interpreter in an android app? I've been looking at Kivy framework, and was maybe hoping that I could use the python command exec(codeString) to run the code. But Kivy is packaged by Buildozer tool to produce an *.apk for android, which might be compiled and not interpreted. Would this work?
There are several apps out there that allow python coding in an Android device, so technically it is possible.
Related
I got python code that has no GUI and works in terminal. Can I convert it to apk and run on android?
I'm just curious if it's possible.
No, you cannot directly run a Python script in the terminal as an Android app. Python scripts are typically run on a computer using the Python interpreter, and Android devices use the Android operating system which is different from the typical computer operating systems.
However, you can use a tool such as Kivy, which is a Python library for creating mobile apps, to create an Android app from your Python script. Kivy provides a way to package your Python code into an Android app, so you can run it on an Android device.
I am sure there are other tools providing this option as well. These tools essentially bundle the Python interpreter and your script into a single executable file, so the user doesn't need to have Python installed on their device to run your app.
I believe there are tutorials on youtube as well so as to how to use Kivy to run your python code. I hope this helps :)
I want to make python code editor in my android app that can excecute the code too. Is it possible to make it with flutter? How to do it?
I am currently learning Python as part of my job and was interested in the possibility of creating android applications using what I am learning. Unfortunately I only have access to a computed at work and the system is pretty locked down in that I cannot export work I create etc and the only device I have during my leisure time is my android phone.
I have heard about the possibility of using Kivy but have only seen reference to this being used on MacOS, Linux or Windows making me think my only choice would be running a virtual machine which would be less convenient than running a native tool. I have also seen that AIDE is a great tool for android app development on mobile but can only be used with C++/Java which would involve learning additional languages and PyDroid3 being a great python tool but don't know how this could be used to create android apps.
Any experience or knowledge in this area would be much appreciated. I understand the best scenario would be to either buy a laptop/pc and use PyCharm and/or Kivy or to learn Java and used the official Android development suite but in my current situation this is not possible.
Just download pydroid3 from play store and follow the steps to create an android app.
Install kivymd module using pip in pydroid3.
Watch kivymd tutorials on youtube to learn kivymd module , you can also refer to kivymd documentation on google.
Develop application using kivymd module in pydroid3.
Convert your python file to apk using kivy buildozer in google colab in chrome on your mobile phone.
I haven't used kivymd but I have used kivy in pyroid3 and it works really well on a phone. Also when you run the code it gives a really good indication of how the final app will look on the phone. But that said I have only used Buildozer to compile the .APK and this only works in Linux so for me that ment virtual Linux system.
so I have a project that developed with django ,Django Restframework.
I had planned for UI handling. Reactjs and Reatnative for UI .but I searched and found Kivy project that comes with Cross Platforms for making Apps and games.my project doesn't involve any game stuff just regular web site.
is it good using kivy for handling UI for Android and IOs?
I also checked kivy supports fully Url request for interact with Rest APIs.
https://kivy.org/docs/api-kivy.network.urlrequest.html
Kivy is really good alternative to android native programming language for python programmers. You need ubuntu to build apk for kivy apps. However, installing ubuntu or virtual environment is not mandatory if you use windows 10 because windows 10 have linux subsystem. You can check it on this videoVideo.
Kivy is general framework which is not specific to games or graphical application only. Kivy support regular mobile application development, we can check it by the provided widgets. The widgets are also customizable So, kivy is a pretty good alternative.
I know we can launch an app in Android using Kivy launcher for android https://play.google.com/store/apps/details?id=org.kivy.pygame
and i can launch apps by the same as well . But i need to know how and where can we see the logs generated by the app in it ? For example if i run kivy app on my desktop i will be able to see logs on console but where will i find them when launching an app by kivy launcher ?
If we cant see logs is there any ways to make this possible ?
On android, kivy prints all python's normal terminal output to the android logcat stream. You can view this from the desktop by connecting your phone via usb and doing adb logcat. adb is provided by the android sdk, so if it's not in your path you can probably find it there. If you use buildozer, I think you can access its auto-downloaded android sdk using
buildozer android logcat
You can also view the adb output using some apps on the play store (may only work with older android versions though, I think something changed here).
Kivy may also store logs as text files somewhere on the sd card, possibly in the app directory (i.e. somewhere in the kivy launcher's kivy directory), but I haven't ever really used this, adb is a lot more convenient.
When your application is executed a .kivy folder will be created (if not already there).
In it you'll see a logs folder. The logs there are the same obtained via "adb logcat".