Author Topic: Fix for MusicBee Wifi Sync app with devices running Android 11 or greater.  (Read 11505 times)

BoringName

  • Full Member
  • ***
  • Posts: 197
Scoped storage was introduced with android 11. This changed how apps access the file system on android devices and has caused a problem with the Wifi Sync App. Usually resulting in an error about the selected music folder not being root. Some users have reported the app working ok on android 11 devices without having to make the below changes. I suspect the app was installed while the device was android 10 and was updated to android 11 with an OTA update and the OS kept the existing file permissions. Once the app is reinstalled or has it's data/cache cleared it will stop working.

Below are instructions on how to get the wifi app working with android 11+ devices.

Disclaimer – I’m not a programmer. I’ve been learning as I go so use the below instructions and the app at your own risk.

Install Android Studio. Easy to do, there are plenty of guides on the net for this.
Download the code for Music Bee Wifi on github and extract it to a folder.
https://github.com/mayallst/MusicBeeWifiSync/archive/refs/heads/master.zip
Inside that folder, delete .idea\vcs.xml - it causes an error when importing it into Android Studio if you don't.
Open Android Studio
Select File->Open and open the folder you extracted above. It will take a while to build gradle, I’m not sure what this does but just be patient. It may prompt you to upgrade gradle. I opted to do that. Again you have to wait a little while.
Once it's loaded there will be a list of files on the left. Under Manifests, drag AndroidManifest.xml onto the right of the screen and it will display the contents.

Add the following line above line 5 in this file.
Code
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />

This change allows the app to have file permissions to all of the external storage. The app previously had this access level but scoped storage blocked it, so you are not giving it access to anything it couldn’t access previously. It’s just a work around to restore functionality.

