x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

Adding custom files to the Android content.

Hi.

I'm currently implementing a third party library to the UE4. The library itself is already implemented and it's initializing but to the proper work it needs a path to the file (the certificate, precisely).

On Windows it's easy, I'm just putting the file into the MyProject\Content directory and then I'm getting the path using:

 FString FullCAPath = FPaths::GameContentDir() + "/ca.pem";

But when I'm trying to add this file to the Android apk, or iOS ipa... well, I'm lost here. The builder is not packing all files from the Content folder. How should it be done?

Product Version: Not Selected
Tags:
more ▼

asked Oct 21 '14 at 12:50 PM in Using UE4

avatar image

zompi2
650 24 48 145

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

3 answers: sort voted first

Open packaging settings for your project and add your folder containing your cert file in non-asset folders to package list.

more ▼

answered Oct 21 '14 at 01:19 PM

avatar image

TimGS
621 20 23 237

avatar image zompi2 Oct 21 '14 at 02:23 PM

That was it, thanks :)

But I have few more questions:

What's a difference between "Additional Non-Asset Directories to Package" and "Additional Non-Asset Directories to Copy" ?

FPaths::GameContentDir() returns ../../../MyProject/Content/ (the Windows path) and the file is in /storage/emulated/0/MyProject/MyProject/Content/ (I build in Development Configuration). Is there a method to get a correct path? When the game will be built to the apk... will be there even a possibility to pass a file path?

avatar image TimGS Oct 21 '14 at 05:43 PM

The difference is there when you use PAK file. In that case To Package means to add folder to PAK file and To Copy means just to copy it to cooked Contents directory.

Do you check FPaths::GameContentDir() on your device or in editor?

avatar image zompi2 Oct 22 '14 at 07:50 AM

I checked it on device.

avatar image daihao81 Jun 04 '15 at 02:26 AM

Hi, I have a same problem on ios. Have you found a correct path to find the custom files on ios?

avatar image zompi2 Jun 10 '15 at 07:58 AM

Hi

I almost forgot about this question.

I've solved the problem in the meantime, I've posted the solution in the answer.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

Well, it's quite complicated, but for now to get proper absolute path to the content file I'm using such code:

 FString AbsoluteContentPath = GFilePathBase + TEXT("/") + GGameName + TEXT("/") + FString::Printf(TEXT("%s/Content/"), FApp::GetGameName());

For development mode works well.

more ▼

answered Nov 13 '14 at 02:15 PM

avatar image

zompi2
650 24 48 145

avatar image MorskoyZmey Nov 28 '15 at 08:28 AM

It works with Launch, but when packaging APK, files don't appear in that folder.

Actually my version:

GFilePathBase + FString("/UE4Game/") + FApp::GetGameName() + TEXT("/") + FApp::GetGameName() + FString("/Content");

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

On UE 4.7.3 I found a better solution.

On Android I'm using a PathToAndroidPaths function from Engine\Source\Runtime\Core\Private\Android\AndroidFile.cpp

On IOS I'm using a ConvertToIOSPath function from Engine\Source\Runtime\Core\Private\IOS\IOSPlatformFile.h

On PC I'm using a FPaths::ConvertRelativePathToFull function from Engine\Source\Runtime\Core\Public\Misc\Paths.h

Most of those function are private, so I made a new, public function that use them for converting relative path to the absolute one.

The ConvertRelativePathToFull from FPaths works correctly only for PC, it doesn't return correct absolute paths for mobile devices.

more ▼

answered Jun 10 '15 at 07:57 AM

avatar image

zompi2
650 24 48 145

avatar image FrankKappaPride Mar 03 '16 at 06:40 PM

Hi, I am facing the same problem right now. My content seems to not get packaged. Instead all of them are stored in the obb file (my guess). May I ask how you go around it?

avatar image zompi2 Mar 04 '16 at 07:04 PM

I think this is a desirable situation that the content goes to OBB file. If You want to have something in APK the best option is tu put them to the YourGame/Build/Android/assets directory. But even then they won't be accessible by UnrealEngine easily. I wrote a function that copies files from assets to external storage. I relied on this solution: http://stackoverflow.com/questions/4447477/android-how-to-copy-files-from-assets-folder-to-sdcard

There is also somethin like put obb into apk option, but never tried it :/

When I go back to work on Monday I'll try to dig around my old code, because this is quite twisted problem and put the official solution with paths ;)

avatar image FrankKappaPride Mar 04 '16 at 10:44 PM

Thanks for replying! I will look into that.

I am relatively new to Android development so I am a bit confused about how Android system works, especially with Unreal. From my understanding, Unreal packages a project with an apk file (not sure whats inside) and an obb file(Content folder of the project). After it is installed, the obb file is located at external storage while the apk is broke down into base.apk and serveral so file in data/data/app. Is my understanding correct?

Also I heard some rumors about app not allowed to access certain areas of the android system. Like https://commonsware.com/blog/2014/04/09/storage-situation-removable-storage.html

Sorry for the amount of questions :/

avatar image zompi2 Mar 05 '16 at 10:23 PM

Well, Android always confuses me more than iOS. I hope someone else will tell if we are correct, but anyway, this is how it works (I think) ;)

First of all - all content goes to OBB. You can decide which one goes to a PAK file and which one are outside of it, but the main design of Android is that content goes to the OBB.

If You really want to have files inside the APK, then the assets or raw directory is a good place (I recommend the assets directory, the raw directory had some issues with ant build scripts).

Where the files are... it depends how you deploy to the Android. If you run it via Unreal Frontend then all files are places in the /sdcard/UE4Game/YourApp/ If you install it from APK+OBB then the files are located in the /sdcard/Android/data/com.YourCompany.YourApp The APK data are stored in /data/data/YourApp

Unfortunately, the APK and OBB files are hidden because of the security reasons and, without rooting it, it is not possible to check them. This is why when You deploy using Unreal Frontend files are put into the public place so You can check what is going on.

And this is the major issue - if you need other application or library to have a direct access to the file that is inside the APK you need to move this file somewhere else, where it is public.

But hey... UnrealEngine uses content from OBB so it can be read! They are probably read by methods from AndroidFile.cpp but using it is kinda painful...

At this point it depends on what You are trying to do. With this information we might find a solution ;)

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question