Pyrebase icon indicating copy to clipboard operation
Pyrebase copied to clipboard

Error when used with kivy in an apk

Open avj-jpg opened this issue 4 years ago • 37 comments

So I am trying to use pyrebase in a kivy project. My apk keeps crashing. The errors are all regarding import of modules like gcloud, oauth2client, .... (it is a long list). I kept fixing them one by one by including these modules under 'requirements' in my buildozer.spec. This is what it looks right now:

requirements = python3,kivy==1.11.1,kivymd, pyjnius, pillow, android, kivmob, pyrebase, requests, gcloud, oauth2client, requests-toolbelt, python-jwt, pycrypto,pyasn1, pyasn1_modules, rsa, google-api-python-client, google-cloud, google-cloud-storage, protobuf

but my apk still crashes with the error: ModuleNotFoundError: No module named 'google.protobuf'

I have included protobuf in the requirements, but that is not helping. How do I fix this? Can you also give me a list of these dependencies that pyrebase requires?

avj-jpg avatar May 05 '20 10:05 avj-jpg

hey have you found a solution for that ?

Windsurfer0000 avatar Aug 11 '20 15:08 Windsurfer0000

Did you find a solution ?

daniel-iova avatar Sep 03 '20 20:09 daniel-iova

Has anyone found a solution

DafzNet avatar Sep 14 '20 19:09 DafzNet

I tried all day yesterday to solve this and think I have a solution, at least a temporary workaround:

the broken import can be found in ::project dir::/.buildozer/android/platform/build-arm64-v8a/build/python-installs/::app name::/gcloud/_helpers.py (or some variation of this path depending on your build) - you can get the exact path from the log.

edit the file (nano or subl whatever)

remove the import (around line 28) and also remove (or comment out) the function referencing google.protobuf (~ line 500):

def _datetime_to_pb_timestamp(when):
    """Convert a datetime object to a Timestamp protobuf.

    :type when: :class:`datetime.datetime`
    :param when: the datetime to convert

    :rtype: :class:`google.protobuf.timestamp_pb2.Timestamp`
    :returns: A timestamp protobuf corresponding to the object.
    """
    ms_value = _microseconds_from_datetime(when)
    seconds, micros = divmod(ms_value, 10**6)
    nanos = micros * 10**3
    return timestamp_pb2.Timestamp(seconds=seconds, nanos=nanos)