On the left of the screen under the Java folder, drag WifiSyncBaseActivity to the right of the screen.
Change line 115 from this -
Code
if ((Build.VERSION.SDK_INT < Build.VERSION_CODES.N || Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) && !PermissionsHandler.isUserSelectedPermissionsPathValid(WifiSyncServiceSettings.accessPermissionsUri.get())) {
To this -
Code
if ((Build.VERSION.SDK_INT < Build.VERSION_CODES.N || Build.VERSION.SDK_INT >= 34) && !PermissionsHandler.isUserSelectedPermissionsPathValid(WifiSyncServiceSettings.accessPermissionsUri.get())) {

This change just stops it checking if it actually has permission to the folder you select. The code to check permissions has changed which caused the root folder error message.

This isn’t necessary but you can set a different version number.
Right click "app" in the left window and select Open Module Settings
I changed the version code to 75 (was 74) and Version number to 2.2 (was 2.1)

Now just build the APK.
From the menus at the top of the screen, select Build->Build Bundle(s)/APK(s)->Build APK(s)
This will create the following APK in the original folder
app\build\outputs\apk\debug\app-debug.apk

Copy this file to your phone.
Use a file browser to find the file on your phone and run it. It will state something about not being from the Play Store and it's unsigned, just install anyway.
Once you open it you will get a dialog to allow it to manage all files on the phone, click allow.
Before you do anything else, go out of the app and go to permission settings on the phone.
On mine I had to go to settings->apps->special app access->All files Access (This was on a redmi note 10 pro running a custom A12 AOSP rom)
Even though I had given it permission earlier, I found MusicBee Wifi Sync was set to "Not Allowed" in this menu. I changed it to Allowed.
Go back into the MusicBee app and you should be able to select a folder now without it popping up an error.

On first sync you may get an error about the playlist folder not being a child of the of the folder you selected, just hit sync more and try and sync again, it should work fine the second time. If you want to avoid this error just make sure there is a playlist folder in your selected music folder before you perform the first sync.

The changes above should allow the app to work on android 11 and above but if you are on android 11 and it’s not working, try the below changes. Don’t bother doing the below if you are on Android 12 or greater as it will just be ignored by the OS.

In the AndroidManifest.xml file, change the following code -
Code
android:allowBackup="true"
android:theme="@style/AppTheme">
To this -
Code
android:allowBackup="true"
android:theme="@style/AppTheme"
android:requestLegacyExternalStorage="true">

I have another version that handles permissions a bit better for the user and technically could be uploaded to the play store as it is targeting SDK 30. I will add this to the guide at a later date.

phred

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 9237
Thanks for doing this, BoringName. I think lots of folks will find this useful.
Download the latest MusicBee v3.5 patch from here.
Unzip into your MusicBee directory and overwrite existing files.

----------
The FAQ
The Wiki
Posting screenshots is here
Searching the forum with Google is  here

Bougicien

  • Newbie
  • *
  • Posts: 5
Is it possible for someone to do these steps and send the APK to someone else? It should work no?

oneformula

  • Newbie
  • *
  • Posts: 19
thanks. sadly, anyone with google's advanced protection canNOT use this. apps and APKs can only be pre-loaded or from the google store.
Last Edit: October 04, 2022, 05:53:38 PM by oneformula

ome-reily

  • Newbie
  • *
  • Posts: 19
Scoped storage was introduced with android 11. This changed how apps access the file system on android devices and has caused a problem with the Wifi Sync App. Usually resulting in an error about the selected music folder not being root. Some users have reported the app working ok on android 11 devices without having to make the below changes. I suspect the app was installed while the device was android 10 and was updated to android 11 with an OTA update and the OS kept the existing file permissions. Once the app is reinstalled or has it's data/cache cleared it will stop working.

Below are instructions on how to get the wifi app working with android 11+ devices.

Disclaimer – I’m not a programmer. I’ve been learning as I go so use the below instructions and the app at your own risk.

Install Android Studio. Easy to do, there are plenty of guides on the net for this.
Download the code for Music Bee Wifi on github and extract it to a folder.
https://github.com/mayallst/MusicBeeWifiSync/archive/refs/heads/master.zip
Inside that folder, delete .idea\vcs.xml - it causes an error when importing it into Android Studio if you don't.
Open Android Studio
Select File->Open and open the folder you extracted above. It will take a while to build gradle, I’m not sure what this does but just be patient. It may prompt you to upgrade gradle. I opted to do that. Again you have to wait a little while.
Once it's loaded there will be a list of files on the left. Under Manifests, drag AndroidManifest.xml onto the right of the screen and it will display the contents.

Add the following line above line 5 in this file.
Code
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />

This change allows the app to have file permissions to all of the external storage. The app previously had this access level but scoped storage blocked it, so you are not giving it access to anything it couldn’t access previously. It’s just a work around to restore functionality.

On the left of the screen under the Java folder, drag WifiSyncBaseActivity to the right of the screen.
Change line 115 from this -
Code
if ((Build.VERSION.SDK_INT < Build.VERSION_CODES.N || Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) && !PermissionsHandler.isUserSelectedPermissionsPathValid(WifiSyncServiceSettings.accessPermissionsUri.get())) {
To this -
Code
if ((Build.VERSION.SDK_INT < Build.VERSION_CODES.N || Build.VERSION.SDK_INT >= 34) && !PermissionsHandler.isUserSelectedPermissionsPathValid(WifiSyncServiceSettings.accessPermissionsUri.get())) {

This change just stops it checking if it actually has permission to the folder you select. The code to check permissions has changed which caused the root folder error message.

This isn’t necessary but you can set a different version number.
Right click "app" in the left window and select Open Module Settings
I changed the version code to 75 (was 74) and Version number to 2.2 (was 2.1)

Now just build the APK.
From the menus at the top of the screen, select Build->Build Bundle(s)/APK(s)->Build APK(s)
This will create the following APK in the original folder
app\build\outputs\apk\debug\app-debug.apk

Copy this file to your phone.
Use a file browser to find the file on your phone and run it. It will state something about not being from the Play Store and it's unsigned, just install anyway.
Once you open it you will get a dialog to allow it to manage all files on the phone, click allow.
Before you do anything else, go out of the app and go to permission settings on the phone.
On mine I had to go to settings->apps->special app access->All files Access (This was on a redmi note 10 pro running a custom A12 AOSP rom)
Even though I had given it permission earlier, I found MusicBee Wifi Sync was set to "Not Allowed" in this menu. I changed it to Allowed.
Go back into the MusicBee app and you should be able to select a folder now without it popping up an error.

On first sync you may get an error about the playlist folder not being a child of the of the folder you selected, just hit sync more and try and sync again, it should work fine the second time. If you want to avoid this error just make sure there is a playlist folder in your selected music folder before you perform the first sync.

The changes above should allow the app to work on android 11 and above but if you are on android 11 and it’s not working, try the below changes. Don’t bother doing the below if you are on Android 12 or greater as it will just be ignored by the OS.

In the AndroidManifest.xml file, change the following code -
Code
android:allowBackup="true"
android:theme="@style/AppTheme">
To this -
Code
android:allowBackup="true"
android:theme="@style/AppTheme"
android:requestLegacyExternalStorage="true">

I have another version that handles permissions a bit better for the user and technically could be uploaded to the play store as it is targeting SDK 30. I will add this to the guide at a later date.

Dude, thank you SO MUCH for writing this up. This could not be more noob friendly of a guide.

I'm on Android 13 on a Google Pixel 4 and technically I got this working. I did everything above with no errors, and the app and MusicBee says it was synced successfully (looking to update ratings). That said, I think I'm pointing the app to the wrong folder.

I use GoneMad Player. Should I be pointing the musicbee sync app to the GoneMad player on my folder, to my music folder, or to the music subfolder that has all my songs (in individual subfolders, I should add)? I did the latter two and nothing actually changed. I feel like we're so close though!

BoringName

  • Full Member
  • ***
  • Posts: 197
I'm on Android 13 on a Google Pixel 4 and technically I got this working. I did everything above with no errors, and the app and MusicBee says it was synced successfully (looking to update ratings). That said, I think I'm pointing the app to the wrong folder.

I use GoneMad Player. Should I be pointing the musicbee sync app to the GoneMad player on my folder, to my music folder, or to the music subfolder that has all my songs (in individual subfolders, I should add)? I did the latter two and nothing actually changed. I feel like we're so close though!

You said it synced successfully so what is the problem you are having?

On android 13 I don't think it matters what folder you select. It just uses the folder you have listed in the "music files" field in Music Bee for that device. The prompting to select a folder is a legacy thing required for android 11/12 to give it access permissions to that specific folder. In android 13 it just gives access to all the folders.

If ratings/play counts are not syncing back to Music Bee it's probably because you are not using the paid version of GoneMad. The trial version doesn't work.

edit: it also uses the storage path setting in Music Bee so you need to make sure that field and the "music files" field are set to where you want the music to sync to. eg) mine is set to
storage path -  M2101K6G\Internal shared storage\
music files - "Music\<Album Artist>\<Album>\<Disc-Track#> - <Title>

If you want it on an SD Card or want to sync it to somewhere other than the root music folder you need to change these settings accordingly.
Last Edit: October 09, 2022, 10:47:33 PM by BoringName

oneformula

  • Newbie
  • *
  • Posts: 19
i removed google's advanced protection to try this, but now i get an error message: "App not installed as package conflicts with an existing package"

BoringName

  • Full Member
  • ***
  • Posts: 197
i removed google's advanced protection to try this, but now i get an error message: "App not installed as package conflicts with an existing package"

Make sure you have uninstalled the existing version of Music Bee, the one you would have downloaded from the play store.

ome-reily

  • Newbie
  • *
  • Posts: 19
I'm on Android 13 on a Google Pixel 4 and technically I got this working. I did everything above with no errors, and the app and MusicBee says it was synced successfully (looking to update ratings). That said, I think I'm pointing the app to the wrong folder.

I use GoneMad Player. Should I be pointing the musicbee sync app to the GoneMad player on my folder, to my music folder, or to the music subfolder that has all my songs (in individual subfolders, I should add)? I did the latter two and nothing actually changed. I feel like we're so close though!

You said it synced successfully so what is the problem you are having?

On android 13 I don't think it matters what folder you select. It just uses the folder you have listed in the "music files" field in Music Bee for that device. The prompting to select a folder is a legacy thing required for android 11/12 to give it access permissions to that specific folder. In android 13 it just gives access to all the folders.

If ratings/play counts are not syncing back to Music Bee it's probably because you are not using the paid version of GoneMad. The trial version doesn't work.

edit: it also uses the storage path setting in Music Bee so you need to make sure that field and the "music files" field are set to where you want the music to sync to. eg) mine is set to
storage path -  M2101K6G\Internal shared storage\
music files - "Music\<Album Artist>\<Album>\<Disc-Track#> - <Title>

If you want it on an SD Card or want to sync it to somewhere other than the root music folder you need to change these settings accordingly.

I said that it said that in synced successfully. It didn't actually update anything, though. That is the problem. And I am indeed using a paid version of Gone Mad.

Quote
it also uses the storage path setting in Music Bee so you need to make sure that field

I feel like there are a few places to set this in MusicBee--can you specify which exact menu the setting you're referring to is under? That's the only place I feel like could be a problem, but I'm unsure. I did sync wired and it put songs on my device were expected, but I can double check if this is somehow the issue.

Otherwise I have no idea what's going wrong.

BoringName

  • Full Member
  • ***
  • Posts: 197
I said that it said that in synced successfully. It didn't actually update anything, though. That is the problem. And I am indeed using a paid version of Gone Mad.

Ok, so you have done a wired sync and the music files are on the phone. The issue is ratings and play counts are not updating back into Music Bee on your PC?

If that is the case, how did you test it?

I feel like there are a few places to set this in MusicBee--can you specify which exact menu the setting you're referring to is under?

Click the 3 lines on the top left of of the application window
Edit Preferences
Devices
Select your device in the list and click "Configure"
It should be on the music tab, make sure the preferences for what you want to sync are correct. eg) all music and\or selected playlists etc...
Settings

This window will have all the paths listed.

But I don't think you need to mess with any of them if you have done a successful wired sync. The issue with ratings\play counts not syncing is probably something else.

Did you make sure the music bee app has full file permissions after you installed it?

On my current phone it's under Settings->apps->Special App Access->All File Access
Select MusicBee Wifi Sync and enable "Allow Access to manage all files".
Last Edit: October 11, 2022, 05:28:32 AM by BoringName

ome-reily

  • Newbie
  • *
  • Posts: 19
I did make sure there were full file permissions. In fact, I just tested it again and it's still not working. I think I know the issue, but I don't know how to fix it.

The first time, I already had the music on my phone and computer so I thought maybe some folders weren't reading each other. So tonight, I deleted all of the music off of my phone and deleted the app. I wired synced my music from desktop (musicbee) to my phone. That worked and everything went through.

I rated a song in GoneMad Player.

Then, I reinstalled the sync app and gave it all permissions. When asked what folder to use, on the first test I just chose my Music folder. Then synced. No change to the rating of the song in desktop MusicBee.

Then I deleted the app again and reinstalled it to be able to choose a different folder (you can only choose a folder once). This time, I chose the sub folder all of my music is in. So on my phone, the structure is MUSIC/SUB_FOLDER/music files (thousands of songs some in that directory and some in further directories organized by their individual albums).

That "synced" but didn't change anything on my Musicbee desktop side, either. That song I rated in GoneMad is still unrated in MusicBee on desktop, and the musicbee sync app produced an error message that looks like this:  https://imgur.com/a/OEkJVS4



Then I tried it a third time with the same setup as the last time, only with the special permission you noted, since I didn't read your response here until I started it this third time. No change.

I did all of that and finally realized the setting in MusicBee desktop to allow for two way syncing is unchecked. But it's not even checkable; it's greyed out, and  I don't know how to actually make it checkable. So...yeah :/

BoringName

  • Full Member
  • ***
  • Posts: 197
The first time, I already had the music on my phone and computer so I thought maybe some folders weren't reading each other. So tonight, I deleted all of the music off of my phone and deleted the app. I wired synced my music from desktop (musicbee) to my phone. That worked and everything went through.

I rated a song in GoneMad Player.
Then, I reinstalled the sync app and gave it all permissions. When asked what folder to use, on the first test I just chose my Music folder.

I believe the app syncs ratings and play counts based on what has changed since the last sync. It gets this info from GoneMad. It doesn't compare every song on your PC with every song on your phone for every sync. Because you changed the rating while the app wasn't installed it might not have flagged the song as having the ratings changed.

So give this a shot.
Leave all the Music on the phone.
Uninstall the Music Bee app.
Re-Install the Music Bee app and Select the "Music" folder you did initially.
Run a Sync - If that works successfully keep going with these steps otherwise reply here it didn't work.
Change a rating of a song in GoneMad. Also play a different song all the way through.
Run another sync
Check MusicBee on your PC to see if the rating and play counts updated on the 2 songs.

edit: Don't worry about that 2 way setting that is greyed out. That is a legacy setting that isn't used anymore. The wifi app will still sync play counts and ratings with that setting unchecked.

phred

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 9237
The wifi app will still sync play counts and ratings with that setting unchecked.
Just to be (more) clear: these options must first be enabled in the WiFi Sync app.
Download the latest MusicBee v3.5 patch from here.
Unzip into your MusicBee directory and overwrite existing files.

----------
The FAQ
The Wiki
Posting screenshots is here
Searching the forum with Google is  here

ome-reily

  • Newbie
  • *
  • Posts: 19
The first time, I already had the music on my phone and computer so I thought maybe some folders weren't reading each other. So tonight, I deleted all of the music off of my phone and deleted the app. I wired synced my music from desktop (musicbee) to my phone. That worked and everything went through.

I rated a song in GoneMad Player.
Then, I reinstalled the sync app and gave it all permissions. When asked what folder to use, on the first test I just chose my Music folder.

I got the note that in synced successfully, but it did not, in fact, push any rating updates to MusicBee. I tried a few times.
I believe the app syncs ratings and play counts based on what has changed since the last sync. It gets this info from GoneMad. It doesn't compare every song on your PC with every song on your phone for every sync. Because you changed the rating while the app wasn't installed it might not have flagged the song as having the ratings changed.

So give this a shot.
Leave all the Music on the phone.
Uninstall the Music Bee app.
Re-Install the Music Bee app and Select the "Music" folder you did initially.
Run a Sync - If that works successfully keep going with these steps otherwise reply here it didn't work.
Change a rating of a song in GoneMad. Also play a different song all the way through.
Run another sync
Check MusicBee on your PC to see if the rating and play counts updated on the 2 songs.

edit: Don't worry about that 2 way setting that is greyed out. That is a legacy setting that isn't used anymore. The wifi app will still sync play counts and ratings with that setting unchecked.


ome-reily

  • Newbie
  • *
  • Posts: 19
As another clue, I just now tried this adding in the playcounts as a sync option, and this time it showed the five songs or so that I had updated the rating for and played through on my phone with an error message saying the file could not be found in musicbee and so the playcount was not updated. When I just do the ratings box checked, I get the success message, but nothing actually changes in musicbee.