A story with a happy ending that will save you time.

If you are using Karamunting.Android.TntKhang.FullScreenImageView (v1.1.1) library you can get the problems — some exceptions:

Exception 1 — NullPointerException

Unable to start activity ComponentInfo{com.example.superapp/com.github.tntkhang.fullscreenimageview.library.FullScreenImageViewActivity}: java.lang.NullPointerException: Attempt to invoke interface method 'java.util.Iterator java.util.List.iterator()' on a null object reference

Solution:

Use the right declaration to run the library:

var context = CrossCurrentActivity.Current.Activity; // used CurrentActivity pluginvar list = new string[] { "image-url1", "image-url2" };
var startIndex = 1;
var fullImageIntent = new Intent(context, typeof(FullScreenImageViewActivity));
fullImageIntent.PutStringArrayListExtra(FullScreenImageViewActivity.UriListData, list);
fullImageIntent.PutExtra(FullScreenImageViewActivity.ImageFullScreenCurrentPos, startIndex);
context.StartActivity(fullImageIntent);

Exception 2 — NoClassDefFoundError

Java.Lang.NoClassDefFoundError: Failed resolution of: Lcom/bumptech/glide/Glide; ---> Java.Lang.ClassNotFoundException: Didn't find class "com.bumptech.glide.Glide" on path: DexPathList[[zip file…

Simple code snippet to remove Facebook cookies

Just use this code snippet:


Short solution for Xamarin.iOS

First, look at the work solution:

var fileUrl = NSUrl.FromFilename(...);
using var img = assetImageGenerator.CopyCGImageAtTime(...);
//...using (var dest = CGImageDestination.Create(fileUrl, UTType.PNG, 1))
{
dest.AddImage(img);
dest.Close();
}

The manual call method Close() is important!

Look at method description:

“Writes the images to the destination and disposes the object.” — Seems so

But Dispose pattern implementation doesn’t support that. Because doesn’t call Close() method.

UPD: GitHub issue: https://github.com/xamarin/xamarin-macios/issues/9058


A short post about disabling cache for requests by security reasons in iOS.

How to check

var cachePath = Path.Combine(FileSystem.CacheDirectory, AppInfo.PackageName);var files = Directory.GetFiles(cachePath); // can see Cache.db* files

Used Xamarin.Essentials.

How to fix

When you using NSUrlSession, use privacy configuration EphemeralSessionConfiguration:

var session = NSUrlSession.FromConfiguration(
NSUrlSessionConfiguration.EphemeralSessionConfiguration);

End;


Some short notes about using Workspaces in Visual Studio for Mac / Xamarin Studio/ Mono Develop IDE.

Build workspace

To build workspace, you need to use mdtool (http://manpages.ubuntu.com/manpages/trusty/man1/mdtool.1.html), which was renamed to vstool.

  1. Use alias:
alias vstool="/Applications/Visual\ Studio.app/Contents/MacOS/vstool"

2. Build workspace:

vstool build XToolkit.mdw

2.1. Build with options:

mdtool build -c:Release XToolkit.mdw
mdtool build -c:"Release|AnyCPU" XToolkit.mdw
mdtool build -c:"Release|AnyCPU" -t:Clean XToolkit.mdw


The short note about setup Charles Proxy for iOS development.

  1. Launch Charles Proxy app.
  2. Install Charles Root Certificate:
Help → SSL Proxing → Install Charles Root Certificate on Mobile Device or Remote Browser

For Simulator use Install Charles Root Certificate in iOS Simulator


  1. Open terminal
  2. Execute command
security cms -D -i MyApp.mobileprovision

3. Get iOS provisioning profile XML source.


The short collection of fast steps about setup HTTP Proxying for iOS and Android development with Xamarin

Charles Proxy

Fiddler

Xamarin specific

  1. If you use the native (AndroidClientHandler, NSUrlSession) HTTP handler, then nothing needs to be done.
  2. If you use HTTP handler by default (managed), follow above:

Setup the proxy with a custom HttpClientHandler:

var handler = new HttpClientHandler
{
// local ip, charles port
Proxy = new WebProxy("192.168.0.52", 8888)
};

Then use it whenever…


Commands for the open separate terminal window for the path.

  1. Use open command:
open -a Terminal <PATH>

2. Use AppleScript:

osascript -e 'tell application "Terminal" to do script "cd <PATH>"'

Yauheni Pakala

I’m a software engineer living in Minsk, Belarus. I am a fan of technology, web development, and programming.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store