I tried changing the import to just protobuf but no luck :(

also had to add this to the code to my main.py when came up against an ssl error:

import ssl
ssl._create_default_https_context = ssl._create_unverified_context

Need to try and get to the bottom of why that was needed. Obviously it can't be ideal to just remove a method and I didn't have time to fully check if that method is used, but couldn't see if anything was obvious, but so far I can run my app and interact with Firebase storage without errors!

Oh yeah, a ton of extra requirements needed in buildozer.spec after getting past google.protobuf:

requirements = python3,kivy==2.0.0rc1,android,plyer,pyrebase5,cryptography,pycryptodome,python-jwt,jwcrypto,oauth2client,httplib2,pyasn1,pyasn1-modules,rsa,google-cloud,gcloud,google-auth,requests,requests-toolbelt,urllib3,chardet,idna,certifi,Pillow

Most of them relate to pyrebase.. the "pycryptodome" one is for missing module "Crypto". Always double check on pypi for the correct pip install instruction if unsure.

nihilok avatar Oct 17 '20 12:10 nihilok

Hey! Iam using firebase_admin in my project and had the same error. I did what nihilok did but then ran into google-auth error. Seems alot fo people have the same issue.

aidingh avatar Dec 02 '20 13:12 aidingh

@aidingh same here, i am also using firebase_admin and my app just crash from the start, if you got anything please mail me to----->[email protected]

aqulline avatar Dec 10 '20 09:12 aqulline

Hey! We were using Firebase_admin and Pyrebase and we actually did spend a whole week trying to get it to work. I actually checked the code for Pyrebase and took out the essential code from it and made email verification to work. I can tell you how if you want. To be frank we skipped Firestore database completly and went for a real time database. The real time database in Firebase that is. Its as good if you ask me and suits Python fine. If you need more help I can surely help you. But we did skip firestore with firebase_admin all togheter.

// Aidin


Från: aqulline [email protected] Skickat: den 10 december 2020 10:13 Till: thisbejim/Pyrebase [email protected] Kopia: aidingh [email protected]; Mention [email protected] Ämne: Re: [thisbejim/Pyrebase] Error when used with kivy in an apk (#344)

@aidinghhttps://github.com/aidingh same here, i am also using firebase_admin and my app just crash from the start, if you got anything please mail me to----->[email protected]mailto:[email protected]

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/thisbejim/Pyrebase/issues/344#issuecomment-742388633, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AEXAHH6PJQZHWWWBVIO6CSTSUCGLJANCNFSM4MZN573A.

aidingh avatar Dec 10 '20 11:12 aidingh

Hey! We were using Firebase_admin and Pyrebase and we actually did spend a whole week trying to get it to work. I actually checked the code for Pyrebase and took out the essential code from it and made email verification to work. I can tell you how if you want. To be frank we skipped Firestore database completly and went for a real time database. The real time database in Firebase that is. Its as good if you ask me and suits Python fine. If you need more help I can surely help you. But we did skip firestore with firebase_admin all togheter. // Aidin ________________________________ Från: aqulline [email protected] Skickat: den 10 december 2020 10:13 Till: thisbejim/Pyrebase [email protected] Kopia: aidingh [email protected]; Mention [email protected] Ämne: Re: [thisbejim/Pyrebase] Error when used with kivy in an apk (#344) @aidinghhttps://github.com/aidingh same here, i am also using firebase_admin and my app just crash from the start, if you got anything please mail me to----->[email protected]mailto:[email protected] — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub<#344 (comment)>, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AEXAHH6PJQZHWWWBVIO6CSTSUCGLJANCNFSM4MZN573A.

Hey, I am using Pyrebase (to connect to Firebase real time database) in my Kivy app. Everything is working fine on Desktop but the app crashes on Android. Could you please help me with this issue?

cmsharma avatar Dec 29 '20 13:12 cmsharma

Hey, I am using Pyrebase (to connect to Firebase real time database) in my Kivy app. Everything is working fine on Desktop but the app crashes on Android. Could you please help me with this issue?

Did you enable internet permissions in buildozer.spec?

nihilok avatar Dec 30 '20 15:12 nihilok

Yeah, Internet permission was enabled!

cmsharma avatar Dec 31 '20 19:12 cmsharma

i used all this requirements = python3,
kivy,
kivymd,
sdl2_ttf==2.0.15,
plyer,
requests,
idna,
certifi,
chardet,
urllib3,
firebase_admin,
google-cloud-storage,
google-api-python-client,
google-api-core,
google-cloud-firestore,
cachecontrol,
msgpack,
google-auth,
protobuf,
pytz,
googleapis-common-protos,
grpcio,
httplib2,
uritemplate,
google-auth-httplib2,
rsa,
cachetools,
pyasn1-modules,
proto-plus,
google-cloud-core,
google-resumable-media,
google-crc32c,
cffi,
pycparser,
pyasn1

(list) Permissions

android.permissions = INTERNET

but still get error

03-18 14:43:35.632 1751 17252 I python : ReferenceError: weakly-referenced object no longer exists

WithSJ avatar Mar 18 '21 09:03 WithSJ

Problems when using pyrebase with kivy:

I have two theories: 1 - Or these imports are wrong: a) from pyrebase import pyrebase b) import pyrebase

I tested both and it only works on the computer.

2 - Or my requirement is incorrect regarding the pyrebase: requirements = python3, kivy == 2.0.0, https: //github.com/kivymd/KivyMD/archive/master.zip,pygments,sdl2_ttf==2.0.15,pillow, requests, certifi, urllib3, chardet, idna, plyer, peewee, pyrebase

Note: Without pyrebase and commenting on the functions I use pyrebase the system works.

CoutinhoElias avatar May 12 '21 14:05 CoutinhoElias

Hello, I have also been trying to make a login system for my application , it seems like many are in the same boat as me , it works fine for me on pc but was not able to make a apk with it , it keeps asking for more and more modules . Did anyone implement a working login system in kivy with reset password ? Any other solutions other than firebase?

requirements = hostpython3==3.7.9,python3==3.7.9,kivy,kivymd,pyrebase,requests,urllib3,chardet,idna,gcloud,oauth2client,requests-toolbelt,protobuf_cpp,python-jwt,pycryptodome,httplib2,pyparsing,pyasn1,pyasn1_modules,rsa,jwcrypto,cryptography,firebase_admin

deprecated, wrapt ( could be requeired by jwcrypto)

here is a Doc which explains what requirements would be needed

https://github.com/RobertFlatt/Android-for-Python/tree/main/Android-for-Python-Users#requirements

Arjun-nemani avatar May 26 '21 15:05 Arjun-nemani

https://github.com/RobertFlatt/Android-for-Python/tree/main/Android-for-Python-Users#requirements

CoutinhoElias avatar May 31 '21 17:05 CoutinhoElias

Ok this worked for me for both pyrebase and firebase admin the missing of this Google files though we have list them in the requirements so what I did I went in my environment and I found out that this Google file when we install them they create a file name Google so the save there things there so I went in my .buildozer/Android/platform/build-armeabi-v7a/build/python-installs. And I found the same folder named Google so what I did I deleted that folder and copy my folder from my environment in sitepackages and I pasted there and run buildozer and boom! It worked so try I am 💯 sure it will work

On Mon, May 31, 2021, 20:26 Elias Coutinho @.***> wrote:

https://github.com/RobertFlatt/Android-for-Python/tree/main/Android-for-Python-Users#requirements

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/thisbejim/Pyrebase/issues/344#issuecomment-851607709, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOCDO5HMRY77476A6HUC62LTQPBDLANCNFSM4MZN573A .

aqulline avatar May 31 '21 19:05 aqulline

Hello, I have also been trying to make a login system for my application , it seems like many are in the same boat as me , it works fine for me on pc but was not able to make a apk with it , it keeps asking for more and more modules . Did anyone implement a working login system in kivy with reset password ? Any other solutions other than firebase?

requirements = hostpython3==3.7.9,python3==3.7.9,kivy,kivymd,pyrebase,requests,urllib3,chardet,idna,gcloud,oauth2client,requests-toolbelt,protobuf_cpp,python-jwt,pycryptodome,httplib2,pyparsing,pyasn1,pyasn1_modules,rsa,jwcrypto,cryptography,firebase_admin

deprecated, wrapt ( could be requeired by jwcrypto)

here is a Doc which explains what requirements would be needed

https://github.com/RobertFlatt/Android-for-Python/tree/main/Android-for-Python-Users#requirements

this woking for me

python3==3.8.5,kivy==2.0.0rc4, kivymd==0.104.1,pyrebase,requests==2.21.0, urllib3, chardet, certifi, idna,gcloud,, oauth2client, requests-toolbelt, protobuf_cpp, python-jwt, pycryptodome, httplib2, pyparsing, pyasn1, pyasn1_modules, rsa,jwcrypto==0.8

cristianmejiaarias avatar Jun 02 '21 22:06 cristianmejiaarias

Ok this worked for me for both pyrebase and firebase admin the missing of this Google files though we have list them in the requirements so what I did I went in my environment and I found out that this Google file when we install them they create a file name Google so the save there things there so I went in my .buildozer/Android/platform/build-armeabi-v7a/build/python-installs. And I found the same folder named Google so what I did I deleted that folder and copy my folder from my environment in sitepackages and I pasted there and run buildozer and boom! It worked so try I am 💯 sure it will work

