[Solved] UE4 Error: Couldn‘t find file for package *** requested by async loading code. NameToLoad: ***

The dynamic loading of some resources fails when a map is packaged separately. The error log is as follows:

[2022.06.16-09.06.47:875][  0]LogStreaming: Error: Couldn't find file for package /SarajePlayerUI/UI/WBP_SarajePlayerRecommendBar requested by async loading code. NameToLoad: /SarajePlayerUI/UI/WBP_SarajePlayerRecommendBar
[2022.06.16-09.06.47:875][  0]LogStreaming: Error: Found 0 dependent packages...
[2022.06.16-09.06.47:875][  0]PIE: Error: CreateWidget called with a null class.

This problem is very strange. In the self-developed plug-in directory, other resources can be loaded with c++ code, but only the following materials cannot be loaded successfully:

UClass* WidgetClass = LoadClass<UUserWidget>(nullptr, TEXT("WidgetBlueprint'/SarajePlayerUI/UI/WBP_SarajePlayerPreview.WBP_SarajePlayerPreview_C'"));

Solution:

Add the directory where the resource is located in Additional Asset Directories to Cook of packaging settings (screenshot as below):

Read More: