Unity-Technologies / Addressables-Sample

Demo project using Addressables package
1.29k stars 298 forks source link

Play Asset Delivery sample silently fails if bundle names conflict #78

Open AmericanFarming opened 2 years ago

AmericanFarming commented 2 years ago

The Play Asset Delivery example has a number of issues, such as failing silently if a bundle name already exists during build. So if you have the same bundle name in two different paths, when it condenses it all down into the PlayAssetDelivery/Build folder it conflicts and throws an error that you never see because the build process clears the console window afterward. This exception handler is also outside of the loop, so it just fails and skips the rest of the bundles entirely instead of ignoring the conflicting bundle. This causes the PAD build process to abort but the rest of the build to continue, so you end up with a broken build containing only some of your assets and no indication as to why.

See PlayAssetDeliveryBuildProcessor.cs (MoveDataForAppBundleBuild)

So if you are building and yet only some bundles are actually making it into the AAB file even though it seems to succeed, this could be why. This is also across ALL groups so if one group has the problem, any subsequent groups will not build.

durstel47 commented 9 months ago

Here the loop, where the PlayAssetDeliveryBuildProcessor.cs fails in the 'File.Move()' function:

               foreach (BuildProcessorDataEntry entry in data.Entries)
               {
                   string assetsFolderPath = Path.Combine( 
                   CustomAssetPackUtility.PackContentRootDirectory, 
                   entry.AssetsSubfolderPath);
                   if (File.Exists(entry.BundleBuildPath))
                   {
                       string metaFilePath = 
                       AssetDatabase.GetTextMetaFilePathFromAssetPath(entry.BundleBuildPath);
                       File.Move(entry.BundleBuildPath, assetsFolderPath);
                       File.Delete(metaFilePath);
                   }
               }

The reason is that the assetFolderPath is an invalid combination of the "CustomAssetPackUtility.PackContentRootDirectory" using a '/' directory separator and the entry.AssetsSubfolderPath using a '\' separator thus producing an invalid target path. Here an example Pack content root path: "Library/com.unity.addressables/aa/Android/Android/onfastfollowswitzerland1_assets_all_b3fa04e36f4368e06a76451666cd722c.bundle" entry.AssetsBundleBildPath: "Assets/PlayAssetDelivery/Build/CustomAssetPackContent" entry.AssetsSubfolderPath: "\src\main\assets\onfastfollowswitzerland1_assets_all_b3fa04e36f4368e06a76451666cd722c.bundle" Final invalid target path resulting in exception "Exception occured when moving data for an app bundle build: Could not find a part of the path..": "Assets/PlayAssetDelivery/Build/CustomAssetPackContent\CustomFastFollow.androidpack\src\main\assets\onfastfollowswitzerland1_assets_all_b3fa04e36f4368e06a76451666cd722c.bundle".

Hopefully we will get a correction of this bug very soon...