Where to place the 'assets' folder in Android Studio?

Android StudioAndroid Assets

Android Studio Problem Overview


I am confused about the assets folder. It doesn't come auto-created in Android Studio, and almost all the forums in which this is discussed talk about Eclipse.

How can the Assets directory be configured in Android Studio?

Android Studio Solutions


Solution 1 - Android Studio

Since Android Studio uses the new Gradle-based build system, you should be putting assets/ inside of the source sets (e.g., src/main/assets/).

In a typical Android Studio project, you will have an app/ module, with a main/ sourceset (app/src/main/ off of the project root), and so your primary assets would go in app/src/main/assets/. However:

  • If you need assets specific to a build type, such as debug versus release, you can create sourcesets for those roles (e.g,. app/src/release/assets/)

  • Your product flavors can also have sourcesets with assets (e.g., app/src/googleplay/assets/)

  • Your instrumentation tests can have an androidTest sourceset with custom assets (e.g., app/src/androidTest/assets/), though be sure to ask the InstrumentationRegistry for getContext(), not getTargetContext(), to access those assets

Also, a quick reminder: assets are read-only at runtime. Use internal storage, external storage, or the Storage Access Framework for read/write content.

Solution 2 - Android Studio

Let Android Studio do it for you.

  1. In Android Studio (1.0 & above), right-click on the enter image description here folder and navigate to the Assets Folder.

enter image description here

  1. On the next screen just click Finish.

enter image description here

And voila! It will create the assets folder in the main target source set.

enter image description here

Solution 3 - Android Studio

Looking inside the .iml file of your project you will see the following line:

 <option name="ASSETS_FOLDER_RELATIVE_PATH" value="/src/main/assets" />

This means the "assets" folder is already declared for Gradle. You will need to create it under src/main/ (I'm using Android Studio 0.4.2).

Solution 4 - Android Studio

Select the app folder and then:

File > New > folder > assets Folder ,

enter image description here

the default location is inside /main folder

enter image description here

Solution 5 - Android Studio

First of all the "Assets" folder will not be created automatically with the project. We have to create it.

The location of Assets folder is: App > src > Assets

Please have a look of the simple image below.

enter image description here

Note: For creating assets folder just click on Project => Right click => Select New => Folder => Assets. It will create Assets folder.

Solution 6 - Android Studio

It's simple, follow these steps

File > New > Folder > Assets Folder

Note : App must be selected before creating folder.

Solution 7 - Android Studio

In android studio you can specify where the source, res, assets folders are located. for each module/app in the build.gradle file you can add something like:

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.1"

    sourceSets {
        main {
            java.srcDirs = ['src']
            assets.srcDirs = ['assets']
            res.srcDirs = ['res']
            manifest.srcFile 'AndroidManifest.xml'
        }
    }
}

Solution 8 - Android Studio

Simply, double shift then type Assets Folder

choose it to be created in the correct place

Solution 9 - Android Studio

Click over main → new -> directory → and type as name "assets"

or... main -> new -> folder -> assets folder (see image)

enter image description here

Solution 10 - Android Studio

File > New > folder > assets Folder

Assets Folder

Solution 11 - Android Studio

In Android Studio 4.1.1

Right Click on your module (app for example) -> New -> Folder -> Assets Folder

enter image description here

Solution 12 - Android Studio

right click on app folder->new->folder->Assets folder->set Target Source set->click on finish button

Solution 13 - Android Studio

Two ways:

  1. Select app/main folder, Right click and select New => Folder => Asset Folder. It will create 'assets' directory in main.

  2. Select main folder, Right click and select New => Directory Enter name as 'assets' = > Ok.

enter image description here

Solution 14 - Android Studio

If you tried all your bullets in this thread in vain try cleaning your project . In my case it only worked after Projet -> clean

Solution 15 - Android Studio

Put the assets folder in the main/src/assets path.

