Buildozer: Kivy :How to ask for storage permission when app starts

Created on 20 Dec 2019  路  15Comments  路  Source: kivy/buildozer

I have built my app for android using kivy(buildozer)and it needs storage permission.So after installation of the app ,i have to everytime give permission manually by going to settings.How can i ask for storage permission when the app starts?

All 15 comments

You could do it with a runtime permission if I am not mistaken. On android you can simply do
from android.permissions import request_permissions, Permission request_permissions([Permission.READ_EXTERNAL_STORAGE, Permission.WRITE_EXTERNAL_STORAGE])

I tried that but the app crashes after asking for permission.
This is the error from logcat(something to do with whitelist):
2-20 14:34:22.027 9007 9007 I [SignBoard]SetupWizardStatus/u0: [SetupWizardStatus.java:96:isEnabled()-CoverServiceThread] isEnabled = false
12-20 14:34:22.031 2263 2263 I KeyboardViewUtil: systemKeyboardHeightRatio:1.000000; userKeyboardHeightRatio:1.000000.
12-20 14:34:22.032 2263 2263 I AndroidIME: PasswordIme.onActivate() : EditorInfo = Package = org.test.myapp : Type = Password : Learning = Disable : Suggestion = Hide : AutoCorrection = Disable : Microphone = Hide : NoPersonalizedLearning = Disable
12-20 14:34:22.037 22889 22923 E LocationManager: [LGNSS] Disable_PrivacyLocation_Information [tOperator : OPEN ] , [privacy_check : NA]
12-20 14:34:22.042 1911 2589 D LocationManagerService: getLastLocation: Request[ACCURACY_FINE gps requested=0 fastest=0 num=1] from com.google.android.apps.maps
12-20 14:34:22.045 1911 10677 D LocationManagerService: getLastLocation: Request[POWER_LOW network requested=0 fastest=0 num=1] from com.google.android.apps.maps
12-20 14:34:22.057 2263 2263 W KeyboardModeManager: setInputView() : inputView = com.google.android.apps.inputmethod.libs.framework.core.InputView{d54cdd7 V.E...... .......D 0,0-1080,1932}
12-20 14:34:22.058 2263 2263 I ConversationToQueryExte: Conv2Query not enabled due to current app [org.test.myapp] not in whitelist
12-20 14:34:22.059 2263 2263 I ConversationToQueryExte: onActivate() : Disabled by unsupported host app
12-20 14:34:22.060 2263 2263 I CurrentMicStatusHolder: Current Mic status = {MicIconHidden-PasswordOrNumberOrDateInputType,}
12-20 14:34:22.066 2263 22036 I FederatedC2QExtension: Already registered manifest.
12-20 14:34:22.066 2263 22036 I FederatedC2QExtension: model for en_IN/glowg_click_20190522 is not yet available
12-20 14:34:22.067 2263 22036 I FederatedC2QExtension: requesting model 'federated_conv2query_triggering_en_IN_glowg_click_20190522'
12-20 14:34:22.067 2263 22036 I FederatedC2QExtension: no valid model for inferencing found, switching to baseline.
12-20 14:34:22.070 2263 3324 I SP : Syncing federatedc2q (20190522) with slices: [], metadata: false
12-20 14:34:22.071 1911 1911 I NotificationServiceEx: LED remove() : mLights=-1|android|17040442|null|1000

Does anybody solved this yet?

As @MBM1607 said, you need this piece of code:

from android.permissions import request_permissions, Permission
request_permissions([Permission.READ_EXTERNAL_STORAGE, Permission.WRITE_EXTERNAL_STORAGE])

Plus you need to have the permission in your buildozer.spec file.

android.permissions = WRITE_EXTERNAL_STORAGE

Yes this works .Thankyou so much.All of you :)

The app crashes after asking for permission
Here is the logcat output:

