kivy / python-for-android

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

[Temporary Resolved] Python 4 android in mac os with Apple Silicon via Roseta #2528

Closed jhay06 closed 2 years ago

jhay06 commented 2 years ago

Hi , Any one here managed to build apk successfully on mac device with Apple silicon cpu via Rosetta?

I did all i can but building in P4a or buildozer has the same error ,

it always fails on import binascii, symbol not found _crc32

Device: Macbook Air OS: Big Sur

Please see attached image Snip20211206_1

misl6 commented 2 years ago

@jhay06 in your requirements can you try to force hostpython3==3.9.9, python3==3.9.9 ?

jhay06 commented 2 years ago

@jhay06 in your requirements can you try to force hostpython3==3.9.9, python3==3.9.9 ?

thanks for the response , By the way i have another issue , i have to blacklist libffi because there's an issue on its automake version , i have automake 1.6.5 but libffi failed to compile because it was created using automake 1.6.3 image

so i have to run this p4a command and do your suggested resolution p4a apk --requirements=python3==3.9.9,hostpython3==3.9.9,kivy --bootstrap=sdl2 --sdk_dir ~/.buildozer/android/platform/android-sdk --android_api 27 --ndk_dir ~/.buildozer/android/platform/android-ndk-r19c --private . --name 'myapp' --package org.sample.app --version 0.1 --dist_name 'testapp' --blacklist-requirements=libffi

but has the same error , please see below

image

jhay06 commented 2 years ago

Okay i think i know the issue here, it is how hostpython3 built in macos ,using the p4a . when p4a run the hostpython3 building , the build architecture of hostpython3 is for linux that's why library files shown on the images above are in .so file which is standard library of a linux , this will not work on mac os device, because mac os uses dylib file not .so file,

so i have to create a temporary resolution for this ,

i have to go to /Users/cebx/.pyton-for-android/build/other_builds/hostpython3/desktop/hostpython3/native-build and remove python.exe , python3 files as well as Python folder and build folder there , then create a link of python and python3 from my python virtualenv folder , python = python.exe and python3 = python3 then re run the p4a, and it works

this is just a temporary solution i made , hope that this will fix on the next update of the python-for-android

,

also to resolve the libfi i have to remove automake , autoconf , libtool , pkgconfig that was installed using homebrew and replace it using macports ,

jhay06 commented 2 years ago

would like to ask if i can join as contributor to this project , will try to contribute maybe i can create a permanent fix for this issue.

misl6 commented 2 years ago

Fixed via #2586, feel free to re-open the issue if you're still encountering it on the develop branch.