Solution 16 - Android Studio

Src/main/Assets

It might not show on your side bar if the app is selected. Click the drop-down at the top that says android and select packages. you will see it then.

Solution 17 - Android Studio

When upgrading to the release version of Android Studio, you may be automatically switched to the new Android project View (see here for more info). If you swap back to either the Project or Packages view, you should see the standard folder hierarchy of a Gradle-based project. Then refer to CommonsWare's answer for the appropriate location.

Solution 18 - Android Studio

Project -> app -> src -> main -> RMB(right mouse button) -> New -> Directory:

enter image description here

enter image description here

Solution 19 - Android Studio

need configure parameter for gradle
i hope is will work

// file: build.gradle  
sourceSets {
    main {
        assets.srcDirs = ['src/main/res/icon/', 'src/main/assets/']
    }
}

Solution 20 - Android Studio

In Android Studio, click on the app folder, then the src folder, and then the main folder. Inside the main folder you can add the assets folder.

Solution 21 - Android Studio

Step 1 : Go to Files. Step 2 : Go to Folders. Step 3 : Create Assets Folder.

In Assets folder just put fonts and use it if needed.

Solution 22 - Android Studio

follow these steps 

1)file->New->Folder
 there are multiple options like
      aidl folder
      assets folder
      jni folder
2) choose options assets folder
3) then there is option to change path of assets folder if you 
    want to change then check otherwise left that checkbox of cahnge folder location
4) click on finish 

Solution 23 - Android Studio

Either create a directory under /app/src/main or use studio File-> New -> Folder - > Assets Folder.

Solution 24 - Android Studio

In Android Studio right-click Folder in app->src->main then create new DIRECTORY name that assets.

Solution 25 - Android Studio

It seems that nobody mentioned this:
You can define it in Project Structure > Project Settings:

enter image description here

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionhvkaleView Question on Stackoverflow
Solution 1 - Android StudioCommonsWareView Answer on Stackoverflow
Solution 2 - Android StudioPrinceView Answer on Stackoverflow
Solution 3 - Android StudioMiguel El MerenderoView Answer on Stackoverflow
Solution 4 - Android StudioJorgesysView Answer on Stackoverflow
Solution 5 - Android StudioLovekush VishwakarmaView Answer on Stackoverflow
Solution 6 - Android StudioPankaj kumarView Answer on Stackoverflow
Solution 7 - Android StudioSportman AppmanView Answer on Stackoverflow
Solution 8 - Android StudioMohammad AlotolView Answer on Stackoverflow
Solution 9 - Android StudioPablo CegarraView Answer on Stackoverflow
Solution 10 - Android StudioGowtham SubramaniamView Answer on Stackoverflow
Solution 11 - Android StudioAmrDeveloperView Answer on Stackoverflow
Solution 12 - Android StudioShraddha PatelView Answer on Stackoverflow
Solution 13 - Android StudioTejpalBhView Answer on Stackoverflow
Solution 14 - Android StudiozizoujabView Answer on Stackoverflow
Solution 15 - Android Studiouser7868389View Answer on Stackoverflow
Solution 16 - Android StudioS.DoyleView Answer on Stackoverflow
Solution 17 - Android StudiostkentView Answer on Stackoverflow
Solution 18 - Android StudioВладислав ШестернинView Answer on Stackoverflow
Solution 19 - Android StudiomadjardiView Answer on Stackoverflow
Solution 20 - Android StudioDharmendra PratapView Answer on Stackoverflow
Solution 21 - Android StudioDeep AdhiaView Answer on Stackoverflow
Solution 22 - Android Studioindrajeet jyotiView Answer on Stackoverflow
Solution 23 - Android StudioDurgeshView Answer on Stackoverflow
Solution 24 - Android Studioshohruh MaxmudovView Answer on Stackoverflow
Solution 25 - Android StudioShamshirsaz.NavidView Answer on Stackoverflow