finamp icon indicating copy to clipboard operation
finamp copied to clipboard

Can't download songs into external storage

Open VileoSufora opened this issue 4 years ago • 11 comments

Phone: Samsung Note 8 Android Version: 9, the most recent update as of this posting. Finamp version: 0.5.1

Finamp seems to generate an entry in the download screen when I try to download an album, but it says 0 MB for the size and Finamp throws this error:

[Flutter/SEVERE] 2021-10-03 20:23:28.511681: Null check operator used on a null value

#0      Navigator.of (package:flutter/src/widgets/navigator.dart:2740)
#1      showDialog (package:flutter/src/material/dialog.dart:1064)
#2      errorSnackbar.<anonymous closure> (package:finamp/components/errorSnackbar.dart:12)
#3      _SnackBarActionState._handlePressed (package:flutter/src/material/snack_bar.dart:124)
#4      _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:989)
#5      GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:182)
#6      TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:607)
#7      BaseTapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:296)
#8      BaseTapGestureRecognizer.acceptGesture (package:flutter/src/gestures/tap.dart:267)
#9      GestureArenaManager.sweep (package:flutter/src/gestures/arena.dart:157)
#10     GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:443)
#11     GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:419)
#12     RendererBinding.dispatchEvent (package:flutter/src/rendering/binding.dart:287)
#13     GestureBinding._handlePointerEventImmediately (package:flutter/src/gestures/binding.dart:374)
#14     GestureBinding.handlePointerEvent (package:flutter/src/gestures/binding.dart:338)
#15     GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:296)
#16     GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:279)
#17     _rootRunUnary (dart:async/zone.dart:1370)
#18     _CustomZone.runUnary (dart:async/zone.dart:1265)
#19     _CustomZone.runUnaryGuarded (dart:async/zone.dart:1170)
#20     _invoke1 (dart:ui/hooks.dart:182)
#21     PlatformDispatcher._dispatchPointerDataPacket (dart:ui/platform_dispatcher.dart:282)
#22     _dispatchPointerDataPacket (dart:ui/hooks.dart:96)

VileoSufora avatar Oct 04 '21 01:10 VileoSufora

That looks like the error that shows when checking for more on an error that happened in an alert dialog. Do you have any other errors?

jmshrv avatar Oct 04 '21 01:10 jmshrv

I do, but it's a weird one.

[Flutter/SEVERE] 2021-10-03 20:23:36.398397: HttpException: Invalid statusCode: 404, uri = https://[server address]/Items/6035db88fb45b059f7d961d75974d9fd/Images/Primary?format=webp&MaxWidth=196&MaxHeight=196

EDIT: Worth noting that the error I initially posted came out twice and this error came out like... 30-ish times in the log. I thought that might be connected to the number of songs in the album, but that album has less than 30 songs.

VileoSufora avatar Oct 04 '21 02:10 VileoSufora

That error is when an image fails to load because you don't have an album image for that item. Are you trying to download to a custom directory or regular internal storage?

jmshrv avatar Oct 04 '21 07:10 jmshrv

A custom directory on my SD card. Edit: Since you mentioned that, I tried downloading to internal storage and it worked. Are there extra steps I need to take for using an SD card?

VileoSufora avatar Oct 04 '21 08:10 VileoSufora

There's a weird bug to do with how Android handles storage permissions that causes custom directories to fail on some phones. For now, you could use the "App Directory" option when creating a custom download location. There will be an option there that leads to the SD card. The only downside of this is that it'll be in the Android folder on your SD card.

The downloader plugin I'm using recently released an update that may fix this issue, so hopefully it works in the next release.

jmshrv avatar Oct 04 '21 08:10 jmshrv

Still not working on android 12 LineageOS

MagicRB avatar Jan 11 '22 13:01 MagicRB

This helped me get downloads to SD card working on LineageOS 20 (android 13):

adb shell pm grant com.unicornsonlsd.finamp android.permission.READ_EXTERNAL_STORAGE
adb shell pm grant com.unicornsonlsd.finamp android.permission.WRITE_EXTERNAL_STORAGE

For some reason the app didn't request the permission by itself.

ilya-zlobintsev avatar Jan 10 '23 07:01 ilya-zlobintsev

Fix above (adb permissions) helps. Samsung Galaxy A53 / Android 13. Usage of app directory in Internal storage dont require any permissions - I was able to download there before adb commands. However, for app directory on sdcard they are necessary af least on some phones.

kai11 avatar May 25 '23 12:05 kai11

What's weird is that Finamp already uses those permissions

https://github.com/jmshrv/finamp/blob/0075794998baabc7bc44877e9d1de53d7d2240bc/android/app/src/main/AndroidManifest.xml#L5-L6

And we request that permission:

https://github.com/jmshrv/finamp/blob/0075794998baabc7bc44877e9d1de53d7d2240bc/lib/services/downloads_helper.dart#L68

jmshrv avatar May 25 '23 13:05 jmshrv

Permission handler dont even request WRITE for android > Q (10):

https://github.com/Baseflow/flutter-permission-handler/blob/master/permission_handler_android/android/src/main/java/com/baseflow/permissionhandler/PermissionUtils.java#LL204C14-L204C14

Issue with some sketchy workarounds: https://github.com/Baseflow/flutter-permission-handler/issues/995 Maybe use Permission.manageExternalStorage.request instead?

kai11 avatar May 25 '23 20:05 kai11

Still present in recent versions. Fix in https://github.com/jmshrv/finamp/issues/134#issuecomment-1376841753 working.

DX37 avatar Aug 13 '23 04:08 DX37