this woking for me

python3==3.8.5,kivy==2.0.0rc4, kivymd==0.104.1,pyrebase,requests==2.21.0, urllib3, chardet, certifi, idna,gcloud,, oauth2client, requests-toolbelt, protobuf_cpp, python-jwt, pycryptodome, httplib2, pyparsing, pyasn1, pyasn1_modules, rsa,jwcrypto==0.8

cristianmejiaarias avatar Jun 02 '21 22:06 cristianmejiaarias

requirements = python3,kivy,kivymd==0.104.1,requests==2.25.1,Pillow==8.2.0,CacheControl,cachetools,certifi,cffi,chardet,google-auth-httplib2,google-cloud-core,google-cloud-firestore,google-crc32c,google-resumable-media,googleapis-common-protos,grpcio,httplib2,idna,jws,msgpack,oauth2client,packaging,pytz,requests-toolbelt,rsa,uritemplate,proto-plus,protobuf,pyasn1,pyasn1-modules,pycparser,pycryptodome,jwt,pyparsing,firebase_admin,google-auth,google-api-python-client,google-cloud,google-cloud-storage,google,google-api-core,pyrebase,urllib3,jnius,android,pyOpenSSL

This requirement.txt works for me . You can try this to solve the issue. Sorry for my bad english

anupamkayal avatar Jun 15 '21 09:06 anupamkayal

Explícame en español.

Te puedo ayudar cundo gustes.

Bendiciones

Sent from my iPhone

On 15 Jun 2021, at 3:26 AM, anupamkayal @.***> wrote:

 requirements = python3,kivy,kivymd==0.104.1,requests==2.25.1,Pillow==8.2.0,CacheControl,cachetools,certifi,cffi,chardet,google-auth-httplib2,google-cloud-core,google-cloud-firestore,google-crc32c,google-resumable-media,googleapis-common-protos,grpcio,httplib2,idna,jws,msgpack,oauth2client,packaging,pytz,requests-toolbelt,rsa,uritemplate,proto-plus,protobuf,pyasn1,pyasn1-modules,pycparser,pycryptodome,jwt,pyparsing,firebase_admin,google-auth,google-api-python-client,google-cloud,google-cloud-storage,google,google-api-core,pyrebase,urllib3,jnius,android,pyOpenSSL

This requirement.txt works for me . You can try this to solve the issue. Sorry for my bad english

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

cristianmejiaarias avatar Jun 15 '21 12:06 cristianmejiaarias

None of the above requirements suits for me. I can't find the full requirements list to make pyrebase work on an .APK and adding the packages by searching recursively as the python-for-android github suggests seems extremely painful. Even their solution, which can be found here https://github.com/Android-for-Python/Android-for-Python-Users#requirements, don't work. The app crashes immediately, as if a package is missing in the requirements.

Does anyone found a working requirements list for pyrebase already?

felipegerhardt avatar Aug 07 '21 16:08 felipegerhardt

After several days working on it, this requirements list didn't make my app crash:

requirements = python3,kivy==2.0.0,kivymd==0.104.1,mapview,pyrebase,geocoder,email-validator,requests,urllib3,chardet,idna,ratelim,decorator,click,dnspython,pillow,oauth2client,httplib2,pyparsing,pyasn1,pyasn1_modules,virtualenv,six,sh,rsa,requests-toolbelt,python-jwt,pygments,pycryptodome,ptyprocess,protobuf,platformdirs,pexpect,kivy-garden.mapview,kivy-garden,jws,googleapis-common-protos,gcloud,future,filelock,docutils,distlib,backports.entry-points-selectable,jwcrypto,cryptography,Deprecated,wrapt

felipegerhardt avatar Aug 12 '21 01:08 felipegerhardt

I got it too.

CoutinhoElias avatar Oct 10 '21 01:10 CoutinhoElias

