kivy / python-for-android

Turn your Python application into an Android APK
https://python-for-android.readthedocs.io
MIT License
8.1k stars 1.81k forks source link

Fix building ssl for python3 #1217

Closed agilewalker closed 5 years ago

agilewalker commented 6 years ago

Pull request https://github.com/kivy/python-for-android/pull/1195 commits squashed and rebased onto master.

bauerj commented 6 years ago

Why was this closed?

ysangkok commented 6 years ago

@Zen-CODE Do you know why this was closed?

inclement commented 6 years ago

@ysangkok It was closed by the OP, I don't know why.

bauerj commented 6 years ago

@agilewalker Do you know why this was closed?

Zen-CODE commented 6 years ago

Perhaps the question for ask is whether https://github.com/kivy/python-for-android/pull/1195 fixes the issue? And if so, why has it not been merged? It seems most likely that the PR was just never merged...

Can anyone confirm that pull requests fixes the issue?

ysangkok commented 6 years ago

It does fix the issue, we are using it in Electrum. See the readme in https://github.com/spesmilo/electrum/tree/master/gui/kivy

Zen-CODE commented 6 years ago

@ysangkok. Okay, I've re-opened the RP. Will test and merge if I don't see any problems. Thanks

Zen-CODE commented 6 years ago

Even using the PR above (and setting the p4a.source_dir to point to there, I don't get a build error but when running get

ImportError: No module named '_ssl'

If I try your instructions, when I try to checkout the specified commit, I get:

pathspec 'a036f4442b6a23' did not match any
ysangkok commented 6 years ago

Weird that you can't find the commit, did you git fetch from agilewalker? The commit is here: https://github.com/agilewalker/python-for-android/commit/a036f4442b6a23 . I have to ponder on the other issue.

EDIT: actually, @SomberNight let me know that that commit is in kivy/python-for-android too. So I really can't understand how you couldn't check it out.

Zen-CODE commented 6 years ago

My bad. Okay, I've got it checked out but I still get the "ImportError: No module named '_ssl'" when doing an import ssl. I am using python 3.5 though. I see the PR contains a python3.6 patch, so possibly it only works for 3.6?

inclement commented 6 years ago

Following the recent discussion on irc, I think the following things need to be done for this to be merged:

1) Rebasing on master again (obviously) 2) It needs testing via Travis 3) I think the build order code at https://github.com/kivy/python-for-android/pull/1217/files#diff-7029dba21bb853e1d7019a7a98586ee9R194 should be restructured to not use arbitrary numbers, so that it's clearer what's going on.

I was going to start on this, but hit some other build problems with p4a, which I'm looking into first.

ghost commented 5 years ago

Since this pull request has a minor conflict with current master, I rebased it while resolving the conflict:

https://github.com/JonasT/python-for-android/tree/tlsfix

(just in case anyone else needs this)

ghost commented 5 years ago

Edit: nvm I was silly and forgot the internet permission. pull request seems to work fine at least as of now

pat1 commented 5 years ago

I have checked JonasT fork and it works for me. I hope in a merge.

ghost commented 5 years ago

@pat1 I think the plan for the future is that python3crystax will be fully abandoned for a direct upstream python 3 build. With this, the missing standard library module issues, including this _ssl module, should be fixed. So I assume (but the others will need to correct me on this) that this will most likely not be merged in favor of fixing the whole python3crystax situation instead.

tito commented 5 years ago

I've an rework openssl recipes that works on latest release and ndk, will open PR today. It will outdate this one.

homdx commented 5 years ago

@pat1 I think the plan for the future is that python3crystax will be fully abandoned for a direct upstream python 3 build. With this, the missing standard library module issues, including this _ssl module, should be fixed. So I assume (but the others will need to correct me on this) that this will most likely not be merged in favor of fixing the whole python3crystax situation instead.

I probe compile test app:

https://stackoverflow.com/questions/49884548/how-to-run-kivy-and-flask-apps-together

with buildozer==0.0.34:

[app]
requirements = kivy,git+https://github.com/JonasT/python-for-android.git,pymysql,python3crystax==3.6,crypto,Flask,werkzeug,jinja2,markupsafe,openssl
android.ndk = 17c
android.ndk_path = /home/user/.buildozer/crystax-ndk-10.3.2
android.arch = armeabi-v7a

Error in my phone: (log from adb)

files/app/crystax_python/stdlib.zip/ssl.py", line 101, in I/python ( 4918): ModuleNotFoundError: No module named '_ssl' I/python ( 4918): WARNING:kivy:stderr: ModuleNotFoundError: No module named '_ssl' I/python ( 4918): Python for android ended.

ghost commented 5 years ago

@homdx have you used the "tlsfix" branch? the "master" branch of the JonasT/python-for-android repo contains whatever, but not this pull request

homdx commented 5 years ago

@JonasT yes (file buildozer.spec):

It's work. Maybe need patch for buildozer==0.34?

--- .local/lib/python2.7/site-packages/buildozer/targets/android.py     2017-12-15 15:43:32.000000000 +0000
+++ .local/lib/python2.7/site-packages/buildozer/targets/android.py.tls 2018-11-21 09:06:02.574278674 +0000
@@ -501,7 +501,7 @@
             if not self.buildozer.file_exists(pa_dir):
                 cmd(
                     ('git clone -b {} --single-branch '
-                     'https://github.com/kivy/python-for-android.git '
+                     'https://github.com/JonasT/python-for-android.git '
                      '{}').format(source, self.p4a_directory),
                     cwd=self.buildozer.platform_dir)
             elif self.platform_update:

and in buildozer.spec:

android.permissions = WRITE_EXTERNAL_STORAGE,INTERNET
p4a.branch = tlsfix
homdx commented 5 years ago

@homdx have you used the "tlsfix" branch? the "master" branch of the JonasT/python-for-android repo contains whatever, but not this pull request

Now not compile. 3 days ago, compile without error, But now is no(

[INFO]: Collating object files from each recipe Traceback (most recent call last): File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main "main", fname, loader, pkg_name) File "/usr/lib/python2.7/runpy.py", line 72, in _run_code exec code in run_globals File "/home/user/hostcwd/app2/.buildozer/android/platform/python-for-android-new-toolchain/pythonforandroid/toolchain.py", line 1032, in main() File "/home/user/hostcwd/app2/.buildozer/android/platform/python-for-android-new-toolchain/pythonforandroid/toolchain.py", line 1028, in main ToolchainCL() File "/home/user/hostcwd/app2/.buildozer/android/platform/python-for-android-new-toolchain/pythonforandroid/toolchain.py", line 550, in init getattr(self, args.subparsername.replace('-', ''))(args) File "/home/user/hostcwd/app2/.buildozer/android/platform/python-for-android-new-toolchain/pythonforandroid/toolchain.py", line 149, in wrapper_func build_dist_from_args(ctx, dist, args) File "/home/user/hostcwd/app2/.buildozer/android/platform/python-for-android-new-toolchain/pythonforandroid/toolchain.py", line 188, in build_dist_from_args build_recipes(build_order, python_modules, ctx) File "pythonforandroid/build.py", line 626, in build_recipes biglink(ctx, arch) File "pythonforandroid/build.py", line 705, in biglink env = arch.get_env() File "pythonforandroid/archs.py", line 155, in get_env env = super(ArchARMv7_a, self).get_env(with_flags_in_cc) File "pythonforandroid/archs.py", line 54, in get_env self.ctx.python_recipe.version[0:3]) AttributeError: 'NoneType' object has no attribute 'version'

