Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

[Bug] Xamarin.Forms 4 (4.0.0.425677) fails Image in Button when resources are defined in Android class library #6327

Closed
zijianhuang opened this issue May 28, 2019 · 5 comments

Comments

@zijianhuang
Copy link

Description

To have multiple Android applications sharing the same resources mostly images, there's an Android class library containing the resources and assets, referenced by each Android app project. This has been working well with Xamarin.Forms 3.6 and previous versions. However, with Xamarin.Forms 4.0, images in buttons are not shown, while standalone images are shown.

Steps to Reproduce

Repository at https://github.com/zijianhuang/xamarinforms4bugs is demonstrating good ones and bad ones.

The master branch is with Xamarin.Forms 4 and Android app project that contains Resources. This is working well.

The ResourcesInLib is with Xamarin.Forms 4 and Android class project that contain Resources. Image of the button is not shown, while the standalone Image is OK

	<StackLayout>
		<Image Source="eye_24.png"/>
		<Label Text="Welcome to Xamarin.Forms!" 
		   HorizontalOptions="Center"
		   VerticalOptions="CenterAndExpand" />
		<Button ImageSource="eye_24.png" Text="Eye"/>
	</StackLayout>

Expected Behavior

Image of button is shown.

Actual Behavior

Image of button is not shown.

Debug Output:

[0:] FileImageSourceHandler: Could not find image or image file was invalid: File: eye_24.png05-28 21:39:04.011 W/ResourceType(25284): No package identifier when getting value for resource number 0x00000000

05-28 21:39:04.060 W/ResourceType(25284): No package identifier when getting value for resource number 0x00000000
[0:] FileImageSourceHandler: Could not find image or image file was invalid: File: eye_24.png

Basic Information

  • Version with issue: Xamarin.Forms 4 (4.0.0.425677)

  • Last known good version: Xamarin.Forms 3.6

  • IDE: Visual Studio 2017 Pro

  • Platform Target Frameworks:

    • Android: 5, 6, 7, 8, 9

Reproduction Link

https://github.com/zijianhuang/xamarinforms4bugs/tree/ResourcesInLib/

@zijianhuang zijianhuang added s/unverified New report that has yet to be verified t/bug 🐛 labels May 28, 2019
@samhouts samhouts added this to the 4.0.0 milestone May 28, 2019
@samhouts samhouts added e/2 🕑 2 and removed s/unverified New report that has yet to be verified labels May 29, 2019
@zijianhuang
Copy link
Author

I had just filed #6343 which might be related to this issue. After you Xamarin team fixing this, please ensure things work well with Xamarin.Forms.Visual.Material 4.

@PureWeen
Copy link
Contributor

PureWeen commented Jun 5, 2019

@zijianhuang one workaround for this is if you add literally any resource into your head project then it should all start loading for you

you can even just add some dummy image

resources\drawable\hack.png

after you do that then your images should start working.

@zijianhuang
Copy link
Author

@PureWeen, No. And I had even better workaround: symbolic links, which I had used in much older Xamarin releases.. However, I would prefer proper solution supported by 3.6.

@PureWeen
Copy link
Contributor

PureWeen commented Jun 5, 2019

it should be part of the next 4.0 or 4.1 release

PureWeen added a commit that referenced this issue Jun 5, 2019
samhouts pushed a commit that referenced this issue Jun 13, 2019
)

* Fix getting packagename and pass context into RM
- fixes #6327

* spacing
@samhouts
Copy link
Member

closed by #6420

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants