Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Assets Folder Not Getting Added To Android Studio Project and APK

I'm trying to add an Assets folder to my Android Project in Android Studio 2.1.2. I right click on the project and choose New -> Folder -> Assets Folder. In the project pane on the left, it doesn't show up when Android is selected. If I switch to Project Files, it does appear, however it looks like a normal directory, rather than looking like a resource directory. I then tried adding files to it (jpgs), both through Android Studio and through the file explorer (all file names are lowercase with no special characters). If you unzip the apk that gets created though, it doesn't contain an Assets directory or the added files. Also sometimes the assets directory will disappear from the project files pane, although it's still in explorer.

What step am I missing to get to the Assets directory properly added to my project?

Note: this is for a LibGdx project that expects image files to be there.

like image 326
Nullqwerty Avatar asked Jul 26 '16 13:07

Nullqwerty


1 Answers

Finally got it. Appears to be a bug in Android Studio, but to make it work, in the Project pane, go to Android view and (this next part is critical) right click on the res folder and go to New->Folder->Assets folder. You might want to click change folder location to be sure it's going into the main folder (mine was) just to be on the safe side.

You must right click on the res folder. That was my issue. If you right click on the module or anywhere else, even though the folder will get created in the proper spot, Android Studio and gradle won't treat it as a resource directory and just ignores it.

like image 133
Nullqwerty Avatar answered Sep 23 '22 21:09

Nullqwerty