Firebase-admin causing 'ModuleNotFoundError: No module named'google.auth'' in Kivy/KivyMD-built Android app: how to solve it?

huangapple go评论64阅读模式
英文:

Firebase-admin causing 'ModuleNotFoundError: No module named'google.auth'' in Kivy/KivyMD-built Android app: how to solve it?

问题

I am trying to build an Android app using Kivy and KivyMD. After building it, the Android app is getting stopped. I saw the log using adb logcat. It says "ModuleNotFoundError: No module named 'google.auth'". I have added all dependencies in builder.spec. I have allowed internet permission in build.spec.

05-21 23:14:59.966 26831 27378 I python  :  Traceback (most recent call last):
05-21 23:14:59.966 26831 27378 I python  :    File "/home/rakshak/hoven/.buildozer/android/app/main.py", line 5, in <module>
05-21 23:14:59.966 26831 27378 I python  :    File "/home/rakshak/hoven/.buildozer/android/platform/build-arm64-v8a_armeabi-v7a/build/python-installs/sales/arm64-v8a/firebase_admin/__init__.py", line 21, in <module>
05-21 23:14:59.966 26831 27378 I python  :    File "/home/rakshak/hoven/.buildozer/android/platform/build-arm64-v8a_armeabi-v7a/build/python-installs/sales/arm64-v8a/firebase_admin/credentials.py", line 20, in <module>
05-21 23:14:59.966 26831 27378 I python  :  ModuleNotFoundError: No module named 'google.auth'
05-21 23:14:59.966 26831 27378 I python  : Python for android ended.

Here is the code:

import kivy
from kivy.app import App
from kivymd.uix.gridlayout import GridLayout
from kivymd.uix.floatlayout import FloatLayout
import firebase_admin
from firebase_admin import credentials
from firebase_admin import db
#import re
import datetime as dt
from kivy.properties import StringProperty
from kivymd.uix.pickers import MDDatePicker
from kivymd.app import MDApp
from kivy.metrics import dp,Metrics
from kivymd.uix.dialog import MDDialog
from kivymd.uix.button import MDFlatButton
from kivymd.uix.button import MDRaisedButton
from kivy.logger import Logger
from kivy.utils import platform

Here is the builder.spec file:

[app]
title = HOVEN SALES
package.name = sales
package.domain = hoven.admin
source.dir = .
source.include_exts = py,png,jpg,kv,atlas,json
version = 0.1
version.regex = __version__ = '(.*)'
version.filename = %(source.dir)s/main.py
requirements = python3,kivy,kivymd,google,firebase_admin,google.auth,requests,openssl,urllib3,chardet,idna,jwt,cryptography,pyparsing,firebase_admin,PIL,google-auth,cachetools,pyasn1,pyasn1_modules,rsa,google-api-python-client,google-cloud-storage,google-cloud-firestore,google-api-core,protobuf,cachecontrol,gcloud,google-cloud,httplib2,cachecontrol,msgpack,requests,certifi,chardet,idna,urllib3,google-api-core,google-auth,cachetools,pyasn1-modules,pyasn1,rsa,pyasn1,googleapis-common-protos,protobuf,google-api-python-client,google-auth-httplib2,httplib2,pyparsing,uritemplate,google-cloud-firestore,google-cloud-core,proto-plus,google-cloud-storage,google-resumable-media,google-crc32c
requirements.source.kivy = ../../kivy
orientation = portrait
android.permissions = android.permissions.INTERNET

Is there anything specific you would like me to do with this information?

英文:

I am trying to build an adnroid app using Kivy and KivyMD. After building it. Android app is getting stopped. I saw the log using adb logcat. it says "ModuleNotFoundError: No module named 'google.auth'". I have added all dependency in builder.spec. I have allowed internet permission in build.spec.

05-21 23:14:59.966 26831 27378 I python  :  Traceback (most recent call last):
05-21 23:14:59.966 26831 27378 I python  :    File &quot;/home/rakshak/hoven/.buildozer/android/app/main.py&quot;, line 5, in \&lt;module\&gt;
05-21 23:14:59.966 26831 27378 I python  :    File &quot;/home/rakshak/hoven/.buildozer/android/platform/build-arm64-v8a_armeabi-v7a/build/python-installs/sales/arm64-v8a/firebase_admin/__init__.py&quot;, line 21, in \&lt;module\&gt;
05-21 23:14:59.966 26831 27378 I python  :    File &quot;/home/rakshak/hoven/.buildozer/android/platform/build-arm64-v8a_armeabi-v7a/build/python-installs/sales/arm64-v8a/firebase_admin/credentials.py&quot;, line 20, in \&lt;module\&gt;
05-21 23:14:59.966 26831 27378 I python  :  ModuleNotFoundError: No module named &#39;google.auth&#39;
05-21 23:14:59.966 26831 27378 I python  : Python for android ended.

here is the code

import kivy
from kivy.app import App
from kivymd.uix.gridlayout import GridLayout
from kivymd.uix.floatlayout import FloatLayout
import firebase_admin
from firebase_admin import credentials
from firebase_admin import db
#import re
import datetime as dt
from kivy.properties import StringProperty
from kivymd.uix.pickers import MDDatePicker
from kivymd.app import MDApp
from kivy.metrics import dp,Metrics
from kivymd.uix.dialog import MDDialog
from kivymd.uix.button import MDFlatButton
from kivymd.uix.button import MDRaisedButton
from kivy.logger import Logger
from kivy.utils import platform

here is builder.spec file

&gt; &gt; \[app\]

&gt; # (str) Title of your application

title = HOVEN SALES

