Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImportError android #943

Closed
konbernu opened this issue Nov 28, 2016 · 3 comments
Closed

ImportError android #943

konbernu opened this issue Nov 28, 2016 · 3 comments

Comments

@konbernu
Copy link

I m trying to import activity from android. Code:

from android import activity

I m using webview as bootstrap and the following recipes: flask,pyjnius,android. When I try to run the app, I get the following error:

I/python: [INFO ] [Logger ] Record log in /data/user/0/org.example.myapp/files/.kivy/logs/kivy_16-11-28_0.txt I/python: File "/data/user/0/org.example.myapp/files/environment.py", line 20, in <module> I/python: File "/data/user/0/org.example.myapp/files/lib/python2.7/site-packages/android/__init__.py", line 8, in <module> I/python: ImportError: dlopen failed: file offset for the library "/data/user/0/org.example.myapp/files/lib/python2.7/site-packages/android/_android.so" >= file size: 0 >= 0

@konbernu konbernu changed the title Cant import android ImportError android Nov 28, 2016
@KeyWeeUsr
Copy link
Contributor

No errors during compilation? Have you tried to unzip the apk and look if it's really present? Sometimes cleaning build/dists seems to be necessary.

@konbernu
Copy link
Author

the first time i compile there is an error:

Building android for armeabi-v7a
('name is', None, <class 'pythonforandroid.recipes.android.AndroidRecipe'>)
INFO: android apparently isn't already in site-packages
INFO: Cythonizing anything necessary in android
ccache found, will optimize builds
('path is', '/home/developer/Android/Ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86/bin/:/home/developer/Android/Ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/:/home/developer/Android/Ndk:/home/developer/Android/Sdk/tools:/home/developer/Android/Ndk:/home/developer/Android/Sdk/platform-tools:/home/developer/Android/Sdk/tools:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin')
INFO: -> directory context /home/developer/.local/share/python-for-android/build/other_builds/android-genericndkbuild-python2-python2/armeabi-v7a/android
[DEBUG]: -> running python.host -c import sys; print(sys.path)
[DEBUG]: ['', '/home/developer/.local/share/python-for-android/build/python-installs/unnamed_dist_2/lib/python27.zip', '/home/developer/.local/share/python-for-android/build/python-installs/unnamed_dist_2/lib/python2.7', '/home/developer/.local/share/python-for-android/build/python-installs/unnamed_dist_2/lib/python2.7/plat-linux4', '/home/developer/.local/share/python-for-android/build/python-installs/unnamed_dist_2/lib/python2.7/lib-tk', '/home/developer/.local/share/python-for-android/build/python-installs/unnamed_dist_2/lib/python2.7/lib-old', '/home/developer/.local/share/python-for-android/build/python-installs/unnamed_dist_2/lib/python2.7/lib-dynload', '/home/developer/.local/lib/python2.7/site-packages', '/home/developer/.local/share/python-for-android/build/python-installs/unnamed_dist_2/lib/python2.7/site-packages']
('cwd is', '/home/developer/.local/share/python-for-android/build/other_builds/android-genericndkbuild-python2-python2/armeabi-v7a/android')
INFO: Trying first build of android to get cython files: this is expected to fail
[DEBUG]: -> running python.host setup.py build_ext -v
[DEBUG]: Traceback (most recent call last):
[DEBUG]: File "setup.py", line 9, in
[DEBUG]: sdl_libs = lib_dict[os.environ['BOOTSTRAP']]
[DEBUG]: KeyError: 'webview'
Exception in thread background thread for pid 15888:
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
self.run()
File "/usr/lib/python2.7/threading.py", line 754, in run
self.__target(*self.__args, **self.__kwargs)
File "/usr/local/lib/python2.7/dist-packages/sh.py", line 2144, in background_thread
handle_exit_code(exit_code)
File "/usr/local/lib/python2.7/dist-packages/sh.py", line 1906, in fn
return self.command.handle_command_exit_code(exit_code)
File "/usr/local/lib/python2.7/dist-packages/sh.py", line 667, in handle_command_exit_code
raise exc
ErrorReturnCode_1:

RAN: /home/developer/.local/share/python-for-android/build/python-installs/unnamed_dist_2/bin/python.host setup.py build_ext -v

STDOUT:
Traceback (most recent call last):
File "setup.py", line 9, in
sdl_libs = lib_dict[os.environ['BOOTSTRAP']]
KeyError: 'webview'

STDERR:

()
INFO: android first build failed (as expected)
INFO: Running cython where appropriate
INFO: Cythonize android/_android_sound.pyx
[DEBUG]: -> running cython ./android/_android_sound.pyx
INFO: Cythonize android/_android.pyx
[DEBUG]: -> running cython ./android/_android.pyx
INFO: Cythonize android/_android_billing.pyx
[DEBUG]: -> running cython ./android/_android_billing.pyx
[DEBUG]: -> running python.host setup.py build_ext -v
[DEBUG]: Traceback (most recent call last):
[DEBUG]: File "setup.py", line 9, in
[DEBUG]: sdl_libs = lib_dict[os.environ['BOOTSTRAP']]
[DEBUG]: KeyError: 'webview'
Exception in thread background thread for pid 15922:
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
self.run()
File "/usr/lib/python2.7/threading.py", line 754, in run
self.__target(*self.__args, **self.__kwargs)
File "/usr/local/lib/python2.7/dist-packages/sh.py", line 2144, in background_thread
handle_exit_code(exit_code)
File "/usr/local/lib/python2.7/dist-packages/sh.py", line 1906, in fn
return self.command.handle_command_exit_code(exit_code)
File "/usr/local/lib/python2.7/dist-packages/sh.py", line 667, in handle_command_exit_code
raise exc
ErrorReturnCode_1:

RAN: /home/developer/.local/share/python-for-android/build/python-installs/unnamed_dist_2/bin/python.host setup.py build_ext -v

STDOUT:
Traceback (most recent call last):
File "setup.py", line 9, in
sdl_libs = lib_dict[os.environ['BOOTSTRAP']]
KeyError: 'webview'

STDERR:

Traceback (most recent call last):
File "setup.py", line 9, in
sdl_libs = lib_dict[os.environ['BOOTSTRAP']]
KeyError: 'webview'
INFO: STDERR:

cd /home/developer/.local/share/python-for-android/build/other_builds/android-genericndkbuild-python2-python2/armeabi-v7a/android && /home/developer/.local/share/python-for-android/build/python-installs/unnamed_dist_2/bin/python.host setup.py build_ext -v

the second time i try to compile, it compiles without an error, so there might be the problem at building android

@inclement
Copy link
Member

I think this is currently working. The original error about size-zero files related to failing to load libpymodules.so, which was both fixed and is no longer an issue as we don't create that file any more.

Please make a new issue if you do experience the same issue again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants