Placement of assets folder in Android Studio full release [duplicate] - android

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?

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.

Let Android Studio do it for you.
In Android Studio (1.0 & above), right-click on the folder and navigate to the Assets Folder.
On the next screen just click Finish.
And voila! It will create the assets folder in the main target source set.

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).

Select the app folder and then:
File > New > folder > assets Folder ,
the default location is inside /main folder

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.
Note: For creating assets folder just click on Project => Right click => Select New => Folder => Assets. It will create Assets folder.

It's simple, follow these steps
File > New > Folder > Assets Folder
Note : App must be selected before creating folder.

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'
}
}
}

Simply, double shift then type Assets Folder
choose it to be created in the correct place

Click over main → new -> directory → and type as name "assets"
or... main -> new -> folder -> assets folder (see image)

In Android Studio 4.1.1
Right Click on your module (app for example) -> New -> Folder -> Assets Folder

File > New > folder > assets Folder

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

Two ways:
Select app/main folder, Right click and select New => Folder => Asset Folder.
It will create 'assets' directory in main.
Select main folder, Right click and select New => Directory
Enter name as 'assets' = > Ok.

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

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

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

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.

need configure parameter for gradle
i hope is will work
// file: build.gradle
sourceSets {
main {
assets.srcDirs = ['src/main/res/icon/', 'src/main/assets/']
}
}

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.

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.

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.

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

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

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

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

Related

Cannot set my custom font on View Android [duplicate]

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?
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.
Let Android Studio do it for you.
In Android Studio (1.0 & above), right-click on the folder and navigate to the Assets Folder.
On the next screen just click Finish.
And voila! It will create the assets folder in the main target source set.
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).
Select the app folder and then:
File > New > folder > assets Folder ,
the default location is inside /main folder
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.
Note: For creating assets folder just click on Project => Right click => Select New => Folder => Assets. It will create Assets folder.
It's simple, follow these steps
File > New > Folder > Assets Folder
Note : App must be selected before creating folder.
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'
}
}
}
Simply, double shift then type Assets Folder
choose it to be created in the correct place
Click over main → new -> directory → and type as name "assets"
or... main -> new -> folder -> assets folder (see image)
In Android Studio 4.1.1
Right Click on your module (app for example) -> New -> Folder -> Assets Folder
File > New > folder > assets Folder
Project -> app -> src -> main -> RMB(right mouse button) -> New -> Directory:
Two ways:
Select app/main folder, Right click and select New => Folder => Asset Folder.
It will create 'assets' directory in main.
Select main folder, Right click and select New => Directory
Enter name as 'assets' = > Ok.
If you tried all your bullets in this thread in vain try cleaning your project . In my case it only worked after Projet -> clean
right click on app folder->new->folder->Assets folder->set Target Source set->click on finish button
Put the assets folder in the main/src/assets path.
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.
need configure parameter for gradle
i hope is will work
// file: build.gradle
sourceSets {
main {
assets.srcDirs = ['src/main/res/icon/', 'src/main/assets/']
}
}
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.
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.
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.
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
Either create a directory under /app/src/main or use studio File-> New -> Folder - > Assets Folder.
In Android Studio right-click Folder in app->src->main then create new DIRECTORY name that assets.
It seems that nobody mentioned this:
You can define it in Project Structure > Project Settings:

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.
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.
Be sure to create folder in app/src/main/ and call it assets.
For me in Android Studio 3.6.2, the assets folder wasn't showing up in the "Android" view, no matter where I tried to create it, after trying the other suggestions here. In the "Project" view it showed up in app/assets as a plain folder. I then drag-and-dropped it to src/main/assets and it automatically changed its icon to the same icon as the res folder, and after this it is now also showing up in the "Android" view, so I guess Android Studio is picking it up correctly now, and it appears to be a bug in Android Studio.
If you created a folder in your res directory and named it "assets" and now as "Nullqwerty" mentioned you could not able to solve your problem and you face to the duplication error, just go to the project tab (or press Alt + 1) and in the view mode, change it from "Android" to "Project", then expand all folders in your project to find assets folder in your src\main\res directory (or in src\main path) and right-click on your "assets" folder (if you created it before by adding a "Directory" and named it assets), then change your view mode from "Project" to "Android", again, and right-click on "res" directory->New->Folder->Assets Folder. Then click on "Finish" button to see the assets folder on your main directory as you want. That's it ;)

Android - How do I create the assets folder manually?

I'm new to Android development, and I'm trying to manage projects from the command line using the SDK since I cannot get Android Studio 1.2 to work properly in my system (it's unresponsive).
The problem: I created a new project but the asset folder is missing.
Other SO answers (enter link description here) solve this by creating the folder from the IDE, or by pointing to the asset folder in the .iml file, with doesn't work in my case (I trying to mange the projects from the command line entirely)
There's also a solution editing build.gradle, but the project created from command line (using the SDK) doesn't seem to be a gradle project.
Any help would be appreciated.
Just create a directory called "assets" at the root of your project, i.e. in the same directory your AndroidManifest.xml lives. There's no need to "link that folder from the project". At least that's the case on my system, where I'm using Android SDK 24.4.1 (and I'm not using Gradle -- just emacs and ant).
Once I had assets/fonts/aisauc.ttf in there, the following code...
import android.graphics.Typeface;
...
Typeface greek =
Typeface.createFromAsset(getAssets(), "fonts/aisauc.ttf");
mytextfield.setTypeface(greek);
gave me a TextField with characters from the font I wanted.
How do I create the assets folder manually?
You make it the same you make any directory on your filesystem. Whether you use mkdir or a command-line equivalent, or whether you use your desktop OS's file manager, is up to you.
The default location for an assets/ directory is in a sourceset (e.g., src/main/assets/, to go along with src/main/AndroidManifest.xml and src/main/res/ and src/main/java/, where src/main/ is a sourceset). You can have an assets/ directory located elsewhere, if you choose, but then you will need to configure your build.gradle file to teach Gradle the alternative assets/ location for whatever sourceset you are trying to apply it to.
In your left most sidebar or the sidebar that shows the app, manifests, java... etc, right click app > New > Folder (has the green android symbol next to it) > Assets Folder.
On the next screen leave the path as 'main' and click 'Finish'. Then you can drop whatever asset you want into the folder.

Adding an assets folder in Android Studio

Android Studio has changed its project structure yet again... now it is
project
└── app-module
├── manifests
├── res
└── java
I've been looking everywhere online, but I can't find where to put the assets folder. When I try to create the folder via the directory viewer in Android Studio (right-click, New... directory) the "directory" option is not available. The only available options are:
Java Class
File
Module
Package
Image Asset
None of which will do what I want here.
Has anyone figured this out?
An image of how to in Android Studio 1.5.1.
Within the "Android" project (see the drop-down in the topleft of my image), Right-click on the app...
You can click on the Project window, press Alt-Insert, and select Folder->Assets Folder. Android Studio will add it automatically to the correct location.
You are most likely looking at your Project with the new(ish) "Android View". Note that this is a view and not the actual folder structure on disk (which hasn't changed since the introduction of Gradle as the new build tool). You can switch to the old "Project View" by clicking on the word "Android" at the top of the Project window and selecting "Project".
According to new Gradle based build system. We have to put assets under main folder.
Or simply right click on your project and create it like
File > New > folder > assets Folder
To specify any additional asset folder I've used this with my Gradle. This adds moreAssets, a folder in the project root, to the assets.
android {
sourceSets {
main.assets.srcDirs += '../moreAssets'
}
}
right click on app-->select
New-->Select Folder-->then click on Assets Folder

Change default output bin folder of Eclipse

Eclipse puts binaries in "project folder/bin/" by default. I'd like to have Eclipse put generated binaries etc in another folder (outside the project folder). Doing Android development.
You can change the "output folder" (by default bin) for a Java project (see "How do I change a Java project's bin folder in Eclipse?")
But for Android projects, as detailed in "Can't change default output folder", you need to modify the build.properties as well.
That can be dangerous though, as commented:
Just to note that changing the output folders doesn't work when dealing with library projects - there's part of the Ant script that is hardcoded to look in the bin folder of libs anyway.
So maybe using the exclude option of Dropbox is preferable here?
I would like to describe an approach below.
First, create a new empty project locally in eclipse work space for storing generated output files say output_bin.
As mentioned in above steps, now from Default Output Folder we need a new Variable to link to our project output folder.
Default Output Folder -> Browse -> Create New Folder...
-> Advance -> check "Link to folder in the file system" ->
Variables -> New.. -> Name = PROJECT_OUT, Location = "CHOOSE_PATH_TO\output_bin\bin\Project1bin" -> Ok
Note: Project1bin is a new directory which stores the bin folder. output_bin is an empty project and you can have multiple bin folder for various projects.

Categories

Resources