Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't create layout folder in Android Studio by new Android Resource Directory (Error : enter or select a qualifier)

Step 1 : Right click on res folder, choose New > Android Resource Directory

Step 2 : Choose layout in resource type, then click OK

Result : Error in name : enter or select a qualifier

It's not happen with menu type. Do I missing something? I have to create directory instead

enter image description here

like image 346
quangkid Avatar asked Dec 25 '17 02:12

quangkid


People also ask

Can I create folder in layout Android?

Select layouts , right-click and select New → Folder → Res Folder. This resource folder will represent a “feature category” that you want. You can easily create any type of file/folder in Android Studio. If you have N vertical features, you need to create N folders.

How do I create a folder in Android Studio?

In the drop down menu click on the new option. After this a drop down menu opens here you will see directory option just click on that. After this enter the name of your directory / folder and press enter this will create a new folder / directory inside your root folder.

What is Qualifier type in Android Studio?

Qualifier name rules You can specify multiple qualifiers for a single set of resources, separated by dashes. For example, drawable-en-rUS-land applies to US-English devices in landscape orientation. The qualifiers must be in the order listed in table 2. For example: Wrong: drawable-hdpi-port/


2 Answers

It's an old question but whoever is having the same problem might find this helpful. Here's another way to create an android resource directory in the layout folder.

  • Right click res folder
  • Click new and the scroll all the way down to XML with the icon
  • Click that and leave everything as it is = Click finish.

Also, make sure to refactor and rename(whatever you like) the XML file that gets generated automatically after creating the resource folder.

screenshot

like image 130
Junia Montana Avatar answered Oct 26 '22 06:10

Junia Montana


Yeah, AS 3.0+ seems to do that to me as well.

But there really shouldn't be a difference between a new Android Resource Directory and just a new (regular) Directory if you don't actually use any qualifiers. It's still just a directory with a different name depending on the qualifier(s). So, you can safely choose new Directory and move along.

And for the sake of it, you can choose new Android Resource Directory with some random qualifier which will just add the qualifier to the directory name, and after it's created, refactor it by deleting the qualifier part from the directory name and you'll end up with a directory named "layout" which is an "Android Resource Directory".

Just do the refactoring with the Project view selected in the Project pane, not the Android view.

like image 38
Boban Talevski Avatar answered Oct 26 '22 06:10

Boban Talevski