Unable to use WifiNetworkSpecifier in Xamarin - xamarin

I tried to use following code snippet in my XAMARIN project using Visual Studio (Windows 10, Android platform API 29).
WifiNetworkSpecifier.Builder builder = new WifiNetworkSpecifier.Builder();
But looks like "WifiNetworkSpecifier" is not available for Visual Studio.
Error: CS0246 The type or namespace name 'WifiNetworkSpecifier' could not be found (are you missing a using directive or an assembly reference?)
Please share workaround to resolve this issue.
VERSION DETAILS ARE AS FOLLOWS:
Microsoft Visual Studio Community 2019, Version 16.6.2
Xamarin.Android SDK 10.3.1.4 (d16-6/3a10de9).

First, right click Android project => Property => Application and choose the Target Framework to Android 10.0(Q) or higher:
Then in your project, reference the namespace:
using Android.Net.Wifi;
Then you can use WifiNetworkSpecifier in your project:
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{
WifiNetworkSpecifier.Builder builder = new WifiNetworkSpecifier.Builder();
}

you need to specify the namespace
using Android.Net.Wifi;
is VS, right clicking on the line that has the error should offer you a prompt to automatically suggest potential fixes

Related

How to fix "The Project needs to include ATL support" in Visual Studio 2019 C++?

I add an ATL project in my main solution, but further on adding a new atl simple object in that project I get the error "The project needs to include ATL support". However if I just open the atl project individually in a new Visual Studio Window, I can create it.
For the fix I also used
class CGFXComOBJECTNAMEModule : public CAtlDllModuleT< CGFXComOBJECTNAMEModule >
{
public:
DECLARE_LIBID(LIBID_GFXCOMOBJECTNAMELib)
DECLARE_REGISTRY_APPID_RESOURCEID(IDR_GFXCOMOBJECTNAME, "{ID here-}")
};
CGFXComOBJECTNAMEModule _Module;
as I saw this fix on internet
FIX
still getting the same error! CAn anyone please help me regarding this?

Compile Error trying to bind a ABBYY RTR SDK.AAR file via Xamarin Android Binding project

I get the error below when I try to bind the "abbyy-rtr-sdk-1.0.aar" downloaded from https://rtrsdk.com/#RTR.Android.Online using Xamarin Android Binding project in Visual Studio 2017, by following the link https://learn.microsoft.com/en-gb/xamarin/android/platform/binding-java-library/binding-an-aar
Severity Code Description Project File Line Suppression State
Error CS0234 The type or namespace name 'IRecognitionContextHolder' does not exist in the namespace 'Com.Abbyy.Mobile.Ocr4' (are you missing an assembly reference?) AbbyLib C:\_MyLab\Xamarin\My\OCR\TextRecogniser\AbbyLib\obj\Debug\generated\src\Com.Abbyy.Mobile.Ocr4.IRecognitionManager.cs 481 Active
Severity Code Description Project File Line Suppression State
Error CS0738 'IDataCaptureServiceInvoker' does not implement interface member 'IRecognitionService.ExtendedSettings'. 'IDataCaptureServiceInvoker.ExtendedSettings' cannot implement 'IRecognitionService.ExtendedSettings' because it does not have the matching return type of 'IRecognitionServiceExtendedSettings'. AbbyLib C:\_MyLab\Xamarin\My\OCR\TextRecogniser\AbbyLib\obj\Debug\generated\src\Com.Abbyy.Mobile.Rtr.IDataCaptureService.cs 679 Active
Error CS0738 'ITextCaptureServiceInvoker' does not implement interface member 'IRecognitionService.ExtendedSettings'. 'ITextCaptureServiceInvoker.ExtendedSettings' cannot implement 'IRecognitionService.ExtendedSettings' because it does not have the matching return type of 'IRecognitionServiceExtendedSettings'. AbbyLib C:\_MyLab\Xamarin\My\OCR\TextRecogniser\AbbyLib\obj\Debug\generated\src\Com.Abbyy.Mobile.Rtr.ITextCaptureService.cs 681 Active
Update
Steps I use by following the link https://learn.microsoft.com/en-gb/xamarin/android/platform/binding-java-library/binding-an-aar
1 Add "abbyy-rtr-sdk-1.0.aar" under Jars folder
2 Set Build Action to LibraryProjectZip
3 Set Compile Using Android version: to Android 4.4 (KitKat) for the Binding project
4 Build the project
I get the errors above.
Below is the versions of IDE:
Window 7
Microsoft Visual Studio Enterprise 2017 (2)
Version 15.8.6
VisualStudio.15.Release/15.8.6+28010.2041
Microsoft .NET Framework
Version 4.7.03062
Xamarin 4.11.0.776
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.
Xamarin Designer 4.15.9
Visual Studio extension to enable Xamarin Designer tools in Visual Studio.
Xamarin Templates 1.1.116
Templates for building iOS, Android, and Windows apps with Xamarin and Xamarin.Forms.
Xamarin.Android SDK 9.0.0.19
Xamarin.Android Reference Assemblies and MSBuild support.
Xamarin.iOS and Xamarin.Mac SDK 12.0.0.15
Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.