01-20 20:23:18.534 1433 1819 I ActivityManager: Start proc 16676:com.google.android.packageinstaller/u0a22 for activity com.google.android.packageinstaller/com.android.packageinstaller.permission.ui.GrantPermissionsActivity caller=org.anoop.myapp
01-20 20:23:18.552 16676 16676 D TidaProvider: TidaProvider()
01-20 20:23:18.561 16676 16676 W ReflectionUtils:
01-20 20:23:18.561 16676 16676 W ReflectionUtils: java.lang.NoSuchMethodException: android.os.MessageQueue#enableMonitor()#bestmatch
01-20 20:23:18.561 16676 16676 W ReflectionUtils: at miui.util.ReflectionUtils.findMethodBestMatch(ReflectionUtils.java:338)
01-20 20:23:18.561 16676 16676 W ReflectionUtils: at miui.util.ReflectionUtils.findMethodBestMatch(ReflectionUtils.java:375)
01-20 20:23:18.561 16676 16676 W ReflectionUtils: at miui.util.ReflectionUtils.callMethod(ReflectionUtils.java:800)
01-20 20:23:18.561 16676 16676 W ReflectionUtils: at miui.util.ReflectionUtils.tryCallMethod(ReflectionUtils.java:818)
01-20 20:23:18.561 16676 16676 W ReflectionUtils: at android.os.BaseLooper.enableMonitor(BaseLooper.java:47)
01-20 20:23:18.561 16676 16676 W ReflectionUtils: at android.os.Looper.prepareMainLooper(Looper.java:112)
01-20 20:23:18.561 16676 16676 W ReflectionUtils: at android.app.ActivityThread.main(ActivityThread.java:6221)
01-20 20:23:18.561 16676 16676 W ReflectionUtils: at java.lang.reflect.Method.invoke(Native Method)
01-20 20:23:18.561 16676 16676 W ReflectionUtils: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:904)
01-20 20:23:18.561 16676 16676 W ReflectionUtils: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:794)
01-20 20:23:18.561 16676 16676 V BoostFramework: BoostFramework() : mPerf = com.qualcomm.qti.Performance@40f97ad
01-20 20:23:18.603 16676 16676 W System : ClassLoader referenced unknown path: /system/priv-app/GooglePackageInstaller/lib/arm64
01-20 20:23:18.611 16676 16676 W ResourceType: No package identifier when getting name for resource number 0x00000000
01-20 20:23:18.749 16676 16676 W ResourceType: No package identifier when getting name for resource number 0x00000000
01-20 20:23:18.769 16676 16676 W ResourceType: No package identifier when getting name for resource number 0x00000000
01-20 20:23:18.818 16676 16676 D AccessibilityManager: current package=com.google.android.packageinstaller, accessibility manager mIsFinalEnabled=false, mOptimizeEnabled=false, mIsUiAutomationEnabled=false, mIsInterestedPackage=false
01-20 20:23:18.824 16676 16676 V BoostFramework: BoostFramework() : mPerf = com.qualcomm.qti.Performance@d028eb
01-20 20:23:18.824 16676 16676 V BoostFramework: BoostFramework() : mPerf = com.qualcomm.qti.Performance@5db3648
01-20 20:23:18.990 16676 16692 I Adreno-EGL: : EGL 1.4 QUALCOMM build: Nondeterministic_AU_msm8937_64_LA.UM.5.5.R1__release_AU (I83a540a04a)
01-20 20:23:18.990 16676 16692 I Adreno-EGL: OpenGL ES Shader Compiler Version: XE031.09.00.04
01-20 20:23:30.229 16732 16732 I subsystem_ramdump: [arg3]: (1/0) 1: Enable qdss ramdump / 0: Disable qdss ramdump
01-20 20:23:30.230 16732 16732 E subsystem_ramdump: Directory /sdcard/ramdump does not exist
01-20 20:23:30.230 16732 16732 I subsystem_ramdump: Attemping to create /sdcard/ramdump
01-20 20:23:30.230 16732 16732 E subsystem_ramdump: Unable to create /sdcard/ramdump
01-20 20:23:30.230 16732 16732 E subsystem_ramdump: Unable to create /sdcard/ramdump
01-20 20:23:30.230 16732 16732 E subsystem_ramdump: Failed to initialize ramdump
01-20 20:23:30.218 16732 16732 W subsystem_ramdu: type=1400 audit(0.0:38110): avc: denied { search } for name="/" dev="sdcardfs" ino=102961 scontext=u:r:subsystem_ramdump:s0 tcontext=u:object_r:sdcardfs:s0 tclass=dir permissive=0
01-20 20:23:30.218 16732 16732 W subsystem_ramdu: type=1400 audit(0.0:38111): avc: denied { search } for name="/" dev="sdcardfs" ino=102961 scontext=u:r:subsystem_ramdump:s0 tcontext=u:object_r:sdcardfs:s0 tclass=dir permissive=0
01-20 20:23:30.246 1433 2942 I ActivityManager: Process com.google.process.gapps (pid 15153) has died: cch+6CE
01-20 20:23:30.249 3639 3747 D PowerKeeper.Event: notifyAMProcDied pacakageName: com.google.process.gapps, pid:15153
01-20 20:23:30.250 19224 19224 I AppBase : onTrimMemory(): 15
01-20 20:23:30.254 15082 15082 I WorkerManager: Unloading disused workers
01-20 20:23:30.321 1433 11979 I WindowManager: WIN DEATH: Window{463b712 u0 org.anoop.myapp/org.kivy.android.PythonActivity}
01-20 20:23:30.321 1433 11443 I chatty : uid=1000(system) Binder:1433_1E expire 1 line
01-20 20:23:30.321 1433 11979 W WindowManager: Force-removing child win Window{e8966a3 u0 SurfaceView - org.anoop.myapp/org.kivy.android.PythonActivity} from container Window{463b712 u0 org.anoop.myapp/org.kivy.android.PythonActivity}
01-20 20:23:30.322 1433 4412 I ActivityManager: Process org.anoop.myapp (pid 16636) has died: fore T
01-20 20:23:30.323 1433 4412 W ActivityManager: Force removing ActivityRecord{5c83162 u0 org.anoop.myapp/org.kivy.android.PythonActivity t202}: app died, no saved state
01-20 20:23:30.323 3639 3747 D PowerKeeper.Event: notifyAMProcDied pacakageName: org.anoop.myapp, pid:16636
01-20 20:23:30.327 1433 5834 W WindowManager: Failed looking up window
01-20 20:23:30.327 1433 5834 W WindowManager: java.lang.IllegalArgumentException: Requested window android.os.BinderProxy@4f26328 does not exist
01-20 20:23:30.327 1433 5834 W WindowManager: at com.android.server.wm.WindowManagerService.windowForClientLocked(WindowManagerService.java:9649)
01-20 20:23:30.327 1433 5834 W WindowManager: at com.android.server.wm.WindowManagerService.windowForClientLocked(WindowManagerService.java:9640)
01-20 20:23:30.327 1433 5834 W WindowManager: at com.android.server.wm.WindowState$DeathRecipient.binderDied(WindowState.java:1818)
01-20 20:23:30.327 1433 5834 W WindowManager: at android.os.BinderProxy.sendDeathNotice(Binder.java:701)
01-20 20:23:30.327 1433 5834 I WindowManager: WIN DEATH: null
01-20 20:23:30.332 374 2634 E ANDR-PERF-RESOURCEQS: Failed to apply optimization [4, 0]
01-20 20:23:30.343 1433 4412 I chatty : uid=1000(system) Binder:1433_15 expire 1 line
01-20 20:23:30.347 4176 23667 D GameBoosterService: onGameStatusChange foreground:ForegroundInfo{mForegroundPackageName='com.miui.home', mForegroundUid=10026, mForegroundPid=1961, mLastForegroundPackageName='org.anoop.myapp', mLastForegroundUid=10160, mLastForegroundPid=16636, mMultiWindowForegroundPackageName='null', mMultiWindowForegroundUid=-1, mFlags=0}
01-20 20:23:30.348 1961 1961 D Launcher.Lifecycle: onStart:UserHandle{0},5e87d24,false
01-20 20:23:30.348 1629 1629 I chatty : uid=1000(system) com.android.systemui expire 210 lines
01-20 20:23:13.090 16636 16636 V pythonutil: Library loading error: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/org.anoop.myapp-1/base.apk"],nativeLibraryDirectories=[/data/app/org.anoop.myapp-1/lib/arm64, /data/app/org.anoop.myapp-1/base.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64]]] couldn't find "libpython2.7.so"
01-20 20:23:13.090 16636 16636 V pythonutil: Loading library: python3.5m
01-20 20:23:13.091 16636 16636 V pythonutil: Library loading error: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/org.anoop.myapp-1/base.apk"],nativeLibraryDirectories=[/data/app/org.anoop.myapp-1/lib/arm64, /data/app/org.anoop.myapp-1/base.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64]]] couldn't find "libpython3.5m.so"
01-20 20:23:13.091 16636 16636 V pythonutil: Loading library: python3.6m
01-20 20:23:13.094 16636 16636 V pythonutil: Library loading error: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/org.anoop.myapp-1/base.apk"],nativeLibraryDirectories=[/data/app/org.anoop.myapp-1/lib/arm64, /data/app/org.anoop.myapp-1/base.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64]]] couldn't find "libpython3.6m.so"
01-20 20:23:13.094 16636 16636 V pythonutil: Loading library: python3.7m
01-20 20:23:13.229 16636 16636 V pythonutil: Loading library: main
01-20 20:23:13.350 16636 16636 V pythonutil: Failed to load _io.so or unicodedata.so...but that's okay.
01-20 20:23:13.350 16636 16636 V pythonutil: Unsatisfied linker when loading ctypes
01-20 20:23:13.350 16636 16636 V pythonutil: Loaded everything!
01-20 20:23:13.353 16636 16636 V SDL : nativeSetupJNI()
01-20 20:23:13.354 16636 16636 V SDL : AUDIO nativeSetupJNI()
01-20 20:23:13.354 16636 16636 V SDL : CONTROLLER nativeSetupJNI()
01-20 20:23:13.370 16636 16636 D hidapi : Initializing Bluetooth
01-20 20:23:13.370 16636 16636 D hidapi : Couldn't initialize Bluetooth, missing android.permission.BLUETOOTH
01-20 20:23:13.398 16636 16636 V PythonActivity: Setting env vars for start.c and Python to use
01-20 20:23:13.398 16636 16636 V PythonActivity: Access to our meta-data...
01-20 20:23:13.400 16636 16636 I PythonActivity: Surface will NOT be transparent
01-20 20:23:13.400 16636 16636 V PythonActivity: onResume()
01-20 20:23:13.400 16636 16636 V SDL : onResume()
01-20 20:23:13.424 16636 16636 V SDL : surfaceCreated()
01-20 20:23:13.424 16636 16636 V SDL : surfaceChanged()
01-20 20:23:13.424 16636 16636 V SDL : pixel format RGB_565
01-20 20:23:13.425 16636 16636 V SDL : Window size: 720x1230
01-20 20:23:13.425 16636 16636 V SDL : Device size: 720x1280
01-20 20:23:13.451 16636 16636 V SDL : nativeResume()
01-20 20:23:13.453 16636 16668 V SDL : Running main function SDL_main from library /data/app/org.anoop.myapp-1/lib/arm64/libmain.so
01-20 20:23:13.453 16636 16668 V PythonActivity: appConfirmedActive() -> preparing loading screen removal
01-20 20:23:13.453 16636 16668 V SDL : nativeRunMain()
01-20 20:23:13.455 16636 16668 I python : Initializing Python for Android
01-20 20:23:13.455 16636 16668 I python : Setting additional env vars from p4a_env_vars.txt
01-20 20:23:13.456 16636 16668 I python : Changing directory to the one provided by ANDROID_ARGUMENT
01-20 20:23:13.456 16636 16668 I python : /data/user/0/org.anoop.myapp/files/app
01-20 20:23:13.464 16636 16668 I python : Preparing to initialize python
01-20 20:23:13.464 16636 16668 I python : _python_bundle dir exists
01-20 20:23:13.464 16636 16668 I python : calculated paths to be...
01-20 20:23:13.464 16636 16668 I python : /data/user/0/org.anoop.myapp/files/app/_python_bundle/stdlib.zip:/data/user/0/org.anoop.myapp/files/app/_python_bundle/modules
01-20 20:23:13.477 16636 16668 I python : set wchar paths...
01-20 20:23:13.639 16636 16668 I python : Initialized python
01-20 20:23:13.639 16636 16668 I python : AND: Init threads
01-20 20:23:13.641 16636 16668 I python : testing python print redirection
01-20 20:23:13.643 16636 16668 I python : Android path ['.', '/data/user/0/org.anoop.myapp/files/app/_python_bundle/stdlib.zip', '/data/user/0/org.anoop.myapp/files/app/_python_bundle/modules', '/data/user/0/org.anoop.myapp/files/app/_python_bundle/site-packages']
01-20 20:23:13.644 16636 16668 I python : os.environ is environ({'PATH': '/sbin:/vendor/bin:/system/sbin:/system/bin:/system/xbin', 'DOWNLOAD_CACHE': '/data/cache', 'ANDROID_BOOTLOGO': '1', 'ANDROID_ROOT': '/system', 'ANDROID_ASSETS': '/system/app', 'ANDROID_DATA': '/data', 'ANDROID_STORAGE': '/storage', 'EXTERNAL_STORAGE': '/sdcard', 'ASEC_MOUNTPOINT': '/mnt/asec', 'BOOTCLASSPATH': '/system/framework/core-oj.jar:/system/framework/core-libart.jar:/system/framework/conscrypt.jar:/system/framework/okhttp.jar:/system/framework/core-junit.jar:/system/framework/bouncycastle.jar:/system/framework/ext.jar:/system/framework/framework.jar:/system/framework/telephony-common.jar:/system/framework/voip-common.jar:/system/framework/ims-common.jar:/system/framework/apache-xml.jar:/system/framework/org.apache.http.legacy.boot.jar:/system/framework/tcmiface.jar:/system/framework/WfdCommon.jar:/system/framework/oem-services.jar:/system/framework/qcom.fmradio.jar:/system/framework/qcmediaplayer.jar:/system/framework/telephony-ext.jar:/system/app/miui/miui.apk:/system/app/miuisystem/miuisystem.apk', 'SYSTEMSERVERCLASSPATH': '/system/framework/services.jar:/system/framework/ethernet-service.jar:/system/framework/wifi-service.jar', 'ANDROID_SOCKET_zygote': '8', 'ANDROID_ENTRYPOINT': 'main.pyc', 'ANDROID_ARGUMENT': '/data/user/0/org.anoop.myapp/files/app', 'ANDROID_APP_PATH': '/data/user/0/org.anoop.myapp/files/app', 'ANDROID_PRIVATE': '/data/user/0/org.anoop.myapp/files', 'ANDROID_UNPACK': '/data/user/0/org.anoop.myapp/files/app', 'PYTHONHOME': '/data/user/0/org.anoop.myapp/files/app', 'PYTHONPATH': '/data/user/0/org.anoop.myapp/files/app:/data/user/0/org.anoop.myapp/files/app/lib', 'PYTHONOPTIMIZE': '2', 'P4A_BOOTSTRAP': 'SDL2', 'PYTHON_NAME': 'python', 'P4A_IS_WINDOWED': 'True', 'P4A_ORIENTATION': 'portrait', 'P4A_NUMERIC_VERSION': 'None', 'P4A_MINSDK': '21', 'LC_CTYPE': 'C.UTF-8'})
01-20 20:23:13.644 16636 16668 I python : Android kivy bootstrap done. __name__ is __main__
01-20 20:23:13.644 16636 16668 I python : AND: Ran string
01-20 20:23:13.644 16636 16668 I python : Run user program, change dir and execute entrypoint
01-20 20:23:13.931 16636 16668 I python : [WARNING] [Config ] Older configuration version detected (0 instead of 21)
01-20 20:23:13.931 16636 16668 I python : [WARNING] [Config ] Upgrading configuration in progress.
01-20 20:23:13.941 16636 16668 I python : [INFO ] [Logger ] Record log in /data/user/0/org.anoop.myapp/files/app/.kivy/logs/kivy_20-01-20_0.txt
01-20 20:23:13.941 16636 16668 I python : [INFO ] [Kivy ] v2.0.0rc1, git-Unknown, 20200103
01-20 20:23:13.942 16636 16668 I python : [INFO ] [Kivy ] Installed at "/data/user/0/org.anoop.myapp/files/app/_python_bundle/site-packages/kivy/__init__.pyc"
01-20 20:23:13.942 16636 16668 I python : [INFO ] [Python ] v3.7.1 (default, Jan 3 2020, 23:17:19)
01-20 20:23:13.942 16636 16668 I python : [Clang 8.0.2 (https://android.googlesource.com/toolchain/clang 40173bab62ec7462
01-20 20:23:13.942 16636 16668 I python : [INFO ] [Python ] Interpreter at "android_python"
01-20 20:23:13.943 16636 16668 I python : [INFO ] [KivyMD ] v0.102.1
01-20 20:23:13.954 16636 16668 I python : [INFO ] [Factory ] 184 symbols loaded
01-20 20:23:13.995 1609 1609 D wpa_supplicant: wlan0: Control interface command 'SIGNAL_POLL'
01-20 20:23:14.010 1609 1609 D wpa_supplicant: CTRL-DEBUG: global_ctrl_sock-sendto: sock=8 sndbuf=212992 outq=0 send_len=48
01-20 20:23:14.916 16636 16668 E linker : library "/system/lib/libc.so" ("/system/lib/libc.so") needed or dlopened by "/data/data/org.anoop.myapp/files/app/_python_bundle/modules/_ctypes.cpython-37m.so" is not accessible for the namespace: [name="classloader-namespace", ld_library_paths="", default_library_paths="/data/app/org.anoop.myapp-1/lib/arm64:/data/app/org.anoop.myapp-1/base.apk!/lib/arm64-v8a", permitted_paths="/data:/mnt/expand:/data/data/org.anoop.myapp"]
01-20 20:23:15.138 16672 16672 I chatty : uid=1000(system) /system/bin/subsystem_ramdump expire 2 lines
01-20 20:23:15.150 16672 16672 I subsystem_ramdump: Usage:./system/bin/subsystem_ramdump [arg1] [arg2] [arg3]
01-20 20:23:15.150 16672 16672 I subsystem_ramdump: [arg1]: (1/2) Ramdump location: 1: eMMC: /data/ramdump or 2: SD card: /sdcard/ramdump
01-20 20:23:15.150 16672 16672 I subsystem_ramdump: [arg2]: (1/0) 1: Enable RPM log / 0: Disable RPM log
01-20 20:23:15.150 16672 16672 I subsystem_ramdump: [arg3]: (1/0) 1: Enable qdss ramdump / 0: Disable qdss ramdump
01-20 20:23:15.152 16672 16672 E subsystem_ramdump: Directory /sdcard/ramdump does not exist
01-20 20:23:15.152 16672 16672 I subsystem_ramdump: Attemping to create /sdcard/ramdump
01-20 20:23:15.152 16672 16672 E subsystem_ramdump: Unable to create /sdcard/ramdump
01-20 20:23:15.152 16672 16672 E subsystem_ramdump: Unable to create /sdcard/ramdump
01-20 20:23:15.152 16672 16672 E subsystem_ramdump: Failed to initialize ramdump
01-20 20:23:15.779 16636 16668 I python : [INFO ] [Image ] Providers: img_tex, img_dds, img_sdl2, img_gif (img_pil, img_ffpyplayer ignored)

@AndreMiras how to install android module?

Add it to your requirements. Try to use Discord for support questions, you'll get better support

@AndreMiras how to install android module?

it's only needed during build. if you need to still run your app through IDE or on desktop:

from kivy.utils import platform

if platform == "android":
from android.permissions import request_permissions, Permission
request_permissions([Permission.READ_EXTERNAL_STORAGE, Permission.WRITE_EXTERNAL_STORAGE])

The suggested code works for storage permissions. However doesn't work for Record Audio

from kivy.utils import platform

if platform == "android":
from android.permissions import request_permissions, Permission
request_permissions([Permission.READ_EXTERNAL_STORAGE, Permission.WRITE_EXTERNAL_STORAGE, Permission.RECORD_AUDIO])

here permission ECORD_AUDIO throws following error:
01-07 14:08:41.499 2331 2693 I GameBoosterService: onForegroundInfoChanged: Cur=com.google.android.packageinstaller last=jigyasu.net.voiceasstmob
01-07 14:08:41.499 794 18980 W ServiceManager: Permission failure: android.permission.RECORD_AUDIO from uid=10197 pid=4691
01-07 14:08:41.500 794 18980 E MediaRecorderService: Request requires android.permission.RECORD_AUDIO

I don't know for sure but if that is the exact error message have you tried importing 'permission' (singular) from android and using permission.RECORD_AUDIO (lower case p no -s) as it says in the error message?

The suggested code works for storage permissions. However doesn't work for Record Audio

from kivy.utils import platform

if platform == "android":
from android.permissions import request_permissions, Permission
request_permissions([Permission.READ_EXTERNAL_STORAGE, Permission.WRITE_EXTERNAL_STORAGE, Permission.RECORD_AUDIO])

here permission ECORD_AUDIO throws following error:
01-07 14:08:41.499 2331 2693 I GameBoosterService: onForegroundInfoChanged: Cur=com.google.android.packageinstaller last=jigyasu.net.voiceasstmob
01-07 14:08:41.499 794 18980 W ServiceManager: Permission failure: android.permission.RECORD_AUDIO from uid=10197 pid=4691
01-07 14:08:41.500 794 18980 E MediaRecorderService: Request requires android.permission.RECORD_AUDIO

I don't know for sure but if that is the exact error message have you tried importing 'permission' (singular) from android and using permission.RECORD_AUDIO (lower case p no -s) as it says in the error message?

The suggested code works for storage permissions. However doesn't work for Record Audio
from kivy.utils import platform
if platform == "android":
from android.permissions import request_permissions, Permission
request_permissions([Permission.READ_EXTERNAL_STORAGE, Permission.WRITE_EXTERNAL_STORAGE, Permission.RECORD_AUDIO])
here permission ECORD_AUDIO throws following error:
01-07 14:08:41.499 2331 2693 I GameBoosterService: onForegroundInfoChanged: Cur=com.google.android.packageinstaller last=jigyasu.net.voiceasstmob
01-07 14:08:41.499 794 18980 W ServiceManager: Permission failure: android.permission.RECORD_AUDIO from uid=10197 pid=4691
01-07 14:08:41.500 794 18980 E MediaRecorderService: Request requires android.permission.RECORD_AUDIO

Thanks a lot for response!!!
I found the issue and seems it is related to my experience with buildozer. The issue could be resolved by putting the RECORD_AUDIO permission in spec file, while it was not required for storage permissions. Might be because MICROPHONE permissions are classified as dangerous.

The app crashes after asking for permission
Here is the logcat output:

01-20 20:23:18.534 1433 1819 I ActivityManager: Start proc 16676:com.google.android.packageinstaller/u0a22 for activity com.google.android.packageinstaller/com.android.packageinstaller.permission.ui.GrantPermissionsActivity caller=org.anoop.myapp
01-20 20:23:18.552 16676 16676 D TidaProvider: TidaProvider()
01-20 20:23:18.561 16676 16676 W ReflectionUtils:
01-20 20:23:18.561 16676 16676 W ReflectionUtils: java.lang.NoSuchMethodException: android.os.MessageQueue#enableMonitor()#bestmatch
01-20 20:23:18.561 16676 16676 W ReflectionUtils: at miui.util.ReflectionUtils.findMethodBestMatch(ReflectionUtils.java:338)
01-20 20:23:18.561 16676 16676 W ReflectionUtils: at miui.util.ReflectionUtils.findMethodBestMatch(ReflectionUtils.java:375)
01-20 20:23:18.561 16676 16676 W ReflectionUtils: at miui.util.ReflectionUtils.callMethod(ReflectionUtils.java:800)
01-20 20:23:18.561 16676 16676 W ReflectionUtils: at miui.util.ReflectionUtils.tryCallMethod(ReflectionUtils.java:818)
01-20 20:23:18.561 16676 16676 W ReflectionUtils: at android.os.BaseLooper.enableMonitor(BaseLooper.java:47)
01-20 20:23:18.561 16676 16676 W ReflectionUtils: at android.os.Looper.prepareMainLooper(Looper.java:112)
01-20 20:23:18.561 16676 16676 W ReflectionUtils: at android.app.ActivityThread.main(ActivityThread.java:6221)
01-20 20:23:18.561 16676 16676 W ReflectionUtils: at java.lang.reflect.Method.invoke(Native Method)
01-20 20:23:18.561 16676 16676 W ReflectionUtils: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:904)
01-20 20:23:18.561 16676 16676 W ReflectionUtils: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:794)
01-20 20:23:18.561 16676 16676 V BoostFramework: BoostFramework() : mPerf = com.qualcomm.qti.Performance@40f97ad
01-20 20:23:18.603 16676 16676 W System : ClassLoader referenced unknown path: /system/priv-app/GooglePackageInstaller/lib/arm64
01-20 20:23:18.611 16676 16676 W ResourceType: No package identifier when getting name for resource number 0x00000000
01-20 20:23:18.749 16676 16676 W ResourceType: No package identifier when getting name for resource number 0x00000000
01-20 20:23:18.769 16676 16676 W ResourceType: No package identifier when getting name for resource number 0x00000000
01-20 20:23:18.818 16676 16676 D AccessibilityManager: current package=com.google.android.packageinstaller, accessibility manager mIsFinalEnabled=false, mOptimizeEnabled=false, mIsUiAutomationEnabled=false, mIsInterestedPackage=false
01-20 20:23:18.824 16676 16676 V BoostFramework: BoostFramework() : mPerf = com.qualcomm.qti.Performance@d028eb
01-20 20:23:18.824 16676 16676 V BoostFramework: BoostFramework() : mPerf = com.qualcomm.qti.Performance@5db3648
01-20 20:23:18.990 16676 16692 I Adreno-EGL: : EGL 1.4 QUALCOMM build: Nondeterministic_AU_msm8937_64_LA.UM.5.5.R1__release_AU (I83a540a04a)
01-20 20:23:18.990 16676 16692 I Adreno-EGL: OpenGL ES Shader Compiler Version: XE031.09.00.04
01-20 20:23:30.229 16732 16732 I subsystem_ramdump: [arg3]: (1/0) 1: Enable qdss ramdump / 0: Disable qdss ramdump
01-20 20:23:30.230 16732 16732 E subsystem_ramdump: Directory /sdcard/ramdump does not exist
01-20 20:23:30.230 16732 16732 I subsystem_ramdump: Attemping to create /sdcard/ramdump
01-20 20:23:30.230 16732 16732 E subsystem_ramdump: Unable to create /sdcard/ramdump
01-20 20:23:30.230 16732 16732 E subsystem_ramdump: Unable to create /sdcard/ramdump
01-20 20:23:30.230 16732 16732 E subsystem_ramdump: Failed to initialize ramdump
01-20 20:23:30.218 16732 16732 W subsystem_ramdu: type=1400 audit(0.0:38110): avc: denied { search } for name="/" dev="sdcardfs" ino=102961 scontext=u:r:subsystem_ramdump:s0 tcontext=u:object_r:sdcardfs:s0 tclass=dir permissive=0
01-20 20:23:30.218 16732 16732 W subsystem_ramdu: type=1400 audit(0.0:38111): avc: denied { search } for name="/" dev="sdcardfs" ino=102961 scontext=u:r:subsystem_ramdump:s0 tcontext=u:object_r:sdcardfs:s0 tclass=dir permissive=0
01-20 20:23:30.246 1433 2942 I ActivityManager: Process com.google.process.gapps (pid 15153) has died: cch+6CE
01-20 20:23:30.249 3639 3747 D PowerKeeper.Event: notifyAMProcDied pacakageName: com.google.process.gapps, pid:15153
01-20 20:23:30.250 19224 19224 I AppBase : onTrimMemory(): 15
01-20 20:23:30.254 15082 15082 I WorkerManager: Unloading disused workers
01-20 20:23:30.321 1433 11979 I WindowManager: WIN DEATH: Window{463b712 u0 org.anoop.myapp/org.kivy.android.PythonActivity}
01-20 20:23:30.321 1433 11443 I chatty : uid=1000(system) Binder:1433_1E expire 1 line
01-20 20:23:30.321 1433 11979 W WindowManager: Force-removing child win Window{e8966a3 u0 SurfaceView - org.anoop.myapp/org.kivy.android.PythonActivity} from container Window{463b712 u0 org.anoop.myapp/org.kivy.android.PythonActivity}
01-20 20:23:30.322 1433 4412 I ActivityManager: Process org.anoop.myapp (pid 16636) has died: fore T
01-20 20:23:30.323 1433 4412 W ActivityManager: Force removing ActivityRecord{5c83162 u0 org.anoop.myapp/org.kivy.android.PythonActivity t202}: app died, no saved state
01-20 20:23:30.323 3639 3747 D PowerKeeper.Event: notifyAMProcDied pacakageName: org.anoop.myapp, pid:16636
01-20 20:23:30.327 1433 5834 W WindowManager: Failed looking up window
01-20 20:23:30.327 1433 5834 W WindowManager: java.lang.IllegalArgumentException: Requested window android.os.BinderProxy@4f26328 does not exist
01-20 20:23:30.327 1433 5834 W WindowManager: at com.android.server.wm.WindowManagerService.windowForClientLocked(WindowManagerService.java:9649)
01-20 20:23:30.327 1433 5834 W WindowManager: at com.android.server.wm.WindowManagerService.windowForClientLocked(WindowManagerService.java:9640)
01-20 20:23:30.327 1433 5834 W WindowManager: at com.android.server.wm.WindowState$DeathRecipient.binderDied(WindowState.java:1818)
01-20 20:23:30.327 1433 5834 W WindowManager: at android.os.BinderProxy.sendDeathNotice(Binder.java:701)
01-20 20:23:30.327 1433 5834 I WindowManager: WIN DEATH: null
01-20 20:23:30.332 374 2634 E ANDR-PERF-RESOURCEQS: Failed to apply optimization [4, 0]
01-20 20:23:30.343 1433 4412 I chatty : uid=1000(system) Binder:1433_15 expire 1 line
01-20 20:23:30.347 4176 23667 D GameBoosterService: onGameStatusChange foreground:ForegroundInfo{mForegroundPackageName='com.miui.home', mForegroundUid=10026, mForegroundPid=1961, mLastForegroundPackageName='org.anoop.myapp', mLastForegroundUid=10160, mLastForegroundPid=16636, mMultiWindowForegroundPackageName='null', mMultiWindowForegroundUid=-1, mFlags=0}
01-20 20:23:30.348 1961 1961 D Launcher.Lifecycle: onStart:UserHandle{0},5e87d24,false
01-20 20:23:30.348 1629 1629 I chatty : uid=1000(system) com.android.systemui expire 210 lines
01-20 20:23:13.090 16636 16636 V pythonutil: Library loading error: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/org.anoop.myapp-1/base.apk"],nativeLibraryDirectories=[/data/app/org.anoop.myapp-1/lib/arm64, /data/app/org.anoop.myapp-1/base.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64]]] couldn't find "libpython2.7.so"
01-20 20:23:13.090 16636 16636 V pythonutil: Loading library: python3.5m
01-20 20:23:13.091 16636 16636 V pythonutil: Library loading error: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/org.anoop.myapp-1/base.apk"],nativeLibraryDirectories=[/data/app/org.anoop.myapp-1/lib/arm64, /data/app/org.anoop.myapp-1/base.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64]]] couldn't find "libpython3.5m.so"
01-20 20:23:13.091 16636 16636 V pythonutil: Loading library: python3.6m
01-20 20:23:13.094 16636 16636 V pythonutil: Library loading error: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/org.anoop.myapp-1/base.apk"],nativeLibraryDirectories=[/data/app/org.anoop.myapp-1/lib/arm64, /data/app/org.anoop.myapp-1/base.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64]]] couldn't find "libpython3.6m.so"
01-20 20:23:13.094 16636 16636 V pythonutil: Loading library: python3.7m
01-20 20:23:13.229 16636 16636 V pythonutil: Loading library: main
01-20 20:23:13.350 16636 16636 V pythonutil: Failed to load _io.so or unicodedata.so...but that's okay.
01-20 20:23:13.350 16636 16636 V pythonutil: Unsatisfied linker when loading ctypes
01-20 20:23:13.350 16636 16636 V pythonutil: Loaded everything!
01-20 20:23:13.353 16636 16636 V SDL : nativeSetupJNI()
01-20 20:23:13.354 16636 16636 V SDL : AUDIO nativeSetupJNI()
01-20 20:23:13.354 16636 16636 V SDL : CONTROLLER nativeSetupJNI()
01-20 20:23:13.370 16636 16636 D hidapi : Initializing Bluetooth
01-20 20:23:13.370 16636 16636 D hidapi : Couldn't initialize Bluetooth, missing android.permission.BLUETOOTH
01-20 20:23:13.398 16636 16636 V PythonActivity: Setting env vars for start.c and Python to use
01-20 20:23:13.398 16636 16636 V PythonActivity: Access to our meta-data...
01-20 20:23:13.400 16636 16636 I PythonActivity: Surface will NOT be transparent
01-20 20:23:13.400 16636 16636 V PythonActivity: onResume()
01-20 20:23:13.400 16636 16636 V SDL : onResume()
01-20 20:23:13.424 16636 16636 V SDL : surfaceCreated()
01-20 20:23:13.424 16636 16636 V SDL : surfaceChanged()
01-20 20:23:13.424 16636 16636 V SDL : pixel format RGB_565
01-20 20:23:13.425 16636 16636 V SDL : Window size: 720x1230
01-20 20:23:13.425 16636 16636 V SDL : Device size: 720x1280
01-20 20:23:13.451 16636 16636 V SDL : nativeResume()
01-20 20:23:13.453 16636 16668 V SDL : Running main function SDL_main from library /data/app/org.anoop.myapp-1/lib/arm64/libmain.so
01-20 20:23:13.453 16636 16668 V PythonActivity: appConfirmedActive() -> preparing loading screen removal
01-20 20:23:13.453 16636 16668 V SDL : nativeRunMain()
01-20 20:23:13.455 16636 16668 I python : Initializing Python for Android
01-20 20:23:13.455 16636 16668 I python : Setting additional env vars from p4a_env_vars.txt
01-20 20:23:13.456 16636 16668 I python : Changing directory to the one provided by ANDROID_ARGUMENT
01-20 20:23:13.456 16636 16668 I python : /data/user/0/org.anoop.myapp/files/app
01-20 20:23:13.464 16636 16668 I python : Preparing to initialize python
01-20 20:23:13.464 16636 16668 I python : _python_bundle dir exists
01-20 20:23:13.464 16636 16668 I python : calculated paths to be...
01-20 20:23:13.464 16636 16668 I python : /data/user/0/org.anoop.myapp/files/app/_python_bundle/stdlib.zip:/data/user/0/org.anoop.myapp/files/app/_python_bundle/modules
01-20 20:23:13.477 16636 16668 I python : set wchar paths...
01-20 20:23:13.639 16636 16668 I python : Initialized python
01-20 20:23:13.639 16636 16668 I python : AND: Init threads
01-20 20:23:13.641 16636 16668 I python : testing python print redirection
01-20 20:23:13.643 16636 16668 I python : Android path ['.', '/data/user/0/org.anoop.myapp/files/app/_python_bundle/stdlib.zip', '/data/user/0/org.anoop.myapp/files/app/_python_bundle/modules', '/data/user/0/org.anoop.myapp/files/app/_python_bundle/site-packages']
01-20 20:23:13.644 16636 16668 I python : os.environ is environ({'PATH': '/sbin:/vendor/bin:/system/sbin:/system/bin:/system/xbin', 'DOWNLOAD_CACHE': '/data/cache', 'ANDROID_BOOTLOGO': '1', 'ANDROID_ROOT': '/system', 'ANDROID_ASSETS': '/system/app', 'ANDROID_DATA': '/data', 'ANDROID_STORAGE': '/storage', 'EXTERNAL_STORAGE': '/sdcard', 'ASEC_MOUNTPOINT': '/mnt/asec', 'BOOTCLASSPATH': '/system/framework/core-oj.jar:/system/framework/core-libart.jar:/system/framework/conscrypt.jar:/system/framework/okhttp.jar:/system/framework/core-junit.jar:/system/framework/bouncycastle.jar:/system/framework/ext.jar:/system/framework/framework.jar:/system/framework/telephony-common.jar:/system/framework/voip-common.jar:/system/framework/ims-common.jar:/system/framework/apache-xml.jar:/system/framework/org.apache.http.legacy.boot.jar:/system/framework/tcmiface.jar:/system/framework/WfdCommon.jar:/system/framework/oem-services.jar:/system/framework/qcom.fmradio.jar:/system/framework/qcmediaplayer.jar:/system/framework/telephony-ext.jar:/system/app/miui/miui.apk:/system/app/miuisystem/miuisystem.apk', 'SYSTEMSERVERCLASSPATH': '/system/framework/services.jar:/system/framework/ethernet-service.jar:/system/framework/wifi-service.jar', 'ANDROID_SOCKET_zygote': '8', 'ANDROID_ENTRYPOINT': 'main.pyc', 'ANDROID_ARGUMENT': '/data/user/0/org.anoop.myapp/files/app', 'ANDROID_APP_PATH': '/data/user/0/org.anoop.myapp/files/app', 'ANDROID_PRIVATE': '/data/user/0/org.anoop.myapp/files', 'ANDROID_UNPACK': '/data/user/0/org.anoop.myapp/files/app', 'PYTHONHOME': '/data/user/0/org.anoop.myapp/files/app', 'PYTHONPATH': '/data/user/0/org.anoop.myapp/files/app:/data/user/0/org.anoop.myapp/files/app/lib', 'PYTHONOPTIMIZE': '2', 'P4A_BOOTSTRAP': 'SDL2', 'PYTHON_NAME': 'python', 'P4A_IS_WINDOWED': 'True', 'P4A_ORIENTATION': 'portrait', 'P4A_NUMERIC_VERSION': 'None', 'P4A_MINSDK': '21', 'LC_CTYPE': 'C.UTF-8'})
01-20 20:23:13.644 16636 16668 I python : Android kivy bootstrap done. __name__ is __main__
01-20 20:23:13.644 16636 16668 I python : AND: Ran string
01-20 20:23:13.644 16636 16668 I python : Run user program, change dir and execute entrypoint
01-20 20:23:13.931 16636 16668 I python : [WARNING] [Config ] Older configuration version detected (0 instead of 21)
01-20 20:23:13.931 16636 16668 I python : [WARNING] [Config ] Upgrading configuration in progress.
01-20 20:23:13.941 16636 16668 I python : [INFO ] [Logger ] Record log in /data/user/0/org.anoop.myapp/files/app/.kivy/logs/kivy_20-01-20_0.txt
01-20 20:23:13.941 16636 16668 I python : [INFO ] [Kivy ] v2.0.0rc1, git-Unknown, 20200103
01-20 20:23:13.942 16636 16668 I python : [INFO ] [Kivy ] Installed at "/data/user/0/org.anoop.myapp/files/app/_python_bundle/site-packages/kivy/__init__.pyc"
01-20 20:23:13.942 16636 16668 I python : [INFO ] [Python ] v3.7.1 (default, Jan 3 2020, 23:17:19)
01-20 20:23:13.942 16636 16668 I python : [Clang 8.0.2 (https://android.googlesource.com/toolchain/clang 40173bab62ec7462
01-20 20:23:13.942 16636 16668 I python : [INFO ] [Python ] Interpreter at "android_python"
01-20 20:23:13.943 16636 16668 I python : [INFO ] [KivyMD ] v0.102.1
01-20 20:23:13.954 16636 16668 I python : [INFO ] [Factory ] 184 symbols loaded
01-20 20:23:13.995 1609 1609 D wpa_supplicant: wlan0: Control interface command 'SIGNAL_POLL'
01-20 20:23:14.010 1609 1609 D wpa_supplicant: CTRL-DEBUG: global_ctrl_sock-sendto: sock=8 sndbuf=212992 outq=0 send_len=48
01-20 20:23:14.916 16636 16668 E linker : library "/system/lib/libc.so" ("/system/lib/libc.so") needed or dlopened by "/data/data/org.anoop.myapp/files/app/_python_bundle/modules/_ctypes.cpython-37m.so" is not accessible for the namespace: [name="classloader-namespace", ld_library_paths="", default_library_paths="/data/app/org.anoop.myapp-1/lib/arm64:/data/app/org.anoop.myapp-1/base.apk!/lib/arm64-v8a", permitted_paths="/data:/mnt/expand:/data/data/org.anoop.myapp"]
01-20 20:23:15.138 16672 16672 I chatty : uid=1000(system) /system/bin/subsystem_ramdump expire 2 lines
01-20 20:23:15.150 16672 16672 I subsystem_ramdump: Usage:./system/bin/subsystem_ramdump [arg1] [arg2] [arg3]
01-20 20:23:15.150 16672 16672 I subsystem_ramdump: [arg1]: (1/2) Ramdump location: 1: eMMC: /data/ramdump or 2: SD card: /sdcard/ramdump
01-20 20:23:15.150 16672 16672 I subsystem_ramdump: [arg2]: (1/0) 1: Enable RPM log / 0: Disable RPM log
01-20 20:23:15.150 16672 16672 I subsystem_ramdump: [arg3]: (1/0) 1: Enable qdss ramdump / 0: Disable qdss ramdump
01-20 20:23:15.152 16672 16672 E subsystem_ramdump: Directory /sdcard/ramdump does not exist
01-20 20:23:15.152 16672 16672 I subsystem_ramdump: Attemping to create /sdcard/ramdump
01-20 20:23:15.152 16672 16672 E subsystem_ramdump: Unable to create /sdcard/ramdump
01-20 20:23:15.152 16672 16672 E subsystem_ramdump: Unable to create /sdcard/ramdump
01-20 20:23:15.152 16672 16672 E subsystem_ramdump: Failed to initialize ramdump
01-20 20:23:15.779 16636 16668 I python : [INFO ] [Image ] Providers: img_tex, img_dds, img_sdl2, img_gif (img_pil, img_ffpyplayer ignored)

How did you solve this problem?

how to connect xampp database into kivy

Don't ask support questions in issues.

Was this page helpful?
0 / 5 - 0 ratings