Maritn Ge
Maritn Ge

Reputation: 1216

I cannot create directories/folders in Android Studio and Flutter, only packages

As you can see here, the option to create new directories doesn't exist, i can only add new packages.

What I want to do though is create a folder structure like

>Lib
>>Pages
>>>Startpage
>>>Loginpage
>>Helpers
>>>Networkhelper
>>>>Requesthelper
>>>Storagehelper
etc...

which i can't do with packages as i cannot put packages into empty packages and stuff

this worked before, however now when i created a new project, the same way i always did, it didn't work. any ideas on what i can do/what went wrong?

Upvotes: 6

Views: 3419

Answers (3)

Reinier Garcia
Reinier Garcia

Reputation: 1680

Initial Situation: On Android Studio you can only add a "Package", not a Directory. enter image description here

SOLUTION

Step # 1: Open the Project Structure window.

Either press Command+; or go through File > Project Structure:

enter image description here

Then you should see something like this: enter image description here

Step 2: Remove the lib folder from the the project's sources root:

  1. Click on "Modules" on the left panel.
  2. Click on the lib folder.
  3. Unmark "Sources" right on top of it (the lib folder will change its color from blue to gray).
  4. Press the "OK" button on the bottom right to apply the changes.

enter image description here

Final Situation:

Now you can add a Directory. enter image description here

Upvotes: 4

chiheb naili
chiheb naili

Reputation: 1

just open VS CODE and create the desired folder it should work that way

Upvotes: 0

ibrohabib
ibrohabib

Reputation: 301

For some reason, lib directory is marked as source root. Its actually doesn't make difference wether shown as package or folder. Its the same thing. But if you want to change it, unmark it.

in your project tree:

project_name -> lib:

  • right click
  • mark directory as
  • unmark as source root

Screenshot

Hope it help.

Upvotes: 30

Related Questions