question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Setting images in code (still) doesn't work on Android

See original GitHub issue

Description

It has been said this would have been fixed but its not. Its broken in RC2 and still broken in RC3. Setting an image from an URL (or from a stream doesn’t matter) in code does not show up in Android. Could test it on iOS and its broken there too.

Steps to Reproduce

public partial class MyPage : ContentPage
{
    public MyPage()
    {
        InitializeComponent();
        MyImageControl = new Image
        {
        	Source = ImageSource.FromStream(() => new MemoryStream(Convert.FromBase64String("your image base64 string here")))
        // OR:
        //	Source = ImageSource.FromUri(new Uri("your image URL here"))
        };
    }
}
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml">
		<Image x:Name="MyImageControl" />
</ContentPage>

Version with bug

Release Candidate 3 (current)

Last version that worked well

Unknown/Other

Affected platforms

Android, iOS

Affected platform versions

Android 11, Pixel 5, Android Simulator on Windows, iOS 15

Did you find any workaround?

See https://github.com/dotnet/maui/issues/7074#issuecomment-1182933173

Relevant log output

No response

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:2
  • Comments:19 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
Symbaicommented, Oct 6, 2022

@mattleibow Ah okay that makes sense. Then I’ll try it like @jsuarezruiz did. If it still doesn’t work that way (which I assume is not the case) I will create a new issue. Thanks for the explanation.

1reaction
jooseracommented, Aug 3, 2022

This seems to be broken on Windows too, not just Android and iOS.

Saving to filesystem and using ImageSource.FromFile works as a workaround.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Android ImageView Is Not Displaying Image?
In ImageView there is two options src and srcCompact. Try both of them to find out which is working. android:src="@drawable/slide_view_4".
Read more >
Add images to your Android app
In this codelab, you will learn how to add images to your app using an ImageView. ... How to create and run a...
Read more >
Add images to your Android app
In this codelab, you learn how to add images to your app using an Image composable. ... Basic knowledge of how to create...
Read more >
Troubleshoot known issues with Android Emulator
This page lists known issues, workarounds, and troubleshooting tips for the Android Emulator. If you encounter an issue not listed here or ...
Read more >
Take photos
This lesson explains how to capture photos using an existing camera ... You want to take photos with minimal fuss, not reinvent the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found