&gt; # (str) Package name

package.name = sales

&gt; # (str) Package domain (needed for android/ios packaging)

package.domain = hoven.admin

&gt; # (str) Source code where the main.py live

source.dir = .

&gt; # (list) Source files to include (let empty to include all the files)

source.include_exts = py,png,jpg,kv,atlas,json

&gt; # (list) List of inclusions using pattern matching

&gt; \#source.include_patterns = assets/*,images/*.png

&gt; # (list) Source files to exclude (let empty to not exclude anything)

&gt; \#source.exclude_exts = spec

&gt; # (list) List of directory to exclude (let empty to not exclude anything)

&gt; \#source.exclude_dirs = tests, bin, venv

&gt; # (list) List of exclusions using pattern matching

Do not prefix with &#39;./&#39;

&gt; \#source.exclude_patterns = license,images/*/*.jpg

&gt; # (str) Application versioning (method 1)

version = 0.1

&gt; # (str) Application versioning (method 2)

version.regex = __version__ = \[&#39;&quot;\](.\*)\[&#39;&quot;\]

version.filename = %(source.dir)s/main.py

&gt; # (list) Application requirements

comma separated e.g. requirements = sqlite3,kivy

requirements = python3,kivy,kivymd,google,firebase_admin,google.auth,requests,openssl,urllib3,chardet,idna,jwt,cryptography,pyparsing,firebase_admin,PIL,google-auth,cachetools,pyasn1,pyasn1_modules,rsa,google-api-python-client,google-cloud-storage,google-cloud-firestore,google-api-core,protobuf,cachecontrol,gcloud,google-cloud,httplib2,cachecontrol,msgpack,requests,certifi,chardet,idna,urllib3,google-api-core,google-auth,cachetools,pyasn1-modules,pyasn1,rsa,pyasn1,googleapis-common-protos,protobuf,google-api-python-client,google-auth-httplib2,httplib2,pyparsing,uritemplate,google-cloud-firestore,google-cloud-core,proto-plus,google-cloud-storage,google-resumable-media,google-crc32c

&gt; # (str) Custom source folders for requirements

Sets custom source for any requirements with recipes

requirements.source.kivy = ../../kivy

&gt; # (str) Presplash of the application

&gt; \#presplash.filename = %(source.dir)s/data/presplash.png

&gt; # (str) Icon of the application

&gt; \#icon.filename = %(source.dir)s/data/icon.png

&gt; # (list) Supported orientations

Valid options are: landscape, portrait, portrait-reverse or landscape-reverse

orientation = portrait

&gt; # (list) List of service to declare

&gt; \#services = NAME:ENTRYPOINT_TO_PY,NAME2:ENTRYPOINT2_TO_PY



OSX Specific





author = &#169; Copyright Info

change the major version of python used by the app

osx.python_version = 3.10.6

Kivy version to use

osx.kivy_version = 2.2.0



Android specific



&gt; # (bool) Indicate if the application should be fullscreen or not

fullscreen = 0

&gt; # (string) Presplash background color (for android toolchain)

Supported formats are: #RRGGBB #AARRGGBB or one of the following names:

red, blue, green, black, white, gray, cyan, magenta, yellow, lightgray,

darkgray, grey, lightgrey, darkgrey, aqua, fuchsia, lime, maroon, navy,

olive, purple, silver, teal.

&gt; \#android.presplash_color = #FFFFFF

&gt; # (string) Presplash animation using Lottie format.

see https://lottiefiles.com/ for examples and https://airbnb.design/lottie/

for general documentation.

Lottie files can be created using various tools, like Adobe After Effect or Synfig.

&gt; \#android.presplash_lottie = &quot;path/to/lottie/file.json&quot;

&gt; # (str) Adaptive icon of the application (used if Android API level is 26+ at runtime)

&gt; \#icon.adaptive_foreground.filename = %(source.dir)s/data/icon_fg.png
&gt; \#icon.adaptive_background.filename = %(source.dir)s/data/icon_bg.png

&gt; # (list) Permissions

&gt; # (See https://python-for-android.readthedocs.io/en/latest/buildoptions/#build-options-1 for all the supported syntaxes and properties)

android.permissions = android.permissions.INTERNET

答案1

得分: 0

这是有效的解决方案:
我发现了谷歌模块,或者说像google.cloud、google.storage等模块,
都存储在一个名为google的文件中,你可以在你的环境中找到它
"env/../../site-packages/google"
所以我去了我的 .buildozer 文件夹的这个路径
.buildozer/android/platform/build-armeabi-v7a/build/python-installs/yummycom/google
yummycom 是我的项目名称,请忽略它

然后我将其与我的环境中的 google 文件夹进行了比较,然后只复制了其中的内容
并将其粘贴到那里,对我来说这样就可以正常工作了
因为当它进入该目录时,它们是丢失的,尽管你在要求中包含了它们
100% 工作了

英文:

2

Here is the solution that worked just fine:
I have found out that google modules are, or i can say module like
google.cloud, google.storage and etc

Are stored in a file named google you can navigate it in your environment
"env/../../site-packages/google"
So what i did i went in this path in my .buildozer folder
.buildozer/android/platform/build-armeabi-v7a/build/python-installs/yummycom/google
yummycom is my project name ignore it

So i compared it with my google folder in my env and i just copy whats in it
and i pasted there and it worked just fine for me
because when its goes in that directory they are missing though you include them in your requirement
100% WORKED

huangapple
  • 本文由 发表于 2023年5月22日 03:10:36
  • 转载请务必保留本文链接:https://go.coder-hub.com/76301512.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定