0

I am trying to load an image and a text file using the AAssetManager in the Android Native Activity in VS 2019. I've tried every combination of paths I could think of to get AAssetManager_openDir or AAssetManager_open to give me a file. Solutions I've found elsewhere were related to incorrect paths or the AAssetManager object wasn't valid.

Here is how I'm trying to get access to my image and text files.

 AAssetManager* pMan = m_pApp->activity->assetManager; AAsset* pAsset = AAssetManager_open(pMan, "drawable\\testpng", AASSET_MODE_BUFFER); // Always returns NULL AAssetDir* pAssetDir = AAssetManager_openDir(pMan, "res\\drawable"); const char* szFilename; while ((szFilename = AAssetDir_getNextFileName(pAssetDir)) != NULL) { // 'szFilename' is always NULL and this print never gets hit __android_log_print(ANDROID_LOG_DEBUG, "Debug", szFilename); } 

This is my Android.Packaging project.

Android Package Project

Android Manifest

<string name="testpng">drawable\test.png</string> <string name="testdrawtxt">drawable\testtext.txt</string> <string name="testpng2">drawable\assets\test2.png</string> <string name="testdrawtxt2">drawable\assets\testtext2.txt</string> 

And finally the actual output directory Resources output directory

The asset manager is valid as far as I know. What am I doing wrong?

2
  • Assets should not be under res, but on the same level of hieararchy. Commented Oct 19, 2019 at 20:06
  • 1
    That was it! I spent too long on this and I was just putting it in the wrong directory. I created a folder called "assets" next to the "res" folder and put the items inside there. Simply calling AAssetManager_open(pMan, "test.png", AASSET_MODE_BUFFER) worked with no problems. Thanks very much. Why not post it as an answer? Commented Oct 19, 2019 at 20:26

1 Answer 1

1

Assets should not be under res, but on the same level of hieararchy.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.