英文:
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 "/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 builder.spec file
> > \[app\]
> # (str) Title of your application
title = HOVEN SALES
> # (str) Package name
package.name = sales
> # (str) Package domain (needed for android/ios packaging)
package.domain = hoven.admin
> # (str) Source code where the main.py live
source.dir = .
> # (list) Source files to include (let empty to include all the files)
source.include_exts = py,png,jpg,kv,atlas,json
> # (list) List of inclusions using pattern matching
> \#source.include_patterns = assets/*,images/*.png
> # (list) Source files to exclude (let empty to not exclude anything)
> \#source.exclude_exts = spec
> # (list) List of directory to exclude (let empty to not exclude anything)
> \#source.exclude_dirs = tests, bin, venv
> # (list) List of exclusions using pattern matching
Do not prefix with './'
> \#source.exclude_patterns = license,images/*/*.jpg
> # (str) Application versioning (method 1)
version = 0.1
> # (str) Application versioning (method 2)
version.regex = __version__ = \['"\](.\*)\['"\]
version.filename = %(source.dir)s/main.py
> # (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
> # (str) Custom source folders for requirements
Sets custom source for any requirements with recipes
requirements.source.kivy = ../../kivy
> # (str) Presplash of the application
> \#presplash.filename = %(source.dir)s/data/presplash.png
> # (str) Icon of the application
> \#icon.filename = %(source.dir)s/data/icon.png
> # (list) Supported orientations
Valid options are: landscape, portrait, portrait-reverse or landscape-reverse
orientation = portrait
> # (list) List of service to declare
> \#services = NAME:ENTRYPOINT_TO_PY,NAME2:ENTRYPOINT2_TO_PY
OSX Specific
author = © 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
> # (bool) Indicate if the application should be fullscreen or not
fullscreen = 0
> # (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.
> \#android.presplash_color = #FFFFFF
> # (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.
> \#android.presplash_lottie = "path/to/lottie/file.json"
> # (str) Adaptive icon of the application (used if Android API level is 26+ at runtime)
> \#icon.adaptive_foreground.filename = %(source.dir)s/data/icon_fg.png
> \#icon.adaptive_background.filename = %(source.dir)s/data/icon_bg.png
> # (list) Permissions
> # (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
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论