'BitmapStub' does not exist in the namespace 'Android.Graphics' Using Xamarin.Forms - xamarin.forms

I implemented a application for Sunmi T1 mini device in-build printer in Xamarin forms and i want to print a image with some text like billing receipt.
I integrated AIDL file for Sunmi T1 mini device you can see in image.
But i am facing namespacing issue in IWoyouService.cs "the type of namespace name 'BitmapStub' does not exist in the namespace 'Android.Graphics'."
case TransactionPrintBitmap: {
data.EnforceInterface (descriptor);
Android.Graphics.Bitmap arg0 = default (Android.Graphics.Bitmap);
arg0 = Android.Graphics.BitmapStub.AsInterface (data.ReadStrongBinder ());
ICallback arg1 = default (ICallback);
arg1 = ICallbackStub.AsInterface (data.ReadStrongBinder ());
this.PrintBitmap (arg0, arg1);
reply.WriteNoException ();
return true;
}
I attach my AIDL Zip file https://drive.google.com/file/d/1lrCgZwDrfyqs6LAwTP3pQ6nMzYIW4hrY/view?usp=sharing.
How can resolve this error in Xamarin.Forms

I had this exact same problem, and managed to solve it by adding another AIDL file to define what a 'Bitmap' is.
I copied this file from the Android Open Source Project and just added it into my project and set the build action to Android Interface Definition like the other Sunmi AIDL files.
Not sure why Xamarin doesn't manage to handle this automatically, but adding this solved the problem for me and I was able to build and successfully invoke the interface methods that accept bitmap parameters.
In case the link ever goes bad, here is the entire file you need to add - it's very small:
/* Save this in Bitmap.aidl and add to your project alongside the others */
package android.graphics;
parcelable Bitmap;

Related

.Net 6.0 console application keeps displaying popup message while I am trying to code

I am typing in an example from the book, "C# 10 and .Net 6".
It is a console application with reflection.
Here is the code so far:
using System.Reflection;
Assembly? assembly = Assembly.GetEntryAssembly();
if (assembly == null) return;
// Loop through the assemlies that this app references
foreach (AssemblyName name in assembly.GetReferencedAssemblies())
{
// Load the assembly so we can read its details
Assembly a = Assembly.Load(name);
// declare a variable to count the number of methods
int methodCount = 0;
// loop through all the types in the assembly
foreach (TypeInfo t in a.DefinedTypes)
{
// add up the counts of methods
methodCount += t.GetMethods().Count();
}
//
}
I got this far and was about to type in the last part and I got the popup dialogue in the pic:
It says:
Specified argument was out of the range of valid values.
Parameter name: length
Why does this obtrusive popup keep displaying and stopping me from typing? What is it? What does it mean? Why does it not wait for you to try and build, compile or run before reporting the problem.
What is this and how do you make it go away?
I just want to add I was able to type it all in and the example runs correctly. But why does VS 2022 keep displaying this popup while I am trying to type?
This looks like a problem with Visual Studio or an extension. It's not a problem with your code.
You could try:
Restarting VS,
Restarting Windows,
Repairing/updating/reinstalling VS.

Property 'downloadURL' not found on object of type 'FIRStorageMetadata *' - Getting this error when trying to build a Flutter project

I'm trying to build a Flutter project on Xcode with firebase installed. I'm getting the following error: Property 'downloadURL' not found on object of type 'FIRStorageMetadata *'
This is being caused by the following section in the FirebaseStoragePlugin.m file:
NSString *path = call.arguments[#"path"];
NSDictionary *metadataDictionary = call.arguments[#"metadata"];
FIRStorageMetadata *metadata;
if (![metadataDictionary isEqual:[NSNull null]]) {
metadata = [self buildMetadataFromDictionary:metadataDictionary];
}
FIRStorageReference *fileRef = [[FIRStorage storage].reference child:path];
[fileRef putData:data
metadata:metadata
completion:^(FIRStorageMetadata *metadata, NSError *error) {
if (error != nil) {
result(error.flutterError);
} else {
// Metadata contains file metadata such as size,
// content-type, and download URL.
NSURL *downloadURL = metadata.downloadURL; <---------------- This line
result(downloadURL.absoluteString);
}
}];
}
Since I didn't generate this code, I don't particularly want to edit it as it should really be working out of the box. I've tried to change the method to see whether later versions of Firebase might only accept another function but to no avail. What shall I do in this situation? Should I perhaps try to rebuild the project with a higher version of Firebase or is there a one line fix?
The downloadURL was removed from the StorageMetadata class in May 2018. If your native iOS code still uses that, it's high time to find an updated SDK or update your code to match the documentation on uploading a file and getting its download URL.
If you're using the FlutterFire binding libraries, upgrade to the latest version (as I definitely don't see any reference to metadata.downloadURL in its current code base). If you're using another library, check if the latest version of that solves the problem - or otherwise consider switching to the FlutterFire libraries as those are quite actively maintained.

