Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Bug PAD Unity 2021.3 not created src/main/assets/ automatically for custom asset bundle

Discussion in 'Android' started by restush96, Jan 23, 2023.

  1. restush96

    restush96

    Joined:
    May 28, 2019
    Posts:
    120
    A few notes :
    - I use Addressable sample https://github.com/Unity-Technologies/Addressables-Sample/tree/master/Advanced/Play Asset Delivery
    - I'm on Unity 2021.3.16f1
    - Using Unity 2020.3.19f is working (no errors).

    So I have an error like this when build android Unity 2021.3
    Code (CSharp):
    1. FAILURE: Build failed with an exception.
    2. * What went wrong:
    3. Execution failed for task ':launcher:assetPackReleasePreBundleTask'.
    4. > Multiple task action failures occurred:
    5.    > A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
    6.       > C:\Unity Projects\unity_pad_built_in_example-main\Library\Bee\Android\Prj\IL2CPP\Gradle\CustomCharacters\src\main\assets
    7.    > A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
    8.       > C:\Unity Projects\unity_pad_built_in_example-main\Library\Bee\Android\Prj\IL2CPP\Gradle\CustomFastFollow\src\main\assets
    9.    > A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
    10.       > C:\Unity Projects\unity_pad_built_in_example-main\Library\Bee\Android\Prj\IL2CPP\Gradle\CustomOnDemand\src\main\assets
    11.  
    When I check, the “custom asset (BUNDLE file)” didn’t put into folder src/main/assets/ or missing. Here is the screenshot that there is no “src” folder. Then the fastfollowcontent_xxxx.BUNDLE Unity automatically move there, which is wrong.


    So this is src folder thing were generated on UnityDataAssetPack, but not for CustomAssets. Here screenshot.


    Then I created folder “src/main/assets/” manualy for CustomAssets. Here screenshot.

    Then, put the BUNDLE inside “assets” folder. Here screenshot.

    Then the build WORKS.

    I also test on google play store and it detect the bundle . Here screenshot.


    So, the question is why Unity 2021.3 did not create “src/main/assets/” automatically for custom asset and put the BUNDLE file in there? In Unity 2020.3.19f, it can create “src/main/assets/” folder automatically for custom asset.
     
    Last edited: Jan 23, 2023
  2. restush96

    restush96

    Joined:
    May 28, 2019
    Posts:
    120
    I tried my main project and can still reproduce the issue. For workaround, need to create folder src/main/assets/.

    upload_2023-1-24_23-19-4.png
     
  3. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,638
    I believe this is a change we made not so long ago.
    We stopped moving files around, instead we now require asset pack directory to be of correct format. The idea is that if you make custom asset pack in Android Studio, you just move the entire folder to Unity giving it .androidpack extension and it works.
     
  4. restush96

    restush96

    Joined:
    May 28, 2019
    Posts:
    120
    I see.

    After some time. I edited a bit the Addressable Sample - Play Asset Delivery to automatically create src/main/assets on build. So everything is fine now.

    upload_2023-1-25_11-9-5.png


    For someone that have same problem like me, you can edit the method called CreateConfigFiles in BuildScriptPlayAssetDelivery.cs. Just add string of src, main, assets.
    upload_2023-1-26_4-18-50.png

    Then, edit the method of CreateAssetPackDirectory in BuildScriptPlayAssetDelivery.cs, to create folder src/main/assets automatically if doesn't exist upload_2023-1-26_4-21-50.png
     
    BogdanLysogora and RakNet like this.
  5. Flexford

    Flexford

    Joined:
    Dec 8, 2016
    Posts:
    20
  6. restush96

    restush96

    Joined:
    May 28, 2019
    Posts:
    120
  7. restush96

    restush96

    Joined:
    May 28, 2019
    Posts:
    120
    "Closing this in favor of the new com.unity.addressables.android package that should be released soon" based on the resolution.

    So it's been a month, any news about com.unity.addressables.android?
     
  8. boriss_unity

    boriss_unity

    Unity Technologies

    Joined:
    Oct 11, 2017
    Posts:
    2
    The package is being actively worked on, but there is no release date yet.
     
  9. dthurn

    dthurn

    Joined:
    Feb 17, 2015
    Posts:
    77
    "we're closing this bug because we're planning to fix it at some unspecified point in the future"? I mean.... cool...
     
  10. Chuck_Equinox

    Chuck_Equinox

    Joined:
    May 9, 2023
    Posts:
    1
    I keep saying "Quit bugging me, I'm planning on taking out the garbage mom."
     
  11. irfanbaysal1997

    irfanbaysal1997

    Joined:
    Sep 17, 2018
    Posts:
    6
    In windows machines I can create CustomOnDemand folder by adding "src","main","assets" however in Mac this file is not generated. Has anyone experienced this issue?
     
  12. Thorax-

    Thorax-

    Joined:
    Feb 10, 2021
    Posts:
    20
    I am using Unity 2020.3.30 and Addressables 1.21.12. In my case the src/main/assets folders are not automatically created by the Play Asset Delivery Build script. The bundle which is set to on-demand delivery is not placed in the CustomOnDemand.androidpack folder. However that folder (CustomOnDemand.androidpack) is created correctly for any on-demand or fast-follow addressable bundle that I create and the build.gradle is created correctly as well as the json file. Inside the json i can clearly see the names of all the asset bundles which are assigned to that asset pack.

    However when building aab and uploading to Google the asset packs are not recognised. There is only one Asset pack which is Install time --> all other asset bundles are set to instal-time:

    img.png
    I tried to edit the script to create the src/main/assets folders as described by @restush96 but the bundle is still not placed in that folder when I build the Addressables and also the .aab build fails with an error:
    Screenshot 2023-08-21 at 17.49.11.png

    Any help would be appreciated.
     
  13. restush96

    restush96

    Joined:
    May 28, 2019
    Posts:
    120
    @Thorax- Hey, I'm not sure if I could help you. I believe the addressable version cause the error and seems like I forget to mention my addressable version in the first post.

    Your error is because there is no directory in `Temp/StagingArea/.../Season2OnDemand`. Also my edited script is on Unity 2021 so you should try upgrade your Unity first, and make sure before/after upgrade try delete `Library` folder. Don't forget to backup first.
     
  14. Thorax-

    Thorax-

    Joined:
    Feb 10, 2021
    Posts:
    20
  15. Thorax-

    Thorax-

    Joined:
    Feb 10, 2021
    Posts:
    20
    @restush96 I notice you are getting your on-demand .bundle files generated inside the CustomAseetPackContent folder. No matter what I do or which Unity + Addressables versions I am using these bundles are always placed in the same folder as all others --> ../com.unity.addressables/aa/Android/Android/

    These are the settings for the on-demand bundle that I am trying to test with:
    Screenshot 2023-08-23 at 10.46.27.png

    Is it normal that bundles are not placed in the custom asset pack folder to which they are assigned?
    Is it possible that I am missing something in the setup of the PAD. I tried to follow thoroughly the Unity PAD Example but it's possible that I am missing something important.

    I opened another thread with more info regarding my problem here:
    https://forum.unity.com/threads/play-asset-delivery-with-addressables.1480656/#post-9240372

    I also write in here because I think the two problems have something in common.
     
  16. restush96

    restush96

    Joined:
    May 28, 2019
    Posts:
    120
    Just to make sure, have you delete library after upgrade? Also please attach full error messages.
     
  17. Thorax-

    Thorax-

    Joined:
    Feb 10, 2021
    Posts:
    20
    I deleted the Library folder before the upgrade on closed editor and performed the upgrade. Anyway I have some serious progress:

    I reduced my Addressables version to 1.19.19 - same as yours. And I am using Unity 2020.3.30f1. The bundle files are not generated inside the Custom asset packs folders but it is ok because Google detects them once the aab is uploaded for testing. Additionally I made the on-demand bundle to be packed Together. It used to be packed separately - I am not sure if this is important. Further tests will clarify this.

    Anyway I am experiencing the following behaviour now:
    I download the test app from Play store - the size is reduced as expected because there is on-demand content.
    - Before starting the game the size occupied on the phone is 183MB
    - After first launch of game and NOT accessing any of the on-demand content the size occupied on the deivce increases to 206MB.
    - When I attempt to open a level from the on-demand bundle - which I am loading using the Addressables API I get to here:

    Screenshot 2023-08-23 at 18.21.16.png

    Screenshot 2023-08-23 at 18.25.31.png

    After the "Trying to download pack: CustomOnDemand" log the app now occupies 216MB, which means something got downloaded, but my game is stuck in the loading screen (which disappears once the level is loaded by the addressables api). I receive no errors or logs of any sort after that moment. The try/catch also doesn't throw any errors.

    Once I received an error on this same build upon trying to load the on-demand asset pack but never saw that error again. Reinstalled the app several times but for now it doesn't show up anymore.
    error1.png
     
    Last edited: Aug 23, 2023
  18. restush96

    restush96

    Joined:
    May 28, 2019
    Posts:
    120
    Based on your errors seems like it does build but failed when retrieve the assets, so it's different with my issue.
    How is your method to get your bundle? Does your on demand assets detected on store?

    Also on Unity 2020 I didn't modified the `BuildScriptPlayAssetDelivery.cs` and it works as expected.
     
    Last edited: Aug 23, 2023
  19. Thorax-

    Thorax-

    Joined:
    Feb 10, 2021
    Posts:
    20
    Sorry for late reply.

    Here is how I am loading the on-demand asset:

    Code (CSharp):
    1. private void LoadLevel()
    2. {
    3.     Debug.Log($"Loading Level: {currentLevel}");
    4.     var operation = Addressables.LoadAssetAsync<LevelSO>(levelPath);
    5.     operation.Completed += (asyncOperationHandle) =>
    6.     {
    7.         Debug.Log($"Loading level {currentLevel} is completed.");
    8.         if (asyncOperationHandle.Status == UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationStatus.Succeeded)
    9.         {
    10.              Debug.Log("Getting Level prefab");
    11.              levelAsset = asyncOperationHandle.Result;
    12.              CurrentLevelPrefab = Instantiate(asyncOperationHandle.Result.LevelPrefab);
    13.         }
    14.     };
    15.  
    16.     operation.WaitForCompletion();
    17.        
    18.     Debug.Log($"Loading Operation is completed for level: {currentLevel}. Initialising managers...");
    19.      ...
    20. }
    When i try to load the level the printed lines are in the following order:
    Loading level: 75
    Trying to download pack: CustomOnDemand - this log is from PlayAssetDeliveryAssetBundleProvider.cs

    Nothing else gets printed. LevelSO is a Scriptable object containing the level prefab. Is it possible that the .WaitForCompletion() call is somehow blocking the download process and therefore nothing happens? In the same way I am loading the levels which are in the instal-time bundles and they are loading without problem.

    The on-demand pack is correctly displayed in Google:
    image_2023_08_25T11_45_51_598Z.png image_2023_08_28T07_15_30_873Z.png
    Tried with and without 'Split Application Binary option'.
     
    Last edited: Aug 28, 2023
  20. restush96

    restush96

    Joined:
    May 28, 2019
    Posts:
    120
    You need to use
    AndroidAssetPacks.GetAssetPackStateAsync(listToDownload);
    and wait for its completion. After complete, it will return list pack state that need to update/download. Then try download the pack by
    AndroidAssetPacks.DownloadAssetPackAsync(packs)
    .

    I also realized that I remember initialize addressable manually before download using `
    await Addressables.InitializeAsync(true)
    `.
     
    ageana likes this.