Hello! I’ve been having this issue that’s been driving me nuts! I have an android application attempting to read a simple .txt file. All it says is “This better work please” in UE 4.27
When I press LAUNCH to run the application on my phone it works pefectly fine, however, when I PACKAGE, and install the .apk using the installer (WHICH INCLUDES THE OBB) the text doesn’t show up.
I’ve tried adding the folder to additional non-asset directories to copy and additional non-asset directories to package and neither work, I also added the folder to additional asset directories to cook. I’ve tried different combinations as well. Disabling to copy but keeping to package and vice-versa.
Using datatables is not an option since the idea of the text files is that they’re user facing, meant to be edited beforte the application opens.
When opening the OBB file via WinRar I see that the text file is there, yet still unable to be read by the application.
I switched to a shipping build still nothing, I’ve tried editing the CopyBuildToStagingDirectory.Automation.cs and adding this line of code, still nothing:
SC.StageFiles(StagedFileType.UFS, CombinePaths(SC.ProjectRoot, "Content/Thing"), "*", true, null, CombinePaths(SC.RelativeProjectRootForStage, "Content/Thing"), true, !Params.Pak);
I’ve tried ConvertRelativePathToFull, still nothing. Essentially all the answers I could find on here aren’t working.
Here’s my code:
FString directory = FPaths::ProjectContentDir() + _filePath;
FString directory_fin = FPaths::ConvertRelativePathToFull(directory);
GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Yellow, "THE DIRECTORY IS: " + directory_fin);
UE_LOG(LogTemp, Warning, TEXT("Diectory is: %s"), *directory);
IPlatformFile& file = FPlatformFileManager::Get().GetPlatformFile();
//Used when
if (file.CreateDirectory(*directory_fin))
{
//Get data from a single file in directory.
FString myFile = directory_fin + _fileName + ".txt";
FFileHelper::LoadFileToString(_csvText, *myFile);
GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Yellow, "THE FILE IS: " + myFile);
GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Yellow, "THE TEXT IS: " + _csvText);
Are there any other ideas? Anything I’ve missed? I feel like I’ve dug deep and still can’t find an answer. If there’s any new information or solutions about these issues in 2022 I’d love to know! Thank you. If there’s any more information I need to provide let me know.
EDIT: The only thing I can think of is that IPlatformFile has trouble with the android platform, but then why does the build work when pressing LAUNCH, even after unplugging the phone. This app is meant for Oculus, but I’m testing the bit of code I’m using on the bigger project on a smaller test project that I’m building to my phone. Same issues, launch works package doesn’t. Both are android platforms.