The problem is that you need to locate the path of which the downloaded required libraries are and see if they are there

On Sun, Oct 10, 2021, 04:16 Elias Coutinho @.***> wrote:

I got it too.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/thisbejim/Pyrebase/issues/344#issuecomment-939386354, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOCDO5AGYFDWV24I3CC2LKLUGDSNDANCNFSM4MZN573A . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

aqulline avatar Oct 13 '21 18:10 aqulline

After several days working on it, this requirements list didn't make my app crash:

requirements = python3,kivy==2.0.0,kivymd==0.104.1,mapview,pyrebase,geocoder,email-validator,requests,urllib3,chardet,idna,ratelim,decorator,click,dnspython,pillow,oauth2client,httplib2,pyparsing,pyasn1,pyasn1_modules,virtualenv,six,sh,rsa,requests-toolbelt,python-jwt,pygments,pycryptodome,ptyprocess,protobuf,platformdirs,pexpect,kivy-garden.mapview,kivy-garden,jws,googleapis-common-protos,gcloud,future,filelock,docutils,distlib,backports.entry-points-selectable,jwcrypto,cryptography,Deprecated,wrapt

You're a genius! Thank you so much, it worked for me too!!!

AlejandroPG10 avatar Apr 16 '23 13:04 AlejandroPG10

After several days working on it, this requirements list didn't make my app crash:

requirements = python3,kivy==2.0.0,kivymd==0.104.1,mapview,pyrebase,geocoder,email-validator,requests,urllib3,chardet,idna,ratelim,decorator,click,dnspython,pillow,oauth2client,httplib2,pyparsing,pyasn1,pyasn1_modules,virtualenv,six,sh,rsa,requests-toolbelt,python-jwt,pygments,pycryptodome,ptyprocess,protobuf,platformdirs,pexpect,kivy-garden.mapview,kivy-garden,jws,googleapis-common-protos,gcloud,future,filelock,docutils,distlib,backports.entry-points-selectable,jwcrypto,cryptography,Deprecated,wrapt

This was actually working before. Nowdays the bulldozer fails if pycryptodome and cryptography are included. If you exclude them, the resulting APK also crashes since these two are necessary. Has anyone found a solution to this?

Alexndegwa avatar Jul 25 '23 11:07 Alexndegwa

bros i really need the help firebase is not working with all requierments keep crashing on my phone

Zeikov avatar Sep 27 '23 19:09 Zeikov

Sure, i would like to help you. Can we have little meeting if you wan Sent from my iPhoneOn Sep 27, 2023, at 1:02 PM, Zeikov @.***> wrote: bros i really need the help firebase is not working with all requierments keep crashing on my phone

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: @.***>

cristianmejiaarias avatar Sep 27 '23 19:09 cristianmejiaarias

Sure, i would like to help you. Can we have little meeting if you wan Sent from my iPhoneOn Sep 27, 2023, at 1:02 PM, Zeikov @.> wrote: bros i really need the help firebase is not working with all requierments keep crashing on my phone —Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: @.>

I will love that do u speak spanish ? wherever u can bro

Zeikov avatar Sep 27 '23 20:09 Zeikov

should i use a older version of pyrebase ? Maybe it will work idk iam trying evrything

Zeikov avatar Sep 27 '23 21:09 Zeikov

Si hablo español hermano. Podemos revisar tu spec y las librerías que estas usando en tu proyecto. Tengo algunas app funcionando sin ningún problema. Tu me avisas.Sent from my iPhoneOn Sep 27, 2023, at 2:57 PM, Zeikov @.***> wrote:

Sure, i would like to help you. Can we have little meeting if you wan Sent from my iPhoneOn Sep 27, 2023, at 1:02 PM, Zeikov @.> wrote: bros i really need the help firebase is not working with all requierments keep crashing on my phone —Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: @.>

I will love that do u speak spanish ? wherever u can bro

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: @.***>

cristianmejiaarias avatar Sep 27 '23 23:09 cristianmejiaarias