Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot do new Image Asset in res folder

Tags:

flutter

I want to do a new Image Asset in my res folder in my flutter project, to change the layout of my app icon. However when i right click on the res folder and chose New -> 'Image Asset' is no longer an option in my Android Studio... Anyone who knows how to fix this? I've been able to do it before. I've updated the Flutter plugin, but that didn't make any difference.

Image of options (Image Asset is missing)

like image 659
Lisa Avatar asked Oct 24 '25 01:10

Lisa


2 Answers

I'm new to flutter as well and as part of following the flutter course, ran into the same issue.

The following solution is with android studio version

Android Studio Arctic Fox | 2020.3.1 Patch 3
Build #AI-203.7717.56.2031.7784292, built on October 1, 2021
Runtime version: 11.0.10+0-b96-7281165 x86_64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
macOS 12.0.1
GC: G1 Young Generation, G1 Old Generation
Memory: 1280M
Cores: 12
Registry: external.system.auto.import.disabled=true
Non-Bundled Plugins: Dart, io.flutter

I found the 'Image Asset' option by following the below-listed steps

  • Right-click on the 'res' folder
  • Hover over 'Flutter' option and click 'Open Android module in Android Studio' enter image description here
  • When a pop-up asks 'Where would you like to open the project?', select 'New Window'
  • Once the project opens in new window, expand the app directory to find 'res' folder.
  • Right-click on 'res' folder, click 'new' and you'll now see the Image Asset option enter image description here
like image 81
Kiran Vemuri Avatar answered Oct 26 '25 17:10

Kiran Vemuri


I want to clarify these answers, it's all there, but it's too confusing: You must create an images folder in the project. In most of my projects, I would create an assets folder, and then a subfolder of images. This won't work, must be a top level images folder.

Additionally, if you start your project in VS code. You have to start the project in Android Studio. You can always just start a new project, do your icon work and copy the folders over to your actual project.

But TWO things seem to interfere: If you don't have an images folder and if you did anything in VS code. I was guilty of both, and had to unwind both issues.

  1. Start a new project in Android Studio

  2. Create an images folder.

  3. Add it to your pubspec.yaml in assets: Mine would look like this:

    assets:

    • assets/images/
    • assets/sounds/
    • assets/
    • images/
  4. Now you'll be able to right click on the res folder and see new image asset.

  5. Do your icon work.

  6. Copy the res folder over to your actual project.

Want to iterate: I put an image in the top level images folder, but I don't think it even needs that. It is looking for the folder, and you must have it. Somewhere in the code, a top level images folder is a condition to giving the image option.

Starting in Android studio will give the option, but it's greyed out. Having the images folder is the magic key that opens the hidden door.

like image 36
jbryanh Avatar answered Oct 26 '25 16:10

jbryanh