Skip to content

Snappy1

  • Home
  • Android
  • What
  • How
  • Is
  • Can
  • Does
  • Do
  • Why
  • Are
  • Who
  • Toggle search form

[FIXED] android – I can’t display images in my apk release in flutter

Posted on November 11, 2022 By

Solution 1 :

Subdirectories within a directory are not automatically included. You need to include every directory in your pubspec.yaml. Not sure how things worked on the emulator without this. So you would have (according to your asset structure):

  assets:
    - assets/images/Antiguo
    - asests/images/Aparicion
    ...

Since the assets are within the assets/ folder, you also need to include that in your path:

Image.asset('assets/images/Kratos/kr1.jpg', ...);

Do a flutter clean and try building again.

Solution 2 :

are you getting any error in your terminal like: “Image not found or similar”, the first thing I saw from your image which isn’t too clear is that when you establish your images path in the pubspec.yaml you must be very carefull with spacing, it seems to me that you added one space instead of 2 and dont forget to add every subdirectory in you’re case you’re missing to add the directory of “Kratos”:

  assets:
    - assets/images/Kratos

So it would be like this:

[Space][Space]assets:
[Space][Space][Space][Space]-[Space]assets/images/Kratos

That should work wonders, hope I was able to give you any help.

Problem :

I have created an app in flutter and when I test it on my mobile it does not show any image. Everything is fine, except the images.

I attach a picture of the pubspec.yaml, as I have the structure of assets and the cmd of how I create the apk. Each name in the images is a folder in which there are images inside.

I clarify that in Visual Studio Code that is where I have done it, in its emulator if the images are shown, but when I install the apk, no.

It is curious that if I add – assets/images/Atreus/ , when creating the apk, this weighs more (as it weighs more for that folder I added), but still not shown.

READ  [FIXED] java - Intantiating a viewmodel using dagger2 in BaseFragment
Powered by Inline Related Posts

Thanks.

pubspec.yaml

structure assets

cmd


ADD: I have already fixed the red warning. It creates the apk without those warnings (I updated jdk to 15 and gradle to version 7.0.2), but the images are still not visible.

build apk

Code image:

 Image.asset(
   'images/Kratos/kr2.jpg',
   width: 100,
   height: 100,
   fit: BoxFit.cover,
 ),

Code image updated:

Code image:

 Image.asset(
   'assets/images/Kratos/kr2.jpg',
   width: 100,
   height: 100,
   fit: BoxFit.cover,
 ),

NEW: Now I get this error. I have version 1.5 on my computer but I don’t know how to select it.

version error

Now, when I change the version manually in build.gradle ext.kotlin_version = ‘1.5’ I get this error, and even if I do flutter clean again it doesn’t fix the problem.

build failed


Ok. Beginner’s mistake. I put the version ‘1.5’ but I should have put ‘1.5.0’ … Similarly, the apk is created without fail but the images are not displayed.

NEWS: Images are already shown! Many thanks to user2233706. I can’t give points for being a “newbie” but I appreciate it very much.

Comments

Comment posted by user2233706

You should put formatted code in your question, not images of it.

Comment posted by Brilosan8

I have added one thing

Comment posted by user2233706

I’ve had issues where building twice mysteriously fixes the issue. But you can set the kotlin version in

Comment posted by Brilosan8

I have added what happens now

Comment posted by user2233706

Can you try debugging on the device? Maybe you’ll see some errors in the debug console. From VSCode you can choose your device from the lower right, assuming you have USB debugging enabled. You also need to post a minimal example that reproduces the problem.

READ  [FIXED] java - Enhanced 'switch' blocks are not supported at language level 7 - Android Studio
Powered by Inline Related Posts

Comment posted by Brilosan8

I have done flutter clean and flutter pub get and the images still do not appear in the apk. Please help.

Comment posted by Brilosan8

I have already put the image of the code I use for the image.

Android Tags:android, dart, flutter, visual-studio

Post navigation

Previous Post: [FIXED] Android ACTION_VIEW intent is not opening urls in non-browser apps like twitter and instagram
Next Post: [FIXED] android – Check if activity is active, and if active pass data from service to activity?

Related Posts

[FIXED] How to add city field to a contact in Android using ContentProviderOperation Android
[FIXED] Best practice for assigning a button text and click listener Android/Kotlin Android
[FIXED] java – Why can’t I generate a signed APK? Android
[FIXED] android – showing ERROR: Failed to resolve: exifinterface Android
[FIXED] json – Android Expected BEGIN_OBJECT but was STRING at line 1 column 1 error Android
[FIXED] java – How do I initialize a listener in a recycler adapter? Android

Archives

  • March 2023
  • February 2023
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022

Categories

  • ¿Cómo
  • ¿Cuál
  • ¿Cuándo
  • ¿Cuántas
  • ¿Cuánto
  • ¿Qué
  • Android
  • Are
  • At
  • C'est
  • Can
  • Comment
  • Did
  • Do
  • Does
  • Est-ce
  • Est-il
  • For
  • Has
  • Hat
  • How
  • In
  • Is
  • Ist
  • Kann
  • Où
  • Pourquoi
  • Quand
  • Quel
  • Quelle
  • Quelles
  • Quels
  • Qui
  • Should
  • Sind
  • Sollte
  • Uncategorized
  • Wann
  • Warum
  • Was
  • Welche
  • Welchen
  • Welcher
  • Welches
  • Were
  • What
  • What's
  • When
  • Where
  • Which
  • Who
  • Who's
  • Why
  • Wie
  • Will
  • Wird
  • Wo
  • Woher
  • you can create a selvedge edge: You can make the edges of garter stitch more smooth by slipping the first stitch of every row.2022-02-04
  • you really only need to know two patterns: garter stitch

Recent Posts

  • Can VPN be traced by police?
  • Where were Kaiser-Frazer cars built?
  • How do you make gold rose gold paint?
  • What are the newest type of dentures?
  • Can you wear joggers as dress pants?

Recent Comments

No comments to show.

Copyright © 2023 Snappy1.

Powered by PressBook Grid Dark theme