Python Forum
Python-for-Android:p4a: syntax error in main.py while compiling apk
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python-for-Android:p4a: syntax error in main.py while compiling apk
#1
Hello all,

Jayson Again - and I am making a website and android app by using an iframe in python then converting the .py file to an apk in p4a module.

I have an intense webpage at fishmap.lftr.biz -- that slings a data rich world fishing map with video, in python3 and so..........
   
I have utilized this webpage to make a .py script and android app as apk:
https://python-for-android.readthedocs.io/en/latest/

when i run and sdl2 bootstrap:
Error while running "/home/jay/.local/share/python-for-android/build/other_builds/hostpython3/desktop/hostpython3/native-build/python3 -OO -m compileall -b -f /home/jay/python-for-android"
This probably means one of your Python files has a syntax error, see logs above
termainal command:
p4a apk --private /home/jay/python-for-android --package=biz.lftr.Fishmap --name "Fishmap" --version 0.1 --bootstrap=sdl2 --requirements=python3==3.9,hostpython3==3.9 --arch arm64-v8a --sdk-dir /home/jay/python-for-android/~/python-for-android/android-studio --ndk-dir /home/jay/python-for-android/android-ndk-r25b --presplash-color=teal --permission=INTERNET --debug
main.py
#!/usr/bin/env python3
print ('''Content-Type: text/html\n''')
print ('''
<html><head>
  <title>LFTR Fishmap</title>
  <meta name="description" content="fish fishing map with Doppler Radar Map weather" />
  <meta http-equiv="content-type" content="text/html" />
  <meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<iframe src="fishmap.lftr.biz"></iframe>
</body> 
</html>''')
so i run :
python3 -OO - m compileall -b -f /home/jay/python-for-android
and the command works no syntax error, however it is independent of the finale of the script, so no apk just .pyc is made

any help???? in making my python script and apk
I am continuing to attempt.....i believe there may be a python -V issue on my Ubuntu 22 machine so i download and install python-is-python3 to make the alias' better. I have python 3.10.4 now aswell. no luck yet.
Hey, my command is wrong... too



p4a clean_download_cache requirements
p4a clean_dists && p4a clean_builds
p4a apk --requirements=requirements \
--permission PERMISSION \
--package=the.package.name \
--name="App name" \
--version=x.y.z \
--android_api XY \
--bootstrap=sdl2 \
--launcher \
--minsdk 13


Warning

Do not use any of –private, –public, –dir or other arguments for adding main.py or main.pyo to the app. The argument –launcher is above them and tells the p4a to build the launcher version of the APK.
Well, a new tutorial has popped up and there has been a revamp done to the package p4a is now python-for-android and when i install it on a new machine :
New Tutorial - http://inclem.net/files/p4a_revamp_doc/quickstart.html

i will get back at the success of the new command:

python-for-android create ..........................
Hello again, Jayson - and i have found new hope on the topic....

a google collab exists utilizing python-for-android and buildozer....

It is a great solution for turning a python program into an ANDROID APP.

Google Colab


i found my colab option here: TowardsDataScience

https://towardsdatascience.com/3-ways-to...f4c9cd55af

I will post the status of the apk untill i finish my fishmap......
Well, i have output an apk ...finally.

   
   

unfortunately, while progress has been made i have yet to load the app, so i will try other options like webview and flask.
Reply
#2
apk in my google drive which opens it for install

well, I am still working, now developing in Android and will think that the python code is working and so is python for android with buildozer so i may have an android problem now.......as to why the apk builds installs however closes after running...for a second...thank you again....I have been on here for a minute and it is a good outlet for python type assistance.
Reply
#3
well, i have also reached out on:
https://groups.google.com/g/kivy-users/c/JgL_LVIJ7-E

by updating kivy via pip in the colab:
pip install git+https://github.com/ebs-universe/kivy_garden.ebs.cefkivy.git

this is my new main.py
import kivy
kivy.require('2.1.0') # replace with your current kivy version !

from kivy.app import App
from kivy.uix.label import Label
from kivy_garden.ebs.cefkivy.browser import CefBrowser, cefpython

class CefBrowserApp(App):
    def build(self):
        return Label(text='LFTR.biz FISHMAP WITH RADAR')
        return CefBrowser(start_url='fishmap.lftr.biz')

CefBrowserApp().run()
cefpython.Shutdown()
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Syntax error for "root = Tk()" dlwaddel 15 1,180 Jan-29-2024, 12:07 AM
Last Post: dlwaddel
Photo SYNTAX ERROR Yannko 3 381 Jan-19-2024, 01:20 PM
Last Post: rob101
  android e python fece recognition Fabiola 1 717 Sep-13-2023, 04:59 PM
Last Post: albertschmidt
  Syntax error while executing the Python code in Linux DivAsh 8 1,586 Jul-19-2023, 06:27 PM
Last Post: Lahearle
  Code is returning the incorrect values. syntax error 007sonic 6 1,228 Jun-19-2023, 03:35 AM
Last Post: 007sonic
  syntax error question - string mgallotti 5 1,316 Feb-03-2023, 05:10 PM
Last Post: mgallotti
Question Running Python under Termux on Android tablet dfkettle 1 3,491 Jan-25-2023, 02:34 PM
Last Post: dfkettle
  Syntax error? I don't see it KenHorse 4 1,256 Jan-15-2023, 07:49 PM
Last Post: Gribouillis
  Syntax error tibbj001 2 891 Dec-05-2022, 06:38 PM
Last Post: deanhystad
  python run all py files from main py file mg24 6 1,329 Oct-12-2022, 04:41 AM
Last Post: mg24

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020