Command failed: /usr/bin/python -m pythonforandroid.toolchain apk --debug --bootstrap=sdl2 --dist_name flaskhello --name flaskhello --version 0.1 --package com.flaskhello.flaskhello --android_api 19 --minsdk 9 --private /home/user/hostcwd/app2/.buildozer/android/app --permission WRITE_EXTERNAL_STORAGE --permission INTERNET --orientation sensor --window --copy-libs --arch armeabi-v7a --color=always --storage-dir=/home/user/hostcwd/app2/.buildozer/android/platform/build

Buildozer failed to execute the last command

The error might be hidden in the log above this error

Please read the full log, and search for it before

raising an issue with buildozer itself.

In case of a bug report, please add a full log with log_level = 2

real 0m48.866s user 0m14.036s sys 0m28.917s user@5232a3a69875:~/hostcwd/app2$ cd /home/user/hostcwd/app2/.buildozer/android/platform/python-for-android-new-toolchain user@5232a3a69875:~/hostcwd/app2/.buildozer/android/platform/python-for-android-new-toolchain$ git log commit c0d398ebe7b4f6f5f8e840cf11cf069002e5978d (HEAD -> tlsfix, origin/tlsfix) Author: Jonas Thiem jonas@thiem.email Date: Fri Nov 23 13:53:58 2018 +0100

Adapt tls fix to new recipe naming
ghost commented 5 years ago

@homdx is there a specific reason you use python 2 for building things? (to run p4a I mean) Can you try a Python 3 host? It works for me using Python 3 host + python3crystax target, I don't see the error you mention above