Possible to load SKBitmap via FFImageLoading CachedImage from platform assets folders?

I am using Xamarin Forms 4.1 (android and ios) and am trying to load an image (png) from the respective asset folders (i.e. resources/drawable on android) into an SKBitmap.
I can load with no problem from the shared folder, (like so)
Assembly assembly = GetType().GetTypeInfo().Assembly;
string resourceID = "PROJECTNAME.Images.image.png";
using (Stream stream = assembly.GetManifestResourceStream(resourceID))
{
SKBitmapObj = SKBitmap.Decode(stream);
}
but would like to do so from the platform folders as the images are used in XAML elsewhere as well.
I have attempted to first load the image into an FFImageLoading CachedImage, and then get the bytes to decode into the SKBitmap, but likewise I seem unable to load a platform image in code.
FFImageLoading.Forms.CachedImage cachedImage =
new CachedImage() { Source = "imagename" };
SKBitampObj = SKBitmap.Decode(cachedImage.GetImageAsPngAsync(60, 60).result);
CachedImages display fine when I do so in XAML, so I assume I am just addressing the image incorrectly, but am not sure.

Xamarin Forms - Native Forms

I am trying to experiment with Native Forms in XF. I have this in iOS working right. That is fine.
In Android, I am getting the following error:
'MainPage' does not contain a definition for 'CreateSupportFragment' and the best extension method overload 'PageExtensions.CreateSupportFragment(ContentPage, Context)' requires a receiver of type 'ContentPage'
The code is erroring in the following code:
var _cp = new MainPage(); // my page from XF.
_list = _cp.CreateSupportFragment(this);
I have made sure that my nuget packages are up to date. I have cleaned and compiled. I've done a bunch of things, but alas, no love. Any ideas on this?
TIA
you need add the line to head of source:
using Xamarin.Forms.Platform.Android
because CreateSupportFragment is an extension method defined in it.

Load Animated gif file using QMovie in Ubuntu

I am new to Ubuntu & Qt. I need to show busy status for other long operations. So, I was just trying to use waiting animation gif files to load instead using Progress bars.
I am using Eclipse Editor for Qt project.
Trolltech/../imageformat folder contains libqgif.so and libqgif.so.debug. I have copied these files in my debug folder too.
loader.gif is added in qrc file and kept in /Resources folder
IN MainWindow class I have added label and after setupUi(this) been called I call my ShowMovie() function as below:
ShowMovie() {
QMovie *movie = NULL;
movie = new QMovie(":/Resources/loader.gif");
if(movie->isValid()) {
ui.label_3->setMovie(movie);
movie->start();
}
else
qDebug()<<"Movie is Invalid";
qDebug()<<QImageReader::supportedImageFormats ();
}
Always isValid() function returns false & I got message that Movie is Invalid.
Last qDebug() returns
("bmp", "gif", "ico", "jpeg", "jpg", "mng", "pbm", "pgm", "png", "ppm",
"svg", "svgz", "tif", "tiff", "xbm", "xpm")
i.e means gif support is available.
I have tried to call ShowMovie() function before loading Main UI and/or on button clicked. Both fails.
Provide help on what is to be corrected.
Thank you.
you don't need to copy librairies files *.so.
Try creating the movie object with the full path to loader.gif. Does it work?
Then you have not setup correctly your resource system.
Either you have a syntax mistake in the qrc file which need to be fixed or you forgot to add it as a resource in the project file (.pro) using
RESOURCES = myqresource.qrc

Resources