I run into errors when i try to build an apk. The errors occur during the compilation of netifaces. without including netifaces as a requirement in buildozer.spec file the apk build process goes to completion, which confirms that the error is as a result of compling netifaces.
Command:
```buildozer android debug
Spec file:
Requirement from buildozer.spec file
requirements = python2,kivy==master,git+https://gitlab.com/kivymd/KivyMD.git,netifaces
### Logs
working: error: command 'arm-linux-androideabi-gcc' failed with exit status 1 Exception in thread background thread for pid 8512:
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 2170, in background_thread
handle_exit_code(exit_code)
File "/usr/local/lib/python2.7/dist-packages/sh.py", line 1929, in fn
return self.command.handle_command_exit_code(exit_code)
File "/usr/local/lib/python2.7/dist-packages/sh.py", line 672, in handle_command_exit_code
raise exc
ErrorReturnCode_1:
RAN: /home/kivy/.buildozer/android/platform/build/build/other_builds/hostpython2/desktop/hostpython2/hostpython setup.py build_ext -v
STDOUT:
running build_ext
checking for getifaddrs...not found. (cached)
checking for getnameinfo...not found. (cached)
checking for socket IOCTLs...not found. (cached)
checking for optional header files...netpacket/packet.h linux/atm.h. (cached)
checking whether struct sockaddr has a length field...no. (cached)
checking which sockaddr_xxx structs are defined...none! (cached)
checking for routing socket support...no. (cached)
checking for sysctl(CTL_NET...) support...no. (cached)
checking for netlink support...no. (cached)
building 'netifaces' extension
arm-linux-androideabi-gcc -DANDROID -mandroid -fomit-frame-pointer -D__ANDROID_API__=19 -I/home/kivy/.buildozer/android/platform/android-ndk-r9c/platforms/android-19/arch-arm -isysroot /home/kivy/.buildozer/android/platform/android-ndk-r9c/platforms/android-19/arch-arm -I/home/kivy/.buildozer/android/platform/build/build/python-installs/touchpadapp/include/python2.7 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -DANDROID -mandroid -fomit-frame-pointer -D__ANDROID_API__=19 -I/home/kivy/.buildozer/android/platform/android-ndk-r9c/platforms/android-19/arch-arm -isysroot /home/kivy/.buildozer/android/platform/android-ndk-r9c/platforms/android-19/arch-arm -I/home/kivy/.buildozer/android/platform/build/build/python-installs/touchpadapp/include/python2.7 -march=armv7-a -mfloat-abi=softfp -mfpu=vfp -mthumb -I/home/kivy/.buildozer/android/platform/build/build/python-installs/touchpadapp/include/python2.7 -fPIC -DNETIFACES_VERSION=0.10.4 -DHAVE_NETPACKET_PACKET_H=1 -DHAVE_LINUX_ATM_H=1 -I/home/kivy/.buildozer/android/platform/build/build/other_builds/hostpython2/desktop/hostpython2/Include -I/home/kivy/.buildozer/android/platform/build/build/other_builds/hostpython2/desktop/hostpython2 -c netifaces.c -o build/temp.linux-x86_64-2.7/netifaces.o
netifaces.c:185:6: error: #error You need to add code for your platform.
# error You need to add code for your platform.
^
netifaces.c: In function 'gateways':
netifaces.c:1213:22: warning: unused variable 'defaults' [-Wunused-variable]
PyObject *result, *defaults;
^
netifaces.c: At top level:
netifaces.c:316:1: warning: 'string_from_sockaddr' defined but not used [-Wunused-function]
string_from_sockaddr (struct sockaddr *addr,
^
netifaces.c:446:1: warning: 'add_to_family' defined but not used [-Wunused-function]
add_to_family (PyObject *result, int family, PyObject *obj)
^
error: command 'arm-linux-androideabi-gcc' failed with exit status 1
STDERR:
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/kivy/.buildozer/android/platform/python-for-android-new-toolchain/pythonforandroid/toolchain.py", line 978, in
main()
File "/home/kivy/.buildozer/android/platform/python-for-android-new-toolchain/pythonforandroid/toolchain.py", line 975, in main
ToolchainCL()
File "/home/kivy/.buildozer/android/platform/python-for-android-new-toolchain/pythonforandroid/toolchain.py", line 512, in __init__
getattr(self, args.subparser_name.replace('-', '_'))(args)
File "/home/kivy/.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/kivy/.buildozer/android/platform/python-for-android-new-toolchain/pythonforandroid/toolchain.py", line 193, in build_dist_from_args
build_recipes(build_order, python_modules, ctx)
File "pythonforandroid/build.py", line 573, in build_recipes
File "pythonforandroid/recipe.py", line 843, in build_arch
File "pythonforandroid/recipe.py", line 855, in build_compiled_components
File "pythonforandroid/logger.py", line 175, in shprint
File "/usr/local/lib/python2.7/dist-packages/sh.py", line 720, in next
self.wait()
File "/usr/local/lib/python2.7/dist-packages/sh.py", line 651, in wait
self.handle_command_exit_code(exit_code)
File "/usr/local/lib/python2.7/dist-packages/sh.py", line 672, in handle_command_exit_code
raise exc
sh.ErrorReturnCode_1:
RAN: /home/kivy/.buildozer/android/platform/build/build/other_builds/hostpython2/desktop/hostpython2/hostpython setup.py build_ext -v
STDOUT:
running build_ext
checking for getifaddrs...not found. (cached)
checking for getnameinfo...not found. (cached)
checking for socket IOCTLs...not found. (cached)
checking for optional header files...netpacket/packet.h linux/atm.h. (cached)
checking whether struct sockaddr has a length field...no. (cached)
checking which sockaddr_xxx structs are defined...none! (cached)
checking for routing socket support...no. (cached)
checking for sysctl(CTL_NET...) support...no. (cached)
checking for netlink support...no. (cached)
building 'netifaces' extension
arm-linux-androideabi-gcc -DANDROID -mandroid -fomit-frame-pointer -D__ANDROID_API__=19 -I/home/kivy/.buildozer/android/platform/android-ndk-r9c/platforms/android-19/arch-arm -isysroot /home/kivy/.buildozer/android/platform/android-ndk-r9c/platforms/android-19/arch-arm -I/home/kivy/.buildozer/android/platform/build/build/python-installs/touchpadapp/include/python2.7 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -DANDROID -mandroid -fomit-frame-pointer -D__ANDROID_API__=19 -I/home/kivy/.buildozer/android/platform/android-ndk-r9c/platforms/android-19/arch-arm -isysroot /home/kivy/.buildozer/android/platform/android-ndk-r9c/platforms/android-19/arch-arm -I/home/kivy/.buildozer/android/platform/build/build/python-installs/touchpadapp/include/python2.7 -march=armv7-a -mfloat-abi=softfp -mfpu=vfp -mthumb -I/home/kivy/.buildozer/android/platform/build/build/python-installs/touchpadapp/include/python2.7 -fPIC -DNETIFACES_VERSION=0.10.4 -DHAVE_NETPACKET_PACKET_H=1 -DHAVE_LINUX_ATM_H=1 -I/home/kivy/.buildozer/android/platform/build/build/other_builds/hostpython2/desktop/hostpython2/Include -I/home/kivy/.buildozer/android/platform/build/build/other_builds/hostpython2/desktop/hostpython2 -c netifaces.c -o build/temp.linux-x86_64-2.7/netifaces.o
netifaces.c:185:6: error: #error You need to add code for your platform.
# error You need to add code for your platform.
^
netifaces.c: In function 'gateways':
netifaces.c:1213:22: warning: unused variable 'defaults' [-Wunused-variable]
PyObject *result, *defaults;
^
netifaces.c: At top level:
netifaces.c:316:1: warning: 'string_from_sockaddr' defined but not used [-Wunused-function]
string_from_sockaddr (struct sockaddr *addr,
^
netifaces.c:446:1: warning: 'add_to_family' defined but not used [-Wunused-function]
add_to_family (PyObject *result, int family, PyObject *obj)
^
error: command 'arm-linux-androideabi-gcc' failed with exit status 1
STDERR:
```
Yes netifaces recipe seems pretty unmaintaned, last commit is from summer 2016 96edc06.
It's even disabled in Travis: https://github.com/kivy/python-for-android/blob/5f66527/ci/constants.py#L40
So contributions to fix it are welcome :smile:
http://srujansv-blog.tumblr.com/post/125383612642/fixing-netifaces-error-you-need-to-add-code-for
We should fix netifaces or just remove the recipe. If the project is really not active any more, probably the latter.
oh my! I would prefer we fix it please. that's the only library i know of that i can use to get the IP address from an android device. Using netifaces on PyDroid, does exactly what i want. PyDroid is a python interpreter for android devices.
We still accept pull request contributions @princeIta :smile:
@AndreMiras, I think that netifaces should work now, at least the compilation issues should be gone, it was fixed in here: https://github.com/kivy/python-for-android/pull/1549
@princeIta, please, can you check again if netifaces works for you and close this issue if that it's the case? I just made a build with netifaces and python2 without problems...
Note: be aware that you need to change your android's ndk to version r17c...also you should check the following variables in your buildozer.spec file:
android.api = 28
android.minapi = 21
I see that your minapi is set to 19, and that was for the old python recipe...now we use 21 (that it's important because otherwise you will not be able to successfully build the python recipe).
Thanks @opacam I confirm I could build it in Docker with the following command:
python setup_testapp_python3.py apk --sdk-dir $ANDROID_SDK_HOME --ndk-dir $ANDROID_NDK_HOME --requirements python3,kivy,netifaces
I'm not sure why it's still in the the ci/constants.py however. I'll check if it builds in Travis and PR
Proof it's building in https://api.travis-ci.org/v3/job/488531781/log.txt via https://github.com/kivy/python-for-android/pull/1675