(As for why it broke, I occasionally rebase tlsfix to the latest p4a master. This is why it suddenly changed in behavior, although of course I haven't intentionally broken it)

homdx commented 5 years ago

@homdx is there a specific reason you use python 2 for building things? (to run p4a I mean) Can you try a Python 3 host? It works for me using Python 3 host + python3crystax target, I don't see the error you mention above

(As for why it broke, I occasionally rebase tlsfix to the latest p4a master. This is why it suddenly changed in behavior, although of course I haven't intentionally broken it)

I can't build with python3 error:

Could not find hostpython, will not compile to .pyo (this is normal with python3) WARNING: --minsdk argument does not match the api that is compiled against. Only proceed if you know what you are doing, otherwise use --minsdk=19 or recompile against api 14 You must pass --allow-minsdk-ndkapi-mismatch to build with --minsdk different to the target NDK api from the build step

Show you buildozer.spec file (api, requrements) and python3 --version? Thanks)

ghost commented 5 years ago

I don't use buildozer. I currently use android platform-tools & NDK bundle for API 19, android build tools 25.0.2, with CrystaX NDK 10.3.2, and I build with target Android API level 19 and mininmum android API level 19.

The error message you quoted already gives you a possible solution: use a minimum SDK android API level of 19. (This is a different option than the regular target API option! It should be something you can set in your buildozer.spec)

homdx commented 5 years ago

You can write instruction, how make apk without buildozer from main.py with kivy file?

ghost commented 5 years ago

@homdx it's all in the docs, just read them: https://python-for-android.readthedocs.io/en/latest/quickstart/ if you have any questions about a specific part, feel free to drop into the discord or make a ticket if you find a particular section unclearly written

Edit:

I use p4a directly, just to be clear on the process. For the options, see the documentation. However, please note that for doing this, I installed the Android SDK + NDK manually (this is the part people usually use buildozer for)

homdx commented 5 years ago

@JonasT Today i build with this instruction https://groups.google.com/forum/#!topic/kivy-users/Lf4zlYmLVPo install apk on the phone, and have error: (log logcat)


V/pythonutil(11885): Checking pattern libcrystax\.so against libSDL2_mixer.so
V/pythonutil(11885): Checking pattern libcrystax\.so against libSDL2_ttf.so
V/pythonutil(11885): Checking pattern libcrystax\.so against libmain.so
V/pythonutil(11885): Checking pattern libcrystax\.so against libSDL2.so
V/pythonutil(11885): Checking pattern libcrystax\.so against libSDL2_image.so
V/pythonutil(11885): Checking pattern libcrystax\.so against libpython3.7m.so
V/pythonutil(11885): Checking pattern libsqlite3\.so against libSDL2_mixer.so
V/pythonutil(11885): Checking pattern libsqlite3\.so against libSDL2_ttf.so
V/pythonutil(11885): Checking pattern libsqlite3\.so against libmain.so
V/pythonutil(11885): Checking pattern libsqlite3\.so against libSDL2.so
V/pythonutil(11885): Checking pattern libsqlite3\.so against libSDL2_image.so
V/pythonutil(11885): Checking pattern libsqlite3\.so against libpython3.7m.so
V/pythonutil(11885): Checking pattern libssl.*\.so against libSDL2_mixer.so
V/pythonutil(11885): Checking pattern libssl.*\.so against libSDL2_ttf.so
V/pythonutil(11885): Checking pattern libssl.*\.so against libmain.so
V/pythonutil(11885): Checking pattern libssl.*\.so against libSDL2.so
V/pythonutil(11885): Checking pattern libssl.*\.so against libSDL2_image.so
V/pythonutil(11885): Checking pattern libssl.*\.so against libpython3.7m.so
V/pythonutil(11885): Checking pattern libcrypto.*\.so against libSDL2_mixer.so
V/pythonutil(11885): Checking pattern libcrypto.*\.so against libSDL2_ttf.so
V/pythonutil(11885): Checking pattern libcrypto.*\.so against libmain.so
V/pythonutil(11885): Checking pattern libcrypto.*\.so against libSDL2.so
V/pythonutil(11885): Checking pattern libcrypto.*\.so against libSDL2_image.so
V/pythonutil(11885): Checking pattern libcrypto.*\.so against libpython3.7m.so
V/pythonutil(11885): Loading library: SDL2
V/pythonutil(11885): Loading library: SDL2_image
V/pythonutil(11885): Loading library: SDL2_mixer
V/pythonutil(11885): Loading library: SDL2_ttf
V/pythonutil(11885): Loading library: python2.7
V/pythonutil(11885): Library loading error: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.kivymd.test-1/base.apk"],nativeLibraryDirectories=[/data/app/com.kivymd.test-1/lib/arm, /vendor/lib, /system/lib]]] couldn't find "libpython2.7.so"
V/pythonutil(11885): Loading library: python3.5m
V/pythonutil(11885): Library loading error: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.kivymd.test-1/base.apk"],nativeLibraryDirectories=[/data/app/com.kivymd.test-1/lib/arm, /vendor/lib, /system/lib]]] couldn't find "libpython3.5m.so"
V/pythonutil(11885): Loading library: python3.6m
V/pythonutil(11885): Library loading error: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.kivymd.test-1/base.apk"],nativeLibraryDirectories=[/data/app/com.kivymd.test-1/lib/arm, /vendor/lib, /system/lib]]] couldn't find "libpython3.6m.so"
V/pythonutil(11885): Loading library: python3.7m
V/pythonutil(11885): Loading library: main
E/art     (11885): dlopen("/data/app/com.kivymd.test-1/lib/arm/libmain.so", RTLD_LAZY) failed: dlopen failed: could not load library "libpython3.7m.so.1.0" needed by "libmain.so"; caused by library "libpython3.7m.so.1.0" not found
V/pythonutil(11885): Library loading error: dlopen failed: could not load library "libpython3.7m.so.1.0" needed by "libmain.so"; caused by library "libpython3.7m.so.1.0" not found
V/pythonutil(11885): An UnsatisfiedLinkError occurred loading main
W/System.err(11885): dlopen failed: could not load library "libpython3.7m.so.1.0" needed by "libmain.so"; caused by library "libpython3.7m.so.1.0" not found```
ghost commented 5 years ago

@homdx

The instructions you linked use the new upstream python3 recipe and not python3crystax, so this cannot work. (since tlsfix is written for the python3crystax recipe only, not python3).

You need to do something like this:

cd WHERE-EVER/crystax-ndk/ && wget --no-verbose https://www.crystax.net/download/crystax-ndk-10.3.2-linux-x86_64.tar.xz -O crystax.tar.xz && tar xf crystax.tar.xz \
    --strip-components=1 \
    && rm WHERE-EVER/crystax-ndk/crystax.tar.xz

... then set ANDROID_NDK to WHERE-EVER/crystax-ndk/ before you call p4a, and use python3crystax in the requirements, not python3. Also please note I use Android API 19 & NDK 19, I have no idea if the API combination you use will work with Crystax (since I assume it might only work with specific NDKs).

In overall, Crystax and the use of this pull request are a tad ugly, so hopefully pure python3 will support TLS properly soon and make all of this unnecessary, but at least as far as I'm informed we're simply not there yet.

homdx commented 5 years ago

@JonasT Please show you .p4a file and full name sdk and ndk (file name for downloaded from google)

ghost commented 5 years ago

@homdx I used the ndk-bundler mechanism. Full command: sdkmanager "platform-tools" "platforms;android-19" "ndk-bundle" "build-tools;25.0.2" But this is derailing here a little, maybe you should come by in the discord or make a separate ticket?

JohnBuckleyGitHub commented 5 years ago

I am unable to get this to build with the following inside of my buildozer.spec:

requirements = android, kivy, python3crystax==3.6,pysdl2,openssl android.api = 19 android.minapi = 19 android.sdk = 26 android.ndk = 10.3.2 android.ndk_path = ~/Android/crystax-ndk-10.3.2/ p4a.source_dir = /home/anon/python-for-android

The python-for-android is the tlsfix branch. I have also tried api and minapi 21

The error message is:

[armeabi-v7a] SharedLibrary : lib_ssl.so /home/anon/Android/crystax-ndk-10.3.2/toolchains/arm-linux-androideabi-5/prebuilt/linux-x86_64/bin/arm-linux-androideabi-g++ -Wl,-soname,lib_ssl.so -shared --sysroot=/home/anon/Android/crystax-ndk-10.3.2/platforms/android-9/arch-arm ./obj/local/armeabi-v7a/objs/_ssl//home/anon/GitHub/boto_test_kivy/.buildozer/android/platform/build/build/other_builds/python3crystax-version3.6/armeabi-v7a__ndk_target_19/python3crystax/Modules/_ssl.o /home/anon/Android/crystax-ndk-10.3.2/sources/openssl/1.0.2h/libs/armeabi-v7a/libssl.a /home/anon/Android/crystax-ndk-10.3.2/sources/openssl/1.0.2h/libs/armeabi-v7a/libcrypto.a -lgcc ./obj/local/armeabi-v7a/libpython3.6m.so -no-canonical-prefixes -march=armv7-a -Wl,--fix-cortex-a8 -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -mthumb -L/home/anon/Android/crystax-ndk-10.3.2/sources/crystax/empty /home/anon/Android/crystax-ndk-10.3.2/sources/crystax/libs/armeabi-v7a/thumb/libcrystax.so -lc -o ./obj/local/armeabi-v7a/lib_ssl.so /home/anon/Android/crystax-ndk-10.3.2/sources/openssl/1.0.2h/libs/armeabi-v7a/libcrypto.a(armcap.o):armcap.c:function OPENSSL_cpuid_setup: error: undefined reference to 'sigfillset' /home/anon/Android/crystax-ndk-10.3.2/sources/openssl/1.0.2h/libs/armeabi-v7a/libcrypto.a(armcap.o):armcap.c:function OPENSSL_cpuid_setup: error: undefined reference to 'sigdelset' /home/anon/Android/crystax-ndk-10.3.2/sources/openssl/1.0.2h/libs/armeabi-v7a/libcrypto.a(armcap.o):armcap.c:function OPENSSL_cpuid_setup: error: undefined reference to 'sigdelset' /home/anon/Android/crystax-ndk-10.3.2/sources/openssl/1.0.2h/libs/armeabi-v7a/libcrypto.a(armcap.o):armcap.c:function OPENSSL_cpuid_setup: error: undefined reference to 'sigdelset' /home/anon/Android/crystax-ndk-10.3.2/sources/openssl/1.0.2h/libs/armeabi-v7a/libcrypto.a(armcap.o):armcap.c:function OPENSSL_cpuid_setup: error: undefined reference to 'sigdelset' /home/anon/Android/crystax-ndk-10.3.2/sources/openssl/1.0.2h/libs/armeabi-v7a/libcrypto.a(ui_openssl.o):ui_openssl.c:function read_string_inner: error: undefined reference to 'signal' collect2: error: ld returned 1 exit status make: *** [obj/local/armeabi-v7a/lib_ssl.so] Error 1 make: Leaving directory `/tmp/ndk-anon/tmp/build-22360/build-python/armeabi-v7a/ssl' ERROR: Can't build python3.6-armeabi-v7a module '_ssl'

STDERR:

Command failed: /home/anon/anaconda2/bin/python -m pythonforandroid.toolchain create --dist_name=botoTest --bootstrap=sdl2 --requirements=android,kivy,python3crystax==3.6,pysdl2,openssl --arch armeabi-v7a --copy-libs --color=always --storage-dir="/home/anon/GitHub/boto_test_kivy/.buildozer/android/platform/build"

ghost commented 5 years ago

@johnbolia did you try using p4a clean_all before retrying with minsdk/ndk 21? I think this error appears due to some openssl / compiler interaction bug for lower API levels (target API 26 shouldn't matter, only minimum api should)

JohnBuckleyGitHub commented 5 years ago

@JonasT I have tried p4_clean_all and buildozer distclean as well as using an entirely new build directory. As an aside, I have been having to clear out the entire build dir as I am geting an error on buildozer android clean: OSError: [Errno 2] No such file or directory: '/home/anon/GitHub/boto_test_kivy/.buildozer/android/platform/python-for-android-new-toolchain' I assume this is due to the failed build? Not due to someother problem.

I have checked that it is using the tslfix p4a build from your gitbranch. It has the addition of the 'libssl.a' and 'libcrypto.a' in the openssl recipe and it is definitely looking in this dir at the start of the build because if I rename the dir it will fail right away (with a different error message).

I have tried severla buildozer builds from 0.34, 0.37 and 0.38dev.

ghost commented 5 years ago

Okay I just checked again, and it works for me with target API 26, ndk & minimum API set to 19. I think this translates to these buildozer settings:

android.api = 26
android.minapi = 19
android.sdk = 26
android.ndk = 10.3.2
android.ndk_api = 19

(please note the different first line, and the added last line)

I don't use buildozer so this is just a guess from the docs. But I suggest you try these settings, let me know if that works for you!

JohnBuckleyGitHub commented 5 years ago

Thank you very much for your time on this.

I will try those api settings. I have not used android.ndk_api before.

If unsuccessful, I am going to setup a new VM to try this. I have been using Ubuntu 18 which comes with python 3.6. Do you think this could be a problem?

On Mon, 31 Dec 2018 14:35 JonasT <notifications@github.com wrote:

Okay I just checked again, and it works for me with target API 26, ndk & minimum API set to 19. I think this translates to these buildozer settings:

android.api = 26 android.minapi = 19 android.sdk = 26 android.ndk = 10.3.2 android.ndk_api = 19

(please note the different first line, and the added last line)

I don't use buildozer so this is just a guess from the docs. But I suggest you try these settings, let me know if that works for you!

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/kivy/python-for-android/pull/1217#issuecomment-450652467, or mute the thread https://github.com/notifications/unsubscribe-auth/ACT71mfl8iLVqoGEMUaiqFi9TmwxLeJ8ks5u-iCZgaJpZM4RS_QZ .

ghost commented 5 years ago

No, I don't think this would be an issue at all @ Ubuntu 18 or Python 3.6. Also, instead of a VM, you could also try my tool which I use to get a somewhat stable build environment in docker: https://github.com/JonasT/p4a-build-spaces (shameless plug)

But your error really looks like your buildozer settings are just wrong, I've encountered that very same error myself. So I'd first try to update your spec and see if that helps, maybe that'll fix all your problems already

JohnBuckleyGitHub commented 5 years ago

I will definitely try the docker.

My heart sank when I thought about setting up a new VM.

Out of curiosity, how long does a second build normally take you?

With the old Android toolchain, I used to be able to generate an API in about 20-30s, now it takes 50 - 70s. This is on a i7 3.2ghz

I know you don't use buildozer, so I was wondering how long your builds take after the initial build?

Again, thank you for your time.

John

On Mon, 31 Dec 2018 14:55 JonasT <notifications@github.com wrote:

No, I don't think this would be an issue at all @ Ubuntu 18 or Python 3.6. Also, instead of a VM, you could also try my tool which I use to get a somewhat stable build environment in docker: https://github.com/JonasT/p4a-build-spaces (shameless plug)

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/kivy/python-for-android/pull/1217#issuecomment-450654720, or mute the thread https://github.com/notifications/unsubscribe-auth/ACT71uNfGQNhnTP7u7Mu9fm_hlfQfr3_ks5u-iV6gaJpZM4RS_QZ .

ghost commented 5 years ago

I use p4aspaces cmd (rather than an interactive p4aspaces shell I could keep running for a longer time / multiple builds) to build which always uses a new throwaway environment from scratch, with the distribution folder and other temporary build artifacts always wiped out. Therefore, I'm always waiting the full 20 minutes or whatever it takes from scratch :man_shrugging: but I'm guaranteed a clean build. Given I occasionally mess with larger self-written changes to python-for-android with very experimental stuff, that is more important to me

JohnBuckleyGitHub commented 5 years ago

That makes sense.

I will look into the docker later today.

On Mon, 31 Dec 2018 15:13 JonasT <notifications@github.com wrote:

I use p4aspaces cmd to build which always uses a new throwaway environment from scratch (the distribution folder and other temporary build artifacts are wiped out) so I'm always waiting the full 20 minutes or whatever it takes from scratch 🤷‍♂️ but I'm guaranteed a clean build. Given I occasionally mess with larger self-written changes to python-for-android with very experimental stuff, that is more important to me

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/kivy/python-for-android/pull/1217#issuecomment-450656525, or mute the thread https://github.com/notifications/unsubscribe-auth/ACT71sAAvOr_xSpWCkVrbX-lE0eunrlgks5u-imDgaJpZM4RS_QZ .

ghost commented 5 years ago

You can also throw away the shell each time though (just use exit and everything is gone outside of the workspace added with --workspace with your project), just to remark this for completeness' sake. cmd just makes more sense for my build since I fully automated it with a script, so I don't need to interact with it unless things go wrong.

You can also catch me in the kivy discord if you need any help with docker or p4a-build-spaces, and I'm very curious if you find anything counter-intuitive/confusing while using the latter so I can improve the docs

JohnBuckleyGitHub commented 5 years ago

Hello Jonas,

I have tried p4aspaces and it looks really promising. I have taken down a few notes on the doumentation.

In my option, you should put a requirements section in the beginning before installation. I knew very little about docker and so it was not immediately obvious to me that it would need to be installed.

Install docker. Maybe include a good link. I found this one which worked for me - https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-18-04

Add user to the docker group sudo usermod -a -G docker $USER

Installation worked fine Launch There is typo in p4spaces list-envs should be p4aspaces list-envs

Questions which I still have: How to use of the --workspace command. I didn't use it on creation, does that mean that envirnoment variables return to defaults, or that the whole container can disappear?

I also get the following warning: Buildozer is running as root! This is not recommended, and may lead to problems later. I am not sure if I made a mistake setting up docker, or if this is normal?

I loaded the container p4a-py3crystax-api26ndk19 and tried the example. Unfortunately it requires api 21+. I tried changing NDKMIN=21, but the build crashes. I have attached the screen output, but I could not find where config.log is located.

In the morning I will try building with your P4A branch for patching ssl, but I need to get a better understanding how to get files in and out of the docker container.

Thanks,

John

On Mon, Dec 31, 2018 at 3:24 PM JonasT notifications@github.com wrote:

You can also throw away the shell each time though (just use exit and everything is gone outside of the workspace added with --workspace with your project), just for completeness sake. cmd just makes more sense for my build since I fully automated it with a script, so I don't need to interact with it unless things go wrong.

You can also catch me in the kivy discord if you need any help with docker or p4a-build-spaces, and I'm very curious if you find anything counter-intuitive/confusing while using the latter so I can improve the docs

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/kivy/python-for-android/pull/1217#issuecomment-450657904, or mute the thread https://github.com/notifications/unsubscribe-auth/ACT71j8VBMLZDTtTDNg8-8UP7BTLEgrdks5u-iwhgaJpZM4RS_QZ .

ghost commented 5 years ago

@johnbolia nice thanks for testing :+1: and thanks for all the feedback! I attempted to clarify the installation requirements and that the container is thrown away in the README.

Regarding your build issue, the screenshot doesn't seem to be attached for some reason. But did you try using the p4a-py3crystax-api26ndk21 environment?

How to use of the --workspace command

You can specify a folder with --workspace which is then available in the container as ~/workspace. Changes to this folder are immediately visible on both ends (inside & outside of the container) and this folder remains once the environment/container is stopped. So if you keep your project & work in there, it will be persisted, while the whole p4a/buildozer install around it is always fresh with your next launch.

I am not sure if I made a mistake setting up docker, or if this is normal?

This is currently a p4a build spaces limitation. I would need to add an option to specify which "outside user" to use, such that inside the container you'd have the correct permissions to access everything in your workspace. I didn't do that yet, so inside the container env you work as a root user which works around this permission complexity. (That's ugly I'll admit, so thanks for putting this back on my radar, I'll add it soon)

JohnBuckleyGitHub commented 5 years ago

Hello Jonas,

Thank you for your answers.

The list of environments that I have are:

Available environments: p4a-py2-api19-ndkbundle Python 2 with min/target API 19, bundled NDK 19 p4a-py2-api28ndk21 Python 2 with target API 28, bundled NDK 21, min api 21 p4a-py3-api28ndk21 Python 3 with target API 28, NDK 21, min api 21 p4a-py3crystax-api19-ndkbundle Python 3 Crystax with min/target API 19, and ndk-bundle for API 19 p4a-py3crystax-api26ndk19 Python 3 Crystax with target API 26 and NDK/min api 19

Which seems to correlate with what I see in your repo. p4a-py3crystax-api26ndk21 would be the most useful build configuration for me, as I need api26 for some of the painful Oreo stuff Google is bringing in and there isn't a numpy recipe for plain python3.

I can re-attach the log, but if you have a p4a-py3crystax-api26ndk21 space which I could pick up, it would probably be best if I jumped on that rathar than trying to get the p4a-py3crystax-api26ndk19 working.

Regarding the workspace, is the correct syntax then:

p4aspaces shell p4a-py3crystax-api26ndk21 --workspace

Also, please let me know if this will work:

  1. create new space with --workspace (which contains project code)

  2. after first build, continue using this space for mulitple builds and even multiple projects until the api configuration is obsolete or the space stops working.

  3. Have several spaces as listed in (2) but all sharing the same workspace?

So do please let me know if the points listed above will be a workable system, or if there is another way to approach it? With the time cost of creating spaces, I would like to avoid creating (or re-creating) whenever possible, though I think once a build starts failing, it will be more time efficient to create a clean space.

Again, thank you for your time.

John

On Tue, Jan 1, 2019 at 10:50 PM JonasT notifications@github.com wrote:

@johnbolia https://github.com/johnbolia nice thanks for testing 👍 and thanks for all the feedback! I attempted to clarify the installation requirements and that the container is thrown away in the README.

Regarding your build issue, the screenshot doesn't seem to be attached for some reason. But did you try using the p4a-py3crystax-api26ndk21 environment?

How to use of the --workspace command

You can specify a folder with --workspace which is then available in the container as ~/workspace. Changes to this folder are immediately visible on both ends (inside & outside of the container) and this folder remains once the environment/container is stopped. So if you keep your project & work in there, it will be persisted, while the whole p4a/buildozer install around it is always fresh with your next launch.

I am not sure if I made a mistake setting up docker, or if this is normal?

This is currently a p4a build spaces limitation. I would need to add an option to specify which "outside user" to use, such that inside the container you'd have the correct permissions to access everything in your workspace. I didn't do that yet, so inside the container things you work as a root user which works around this permission complexity. (That's ugly I'll admit, so thanks for putting this back on my radar, I'll add it soon)

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/kivy/python-for-android/pull/1217#issuecomment-450762899, or mute the thread https://github.com/notifications/unsubscribe-auth/ACT71pfePxTlVqB_nLAkR5WLGxXqZz6Qks5u--Y_gaJpZM4RS_QZ .

JohnBuckleyGitHub commented 5 years ago

Sorry, just a couple other things I forgot to include in the last email.

Regarding super user, although a bit ugly, not a big deal. I am not that good in a nix environment, so I was just afraid I might have made a mistake. It may be worth putting something in the documentation that this behaviour is expected, as I was a bit spooked by the warning and almost tried re-installing as I thought I had made a mistake. It might be fine as is, I am an utter newbie with docker and not great with nix.

Also, does the --workspace command setup a volume? I was reading up on docker and it looks like a similar behavior to what you describe.

Thanks,

John

On Wed, Jan 2, 2019 at 10:11 AM John johnpbcmail@gmail.com wrote:

Hello Jonas,

Thank you for your answers.

The list of environments that I have are:

Available environments: p4a-py2-api19-ndkbundle Python 2 with min/target API 19, bundled NDK 19 p4a-py2-api28ndk21 Python 2 with target API 28, bundled NDK 21, min api 21 p4a-py3-api28ndk21 Python 3 with target API 28, NDK 21, min api 21 p4a-py3crystax-api19-ndkbundle Python 3 Crystax with min/target API 19, and ndk-bundle for API 19 p4a-py3crystax-api26ndk19 Python 3 Crystax with target API 26 and NDK/min api 19

Which seems to correlate with what I see in your repo. p4a-py3crystax-api26ndk21 would be the most useful build configuration for me, as I need api26 for some of the painful Oreo stuff Google is bringing in and there isn't a numpy recipe for plain python3.

I can re-attach the log, but if you have a p4a-py3crystax-api26ndk21 space which I could pick up, it would probably be best if I jumped on that rathar than trying to get the p4a-py3crystax-api26ndk19 working.

Regarding the workspace, is the correct syntax then:

p4aspaces shell p4a-py3crystax-api26ndk21 --workspace

Also, please let me know if this will work:

  1. create new space with --workspace (which contains project code)

  2. after first build, continue using this space for mulitple builds and even multiple projects until the api configuration is obsolete or the space stops working.

  3. Have several spaces as listed in (2) but all sharing the same workspace?

So do please let me know if the points listed above will be a workable system, or if there is another way to approach it? With the time cost of creating spaces, I would like to avoid creating (or re-creating) whenever possible, though I think once a build starts failing, it will be more time efficient to create a clean space.

Again, thank you for your time.

John

On Tue, Jan 1, 2019 at 10:50 PM JonasT notifications@github.com wrote:

@johnbolia https://github.com/johnbolia nice thanks for testing 👍 and thanks for all the feedback! I attempted to clarify the installation requirements and that the container is thrown away in the README.

Regarding your build issue, the screenshot doesn't seem to be attached for some reason. But did you try using the p4a-py3crystax-api26ndk21 environment?

How to use of the --workspace command

You can specify a folder with --workspace which is then available in the container as ~/workspace. Changes to this folder are immediately visible on both ends (inside & outside of the container) and this folder remains once the environment/container is stopped. So if you keep your project & work in there, it will be persisted, while the whole p4a/buildozer install around it is always fresh with your next launch.

I am not sure if I made a mistake setting up docker, or if this is normal?

This is currently a p4a build spaces limitation. I would need to add an option to specify which "outside user" to use, such that inside the container you'd have the correct permissions to access everything in your workspace. I didn't do that yet, so inside the container things you work as a root user which works around this permission complexity. (That's ugly I'll admit, so thanks for putting this back on my radar, I'll add it soon)

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/kivy/python-for-android/pull/1217#issuecomment-450762899, or mute the thread https://github.com/notifications/unsubscribe-auth/ACT71pfePxTlVqB_nLAkR5WLGxXqZz6Qks5u--Y_gaJpZM4RS_QZ .

ghost commented 5 years ago

@johnbolia I vaguely remember some issue with building Crystax + TLS with NDK API/minimum API 21. I use target API 26 + ndk/minimum 19 with Crystax personally and that works fine. Can you attach your build error? (don't use e-mail, respond using the web interface and attach the thing there - then it should show up)

Regarding --workspace, it's just a volume yes. It needs a folder path as a parameter, which is the folder that will then be mapped inside as ~/workspace. Ideally, that folder contains your project itself, that saves you the effort to download it separately each time

ghost commented 5 years ago

For what it's worth, we're also like 3 merges away from obsoleting Crystax I would think. So in 1-2 weeks this whole tlsfix & crystax business might have solved itself :woman_shrugging: lol

JohnBuckleyGitHub commented 5 years ago

@JonasT I have attached the screen output

Apologies to the issue thread for going so far off topic, I was on email and forgot all this was posted. p4a screen output.txt

ghost commented 5 years ago

@JonasT I have attached the screen output

Ah, it might want clang and only gcc is around. Should be easy to fix, nevertheless I remember CrystaX having some issues with higher minimum(!) API levels so I'm not sure if that environment is very useful anyway (I added a few just for testing mainly)

I loaded the container p4a-py3crystax-api26ndk19 and tried the example. Unfortunately it requires api 21+

Do you require that as a minimum API though? This is almost never necessary, so it sounds to me like you might maybe just want to use p4a-py3crystax-api26ndk19 instead

homdx commented 5 years ago

@JonasT I checked with new deps #apt install -y libffi-dev libssl-dev and latest branch master of p4a:

New logs:

I/python  ( 4580): Android kivy bootstrap done. __name__ is __main__
I/python  ( 4580): AND: Ran string
I/python  ( 4580): Run user program, change dir and execute entrypoint
I/python  ( 4580): main.py
I/python  ( 4580): [WARNING] [Config      ] Older configuration version detected (0 instead of 20)
I/python  ( 4580): [WARNING] [Config      ] Upgrading configuration in progress.
I/python  ( 4580): [INFO   ] [Logger      ] Record log in /data/data/com.example.test/files/app/.kivy/logs/kivy_19-01-11_0.txt
I/python  ( 4580): [INFO   ] [Kivy        ] v1.10.1
I/python  ( 4580): [INFO   ] [Python      ] v3.7.1 (default, Jan 11 2019, 17:30:45) 
I/python  ( 4580): [Clang 6.0.2 (https://android.googlesource.com/toolchain/clang 183abd29fc496f55
I/python  ( 4580): [INFO   ] [Factory     ] 194 symbols loaded
I/python  ( 4580): [INFO   ] [Image       ] Providers: img_tex, img_dds, img_sdl2, img_gif (img_pil, img_ffpyplayer ignored)
I/python  ( 4580): [INFO   ] [Window      ] Provider: sdl2
I/python  ( 4580): [INFO   ] [GL          ] Using the "OpenGL ES 2" graphics system
I/python  ( 4580): [INFO   ] [GL          ] Backend used <gl>
I/python  ( 4580): [INFO   ] [GL          ] OpenGL version <b'OpenGL ES 3.1 build 1.4@3300288'>
I/python  ( 4580): [INFO   ] [GL          ] OpenGL vendor <b'Imagination Technologies'>
I/python  ( 4580): [INFO   ] [GL          ] OpenGL renderer <b'PowerVR Rogue G6200'>
I/python  ( 4580): [INFO   ] [GL          ] OpenGL parsed version: 3, 1
I/python  ( 4580): [INFO   ] [GL          ] Texture max size <8192>
I/python  ( 4580): [INFO   ] [GL          ] Texture max units <16>
I/python  ( 4580): [INFO   ] [Window      ] auto add sdl2 input provider
I/python  ( 4580): [INFO   ] [Window      ] virtual keyboard not allowed, single mode, not docked
I/python  ( 4580):  main.py:172: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
I/python  ( 4580):    import imp
I/python  ( 4580): [WARNING] [Base        ] Unknown <android> provider
I/python  ( 4580): [INFO   ] [Base        ] Start application main loop
I/python  ( 4580): [INFO   ] [GL          ] NPOT texture support is available
I/python  ( 4580): [INFO   ] [Text        ] Provider: sdl2
I/python  ( 4580): [WARNING] [Accordion   ] not enough space for displaying all children
I/python  ( 4580): [WARNING] [Accordion   ] need 264px, got 0px
I/python  ( 4580): [WARNING] [Accordion   ] layout aborted.
I/python  ( 4580): [INFO   ] [Loader      ] using a thread pool of 2 workers
I/python  ( 4580): [ERROR  ] [Loader      ] Failed to load image <https://kushaldas.in/images/pyconin15-3.jpg>
I/python  ( 4580): Traceback (most recent call last):
I/python  ( 4580):   File "/data/data/com.example.test/files/app/_python_bundle/stdlib.zip/urllib/request.py", line 1317, in do_open
I/python  ( 4580):     encode_chunked=req.has_header('Transfer-encoding'))
I/python  ( 4580):   File "/data/data/com.example.test/files/app/_python_bundle/stdlib.zip/http/client.py", line 1229, in request
I/python  ( 4580):     self._send_request(method, url, body, headers, encode_chunked)
I/python  ( 4580):   File "/data/data/com.example.test/files/app/_python_bundle/stdlib.zip/http/client.py", line 1275, in _send_request
I/python  ( 4580):     self.endheaders(body, encode_chunked=encode_chunked)
I/python  ( 4580):   File "/data/data/com.example.test/files/app/_python_bundle/stdlib.zip/http/client.py", line 1224, in endheaders
I/python  ( 4580):     self._send_output(message_body, encode_chunked=encode_chunked)
I/python  ( 4580):   File "/data/data/com.example.test/files/app/_python_bundle/stdlib.zip/http/client.py", line 1016, in _send_output
I/python  ( 4580):     self.send(msg)
I/python  ( 4580):   File "/data/data/com.example.test/files/app/_python_bundle/stdlib.zip/http/client.py", line 956, in send
I/python  ( 4580):     self.connect()
I/python  ( 4580):   File "/data/data/com.example.test/files/app/_python_bundle/stdlib.zip/http/client.py", line 1392, in connect
I/python  ( 4580):     server_hostname=server_hostname)
I/python  ( 4580):   File "/data/data/com.example.test/files/app/_python_bundle/stdlib.zip/ssl.py", line 412, in wrap_socket
I/python  ( 4580):     session=session
I/python  ( 4580):   File "/data/data/com.example.test/files/app/_python_bundle/stdlib.zip/ssl.py", line 853, in _create
I/python  ( 4580):     self.do_handshake()
I/python  ( 4580):   File "/data/data/com.example.test/files/app/_python_bundle/stdlib.zip/ssl.py", line 1117, in do_handshake
I/python  ( 4580):     self._sslobj.do_handshake()
I/python  ( 4580): ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1051)
I/python  ( 4580): During handling of the above exception, another exception occurred:
I/python  ( 4580): Traceback (most recent call last):
I/python  ( 4580):   File "/data/data/com.example.test/files/app/_python_bundle/site-packages/kivy/loader.py", line 317, in _load_urllib
I/python  ( 4580):     fd = urllib_request.urlopen(filename)
I/python  ( 4580):   File "/data/data/com.example.test/files/app/_python_bundle/stdlib.zip/urllib/request.py", line 222, in urlopen
I/python  ( 4580):     return opener.open(url, data, timeout)
I/python  ( 4580):   File "/data/data/com.example.test/files/app/_python_bundle/stdlib.zip/urllib/request.py", line 525, in open
I/python  ( 4580):     response = self._open(req, data)
I/python  ( 4580):   File "/data/data/com.example.test/files/app/_python_bundle/stdlib.zip/urllib/request.py", line 543, in _open
I/python  ( 4580):     '_open', req)
I/python  ( 4580):   File "/data/data/com.example.test/files/app/_python_bundle/stdlib.zip/urllib/request.py", line 503, in _call_chain
I/python  ( 4580):     result = func(*args)
I/python  ( 4580):   File "/data/data/com.example.test/files/app/_python_bundle/stdlib.zip/urllib/request.py", line 1360, in https_open
I/python  ( 4580):     context=self._context, check_hostname=self._check_hostname)
I/python  ( 4580):   File "/data/data/com.example.test/files/app/_python_bundle/stdlib.zip/urllib/request.py", line 1319, in do_open
I/python  ( 4580):     raise URLError(err)
I/python  ( 4580): urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1051)>
I/python  ( 4580): [ERROR  ] [Loader      ] Failed to load image <https://paste.opensuse.org/images/85253798.png>
I/python  ( 4580): Traceback (most recent call last):
I/python  ( 4580):   File "/data/data/com.example.test/files/app/_python_bundle/stdlib.zip/urllib/request.py", line 1317, in do_open
I/python  ( 4580):     encode_chunked=req.has_header('Transfer-encoding'))
I/python  ( 4580):   File "/data/data/com.example.test/files/app/_python_bundle/stdlib.zip/http/client.py", line 1229, in request
I/python  ( 4580):     self._send_request(method, url, body, headers, encode_chunked)
I/python  ( 4580):   File "/data/data/com.example.test/files/app/_python_bundle/stdlib.zip/http/client.py", line 1275, in _send_request
I/python  ( 4580):     self.endheaders(body, encode_chunked=encode_chunked)
I/python  ( 4580):   File "/data/data/com.example.test/files/app/_python_bundle/stdlib.zip/http/client.py", line 1224, in endheaders
I/python  ( 4580):     self._send_output(message_body, encode_chunked=encode_chunked)
I/python  ( 4580):   File "/data/data/com.example.test/files/app/_python_bundle/stdlib.zip/http/client.py", line 1016, in _send_output
I/python  ( 4580):     self.send(msg)
I/python  ( 4580):   File "/data/data/com.example.test/files/app/_python_bundle/stdlib.zip/http/client.py", line 956, in send
I/python  ( 4580):     self.connect()
I/python  ( 4580):   File "/data/data/com.example.test/files/app/_python_bundle/stdlib.zip/http/client.py", line 1392, in connect
I/python  ( 4580):     server_hostname=server_hostname)
I/python  ( 4580):   File "/data/data/com.example.test/files/app/_python_bundle/stdlib.zip/ssl.py", line 412, in wrap_socket
I/python  ( 4580):     session=session
I/python  ( 4580):   File "/data/data/com.example.test/files/app/_python_bundle/stdlib.zip/ssl.py", line 853, in _create
I/python  ( 4580):     self.do_handshake()
I/python  ( 4580):   File "/data/data/com.example.test/files/app/_python_bundle/stdlib.zip/ssl.py", line 1117, in do_handshake
I/python  ( 4580):     self._sslobj.do_handshake()
I/python  ( 4580): ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1051)
I/python  ( 4580): During handling of the above exception, another exception occurred:
I/python  ( 4580): Traceback (most recent call last):
I/python  ( 4580):   File "/data/data/com.example.test/files/app/_python_bundle/site-packages/kivy/loader.py", line 317, in _load_urllib
I/python  ( 4580):     fd = urllib_request.urlopen(filename)
I/python  ( 4580):   File "/data/data/com.example.test/files/app/_python_bundle/stdlib.zip/urllib/request.py", line 222, in urlopen
I/python  ( 4580):     return opener.open(url, data, timeout)
I/python  ( 4580):   File "/data/data/com.example.test/files/app/_python_bundle/stdlib.zip/urllib/request.py", line 525, in open
I/python  ( 4580):     response = self._open(req, data)
I/python  ( 4580):   File "/data/data/com.example.test/files/app/_python_bundle/stdlib.zip/urllib/request.py", line 543, in _open
I/python  ( 4580):     '_open', req)
I/python  ( 4580):   File "/data/data/com.example.test/files/app/_python_bundle/stdlib.zip/urllib/request.py", line 503, in _call_chain
I/python  ( 4580):     result = func(*args)
I/python  ( 4580):   File "/data/data/com.example.test/files/app/_python_bundle/stdlib.zip/urllib/request.py", line 1360, in https_open
I/python  ( 4580):     context=self._context, check_hostname=self._check_hostname)
I/python  ( 4580):   File "/data/data/com.example.test/files/app/_python_bundle/stdlib.zip/urllib/request.py", line 1319, in do_open
I/python  ( 4580):     raise URLError(err)
I/python  ( 4580): urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1051)>

and

I/python  ( 4156): [INFO   ] [Python      ] v2.7.15 (default, Jan 11 2019, 17:41:48) 
I/python  ( 4156): [GCC 4.2.1 Compatible Android (4691093 based on r316199) Clang 6.0.2 (https://a
I/python  ( 4156): [INFO   ] [Factory     ] 194 symbols loaded
I/python  ( 4156): [INFO   ] [Image       ] Providers: img_tex, img_dds, img_sdl2, img_gif (img_pil, img_ffpyplayer ignored)
I/python  ( 4156): [INFO   ] [Window      ] Provider: sdl2
I/python  ( 4156): [INFO   ] [GL          ] Using the "OpenGL ES 2" graphics system
I/python  ( 4156): [INFO   ] [GL          ] Backend used <gl>
I/python  ( 4156): [INFO   ] [GL          ] OpenGL version <OpenGL ES 3.1 build 1.4@3300288>
I/python  ( 4156): [INFO   ] [GL          ] OpenGL vendor <Imagination Technologies>
I/python  ( 4156): [INFO   ] [GL          ] OpenGL renderer <PowerVR Rogue G6200>
I/python  ( 4156): [INFO   ] [GL          ] OpenGL parsed version: 3, 1
I/python  ( 4156): [INFO   ] [GL          ] Texture max size <8192>
I/python  ( 4156): [INFO   ] [GL          ] Texture max units <16>
I/python  ( 4156): [INFO   ] [Window      ] auto add sdl2 input provider
I/python  ( 4156): [INFO   ] [Window      ] virtual keyboard not allowed, single mode, not docked
I/python  ( 4156): [WARNING] [Base        ] Unknown <android> provider
I/python  ( 4156): [INFO   ] [Base        ] Start application main loop
I/python  ( 4156): [INFO   ] [GL          ] NPOT texture support is available
I/python  ( 4156): [INFO   ] [Text        ] Provider: sdl2
I/python  ( 4156): [INFO   ] [Base        ] Leaving application in progress...
I/python  ( 4156):  Traceback (most recent call last):
I/python  ( 4156):    File "main.py", line 193, in <module>
I/python  ( 4156):      PyConApp().run()
I/python  ( 4156):    File "/data/data/com.example.test/files/app/_python_bundle/site-packages/kivy/app.py", line 826, in run
I/python  ( 4156):      runTouchApp()
I/python  ( 4156):    File "/data/data/com.example.test/files/app/_python_bundle/site-packages/kivy/base.py", line 502, in runTouchApp
I/python  ( 4156):      EventLoop.window.mainloop()
I/python  ( 4156):    File "/data/data/com.example.test/files/app/_python_bundle/site-packages/kivy/core/window/window_sdl2.py", line 727, in mainloop
I/python  ( 4156):      self._mainloop()
I/python  ( 4156):    File "/data/data/com.example.test/files/app/_python_bundle/site-packages/kivy/core/window/window_sdl2.py", line 460, in _mainloop
I/python  ( 4156):      EventLoop.idle()
I/python  ( 4156):    File "/data/data/com.example.test/files/app/_python_bundle/site-packages/kivy/base.py", line 337, in idle
I/python  ( 4156):      Clock.tick()
I/python  ( 4156):    File "/data/data/com.example.test/files/app/_python_bundle/site-packages/kivy/clock.py", line 581, in tick
I/python  ( 4156):      self._process_events()
I/python  ( 4156):    File "kivy/_clock.pyx", line 384, in kivy._clock.CyClockBase._process_events
I/python  ( 4156):    File "kivy/_clock.pyx", line 414, in kivy._clock.CyClockBase._process_events
I/python  ( 4156):    File "kivy/_clock.pyx", line 412, in kivy._clock.CyClockBase._process_events
I/python  ( 4156):    File "kivy/_clock.pyx", line 167, in kivy._clock.ClockEvent.tick
I/python  ( 4156):    File "/data/data/com.example.test/files/app/_python_bundle/site-packages/kivy/animation.py", line 352, in _update
I/python  ( 4156):      self.stop(widget)
I/python  ( 4156):    File "/data/data/com.example.test/files/app/_python_bundle/site-packages/kivy/animation.py", line 217, in stop
I/python  ( 4156):      self.dispatch('on_complete', widget)
I/python  ( 4156):    File "kivy/_event.pyx", line 703, in kivy._event.EventDispatcher.dispatch
I/python  ( 4156):    File "kivy/_event.pyx", line 1214, in kivy._event.EventObservers.dispatch
I/python  ( 4156):    File "kivy/_event.pyx", line 1138, in kivy._event.EventObservers._dispatch
I/python  ( 4156):    File "/data/data/com.example.test/files/app/_python_bundle/site-packages/kivy/uix/screenmanager.py", line 419, in _on_complete
I/python  ( 4156):      self.screen_in.dispatch('on_enter')
I/python  ( 4156):    File "kivy/_event.pyx", line 703, in kivy._event.EventDispatcher.dispatch
I/python  ( 4156):    File "kivy/_event.pyx", line 1214, in kivy._event.EventObservers.dispatch
I/python  ( 4156):    File "kivy/_event.pyx", line 1098, in kivy._event.EventObservers._dispatch
I/python  ( 4156):    File "/data/data/com.example.test/files/app/_python_bundle/site-packages/kivy/lang/builder.py", line 64, in custom_callback
I/python  ( 4156):      exec(__kvlang__.co_value, idmap)
I/python  ( 4156):    File "<string>", line 78, in <module>
I/python  ( 4156):    File "main.py", line 178, in load_screen
I/python  ( 4156):      manager.add_widget(sc)
I/python  ( 4156):    File "/data/data/com.example.test/files/app/_python_bundle/site-packages/kivy/uix/screenmanager.py", line 993, in add_widget
I/python  ( 4156):      self.current = screen.name
I/python  ( 4156):    File "kivy/properties.pyx", line 483, in kivy.properties.Property.__set__
I/python  ( 4156):    File "kivy/properties.pyx", line 524, in kivy.properties.Property.set
I/python  ( 4156):    File "kivy/properties.pyx", line 579, in kivy.properties.Property.dispatch
I/python  ( 4156):    File "kivy/_event.pyx", line 1214, in kivy._event.EventObservers.dispatch
I/python  ( 4156):    File "kivy/_event.pyx", line 1120, in kivy._event.EventObservers._dispatch
I/python  ( 4156):    File "/data/data/com.example.test/files/app/_python_bundle/site-packages/kivy/uix/screenmanager.py", line 1056, in on_current
I/python  ( 4156):      screen.dispatch('on_enter')
I/python  ( 4156):    File "kivy/_event.pyx", line 707, in kivy._event.EventDispatcher.dispatch
I/python  ( 4156):    File "/data/data/com.example.test/files/app/uix/screens/screenschedule.py", line 175, in on_enter
I/python  ( 4156):      from network import get_data
I/python  ( 4156):    File "/data/data/com.example.test/files/app/network/__init__.py", line 3, in <module>
I/python  ( 4156):      from kivy.network.urlrequest import UrlRequest
I/python  ( 4156):    File "/data/data/com.example.test/files/app/_python_bundle/site-packages/kivy/network/urlrequest.py", line 67, in <module>
I/python  ( 4156):      from httplib import HTTPConnection
I/python  ( 4156):    File "/data/data/com.example.test/files/app/_python_bundle/stdlib.zip/httplib.py", line 72, in <module>
I/python  ( 4156):    File "/data/data/com.example.test/files/app/_python_bundle/stdlib.zip/socket.py", line 47, in <module>
I/python  ( 4156):  ImportError: dlopen failed: cannot locate symbol "gethostbyaddr_r" referenced by "_socket.so"...
I/python  ( 4156): Python for android ended.
I/DEBUG   ( 4201):     #00 pc 0012856c  /data/app/com.example.test-1/lib/arm/libpython2.7.so
homdx commented 5 years ago

Great)) You reproduce new bug, like this: https://github.com/kivy/python-for-android/issues/1501

