question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

simple flask app on android fails to start

See original GitHub issue

This is my main.py

from flask import Flask
app = Flask(__name__)

@app.route('/')
def hello_world():
    return 'Hello World!'

if __name__ == '__main__':
    app.run(port=5000)

And I use python-for-android apk --private ~/workspace/mobile/webview/ --package=org.example.myapp --name "test" --version 0.1 --bootstrap=webview --requirements=flask --port 5000 for creating the APK. when I run the app on Android 4.4.2: logcat stucks at V/python (13767): extracting _load.html here:

V/python (13767): extracting lib/python2.7/lib-dynload/ V/python (13767): extracting lib/python2.7/lib-dynload/future_builtins.so V/python (13767): extracting lib/python2.7/lib-dynload/syslog.so V/python (13767): extracting lib/python2.7/lib-dynload/unicodedata.so V/python (13767): extracting lib/python2.7/lib-dynload/_ctypes.so V/python (13767): extracting lib/python2.7/lib-dynload/_csv.so V/python (13767): extracting lib/python2.7/lib-dynload/_io.so V/python (13767): extracting _load.html

and there is error shown on android device

Python Error

An error occurred while trying to load the application libraries. Please try again and/or reinstall.

Error: Couldn’t load main from loader dalvik.system.PathClassLoader[DexPathList[[zip file “/data/app/org/example.myapp-1.apk”],nativeLibraryDirectories=[/data/app-lib/org.example.myapp-1, /vendor/lib, /system/lib]]]: findLibrary returned null

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
inclementcommented, Sep 3, 2017

I’ve just checked the flask build and it does work for me, so it seems p4a isn’t just broken right now.

Your error seems to relate to a failure to load libmain.so, which occurs before any of the python stuff really gets going - that’s why you don’t get a clear log when checking only python. I don’t know why the libmain load would fail though. You could locat the python-for-android dist dir that has been produced and check what is in its libs folder, just in case - it should be libmain.so and libpython2.7.so.

0reactions
inclementcommented, Jan 31, 2019

Closing in favour of https://github.com/kivy/python-for-android/issues/1644, which tracks the current issues with the webview bootstrap following the many recent changes.

Read more comments on GitHub >

github_iconTop Results From Across the Web

application failed to connect to server (python, flask, android ...
This is the terminal in the python code. * Serving Flask app "flaskcoba1" (lazy loading) * Environment: production WARNING: This is a ...
Read more >
How to Build a Simple Android App with Flask Backend?
If the Application is failing to connect to the server, make sure your firewall allows connections on port 5000. If not, create an...
Read more >
How to make client android application with Flask server
This tutorial will show you how to send a simple text in which the Android app just makes an HTTP POST message for...
Read more >
Building an Android App on a Flask Server - HackerNoon
1. Create your Android App ... Select the activity template and click Next. ... Now the Android app is being created. Wait some...
Read more >
Quickstart — Flask Documentation (1.1.x)
What to do if the Server does not Start¶. In case the python -m flask fails or flask does not exist, there are...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found