Comments (5)
Can I suggest you to try to implement a simple example using just python's httplib, and not using requests? Maybe there are some android permissions that are blocking your http requests..
from pybridge.
I've constructed an example which uses http.client
(the python3 version of httplib
).
In bootstrap.py:
from http.client import HTTPConnection
def router(args):
# same as usual
def http_request(args):
conn = HTTPConnection("www.google.com")
print("sending request")
conn.request("GET", "/")
print("getting response")
r1 = conn.getresponse()
print(r1.status, r1.reason)
return str(r1.status)
routes = {
'http_request' : http_request
}
and in MainActivity.java we call json.put("function", "http_request")
.
I get the same errors as before. If I don't copy _socket.so
and the other .so files into the python directory I get ImportError: no module named '_socket'
. If I do copy all the .so files, then I get a SIGSEGV error which I've tracked down to a call of the _socket.getaddrinfo
function.
from pybridge.
Ah, you were right about the android permissions!
I added the following line to my AndroidManifests.xml file:
Now everything works :)
from pybridge.
How do I then tell pybridge to use the correct architecture specific _socket.so
file? At the moment I'm manually copying _socket.so
from the arm64-v8a
libs in the crystax ndk, but I guess there's a more elegant automated way to do this?
from pybridge.
Glad it worked for you.. 👍
I don't have any solution to automatically copy python files by architecture as I want to keep pybridge simple to understand and "hack"..
from pybridge.
Related Issues (20)
- How to install crystax-ndk in Mac? HOT 3
- How to include python .so modules (e.g. select.so) for all architectures? HOT 9
- APP_ABI := all HOT 1
- nsatisfiedLinkError HOT 2
- ImportError: No module named 'select' HOT 6
- No module named '_ssl' HOT 2
- so
- Question: How to import module based on c libraries HOT 2
- import module error
- 我问一下能不能把python编译器加上一些包比如requests等等封装到位的app上 然后可以执行.py文件或者单行代码 你这么怎么用呢
- How do i install packages in python ? HOT 3
- Need to hide my python file HOT 3
- Followed all the mention steps But I get "libpybridge.so" not found HOT 1
- libpybridge.so HOT 2
- how to uses python-for-android to cross-compile Python 3.8 for arm64-v8a
- UnsatisfiedLinkedError for libpybridge.so HOT 1
- Need help for app
- Cannot resolve symbol 'PyBridge' HOT 1
- you say about "python-for-android/dists/.../_python_bundle"
- python-for-android shared libraries for other architectures
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pybridge.