Then I launch app in phone: give error:

Error: dlopen failed: could not load library "libpython2.7.so.1.0" needed by "libmain.so", caused by library "libpython2.7.so.1.0" not found

Step for reproduce need Docker with env, provided by @JonasT https://github.com/JonasT/p4a-build-spaces

Start with you branch p4a: $./p4aspaces shell p4a-py3-api28ndk21 --p4a=https://github.com/opacam/python-for-android/archive/fix-python2-gethost.zip In docker:

git clone https://github.com/homdx/pydelhi_mobile
cd pyd*
git checkout api28
apt-get install nano --yes
nano .p4a

file .p4a --arch=armeabi-v7a --name 'Py Delhi' --package com.example.test --version 1 --icon data/icon.png --presplash=../screen.png --permission=INTERNET --requirements=python2,android,openssl,kivy==1.10.1,futures,requests end of file .p4a

now copy this file to folder and build:

cp .p4a pydelhiconf/
cd pydelhiconf
and compile
time p4a apk --private .

And install apk and give errors:)

V/pythonutil(14740): Checking pattern libcrypto.*\.so against libssl1.1.so
V/pythonutil(14740): Checking pattern libcrypto.*\.so against libSDL2_mixer.so
V/pythonutil(14740): Checking pattern libcrypto.*\.so against libSDL2_ttf.so
V/pythonutil(14740): Checking pattern libcrypto.*\.so against libmain.so
V/pythonutil(14740): Checking pattern libcrypto.*\.so against libSDL2.so
V/pythonutil(14740): Checking pattern libcrypto.*\.so against libpython2.7.so
V/pythonutil(14740): Checking pattern libcrypto.*\.so against libcrypto1.1.so
V/pythonutil(14740): Pattern libcrypto.*\.so matched file libcrypto1.1.so
V/pythonutil(14740): Checking pattern libcrypto.*\.so against libSDL2_image.so
V/pythonutil(14740): Loading library: SDL2
V/pythonutil(14740): Loading library: SDL2_image
V/pythonutil(14740): Loading library: SDL2_mixer
V/pythonutil(14740): Loading library: SDL2_ttf
V/pythonutil(14740): Loading library: ssl1.1
V/pythonutil(14740): Loading library: crypto1.1
V/pythonutil(14740): Loading library: python2.7
V/pythonutil(14740): Loading library: python3.5m
V/pythonutil(14740): Library loading error: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.example.test-1/base.apk"],nativeLibraryDirectories=[/data/app/com.example.test-1/lib/arm, /vendor/lib, /system/lib]]] couldn't find "libpython3.5m.so"
V/pythonutil(14740): Loading library: python3.6m
V/pythonutil(14740): Library loading error: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.example.test-1/base.apk"],nativeLibraryDirectories=[/data/app/com.example.test-1/lib/arm, /vendor/lib, /system/lib]]] couldn't find "libpython3.6m.so"
V/pythonutil(14740): Loading library: python3.7m
V/pythonutil(14740): Library loading error: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.example.test-1/base.apk"],nativeLibraryDirectories=[/data/app/com.example.test-1/lib/arm, /vendor/lib, /system/lib]]] couldn't find "libpython3.7m.so"
V/pythonutil(14740): Loading library: main
E/art     (14740): dlopen("/data/app/com.example.test-1/lib/arm/libmain.so", RTLD_LAZY) failed: dlopen failed: could not load library "libpython2.7.so.1.0" needed by "libmain.so"; caused by library "libpython2.7.so.1.0" not found
V/pythonutil(14740): Library loading error: dlopen failed: could not load library "libpython2.7.so.1.0" needed by "libmain.so"; caused by library "libpython2.7.so.1.0" not found
V/pythonutil(14740): An UnsatisfiedLinkError occurred loading main
W/System.err(14740): dlopen failed: could not load library "libpython2.7.so.1.0" needed by "libmain.so"; caused by library "libpython2.7.so.1.0" not found
opacam commented 5 years ago

Try it now please @homdx, it should work

Note: sorry, I didn't consider the @JonasT's application p4aspaces, my master branch was outdated...I only considered the merge conflicts...