The type or namespace name 'App' could not be found

Brand new Xamarin Cross-Platform project.
Solution comprises of:
A Xamarin (Xamarin Forms) android project
Shared (.NET Standard 2.0) Class Library
project, where 'App' is defined.
Both projects build with no errors or warnings.
However, when trying to run them I get the following error:
error: The type or namespace name 'App' could not be found (are you
missing a using directive or an assembly reference?) Failed to debug
your app.
It looks like a caching thing related to visual studio but I tried cleaning all caches (.vs, obj, release, restart VS, etc..)
Context:
I'm Using Visual Studio 2017.
Tried running the app on an emulator and on a real phone (Xamarin Live)
The app did run for a while but after an hour or so this error started popping out.
Tried plenty (I would love to say all but maybe missed one) solutions I found over SE and Xamarin forums. None helped.
I have found that this error occurs when I create a new project where the name and solution have a space. Try creating one without a space.
For example: "MyAwesomeApp" instead of "My Awesome App"

Errors while using Sqlite-net on Xamarin studio

I am using sqlite-net in Xamarin Studio for Xamarin.forms application. In that I have put the sqlite-net library version 1.0.8. I have created the interface which I would be implementing in the platforms. But when I try to compile the PCL project I am getting a lot of errors which are present in the SQLite.cs file which was added when I added the PCL for sqlite-net.
I initially thought that the file is not important but it started giving more errors in the application. How to resolve this issue?
I am using a video tutorial for which used Visual studio for making the sample.
I am attaching the pic for the same. I would like to mention that the problem is not in my file the compile time errors are in the library.
EDIT: The PCL version of the package is 1.0.8
I had added the file in the application with content
using System;
using SQLite;
namespace SQLiteExample
{
public interface ISQLite
{
SQLite.SQLiteConnection GetConnection();
}
}
You should use SQLite-Net-PCL instead of SQLite-Net.

How to use c# 6 compiler in visual studio 2012

Can any one help me how I can use the C#6 compiler in my project?
This is what I already tried:
I have installed the nuget package via this command:
Install-Package Microsoft.Net.Compilers
After that I am getting the below error:
"Error 1 The name 'nameOf' does not exist in the current context"
And when I try to change the compiler version in visual studio, C# 6 is not even showing up:
You can't. If you want to use C# 6.0 in Visual Studio, you will need to upgrade to VS 2015.
There is no nameOf keyword in C#. If this is the exact error message, you have a typo and should use nameof instead.
using System;
using System.Linq.Expressions;
public static String nameof<T>(Expression<Func<T>> name)
{
MemberExpression expressionBody = (MemberExpression)name.Body;
return expressionBody.Member.Name;
}
Use this. This is copied from another stackoverflow question

Resources