Errors while using Sqlite-net on Xamarin studio - xamarin

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.

Related

Unable to use WifiNetworkSpecifier in 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

Compilation error on new Xamarin Forms project

I have installed Visual Studio for Mac (7.0.1 build 24 Community Edition), generated a new project using Forms, and could not get it to compile. The error shown makes no sense to me since the code looks correct.
I have not made any change to the code. It is as generated by the Wizard.
I have tried the following ways of setting up, on different machines:
Using Home Brew
Using the Visual Studio For Mac installer
Any pointers on how to work around this one will help.
Please look below Error Message
You cannot have a dash in your namespace. Try using TestAppXamarin or TestApp.Xamarin instead:
namespace TestApp.Xamarin {
public class TestAppClass { }
}

Xamarin Forms Platform Specific Project Cant See Class Library

I'm trying to develop a Xamarin forms application and I'm having problems seeing namespaces in an Android class library I've added to the solution. Note, I'm using visual studio 2015 Community Version 14.0.25431.01 Update 3.
My Xamarin forms application solution contains the following projects.
XFormsApp(Portable)
XFormsApp.Android
XFormsApp.IOS
XFormsApp.UWP
MyCoreComsLib Preexisting PCL containing communications interfaces/abstractions, and cross platform utilities.
MyAndroidComsLib Preexisting Android specific implementations of the communications interfaces. This library references MyCoreComsLib. I believe MyAndroidComsLib is an "Android Class Library" project.
Right now I'm just trying to get the android implementation of the Xamarin forms app running so I added the following references between projects.
from MyAndroidComsLib to MyCoreComsLib
from XFormsApp(Portable) to MyCoreComsLib
from XFormsApp.Android to MyCoreComsLib
from XFormsApp.Android to MyAndroidComsLib
My Problem: When I work in CrossApp.Android I can't see any classes or namespaces from MyCoreComsLib or MyAndroidComsLib. However, when working in XFormsApp(Portable) I can access namespaces / classes in MyCoreComsLib. I've used the MyCoreComsLib and MyAndroidComsLib class libraries in android only c# projects so there aren't any issues with the visibility of classes.
I've done the following in an attempt to solve this issue.
Made sure MyCoreComsLiband MyAndroidComsLib built in the cross platform app solution.
Made sure the references to MyCoreComsLiband MyAndroidComsLib show up in the references list under the XFormsApp.Android project.
Restarted visual studio.
Created a brand new Xamarin forms app. Added a new Android Class library to the project. Added a reference from the NewFormsApp.Android project to the class library and attempted to access classes in the class library. Note, I wasn't able to see a class an in the new android class library so this leads me to believe this is a limitation with visual studio / Xamarin but I don't understand why this wouldn't be supported.
Thanks Everyone!
This has been confirmed as a bug in visual studio 2015 https://bugzilla.xamarin.com/show_bug.cgi?id=57991. I was able to resolve this issue by switching to visual studio 2017.

The target "GetBuiltProjectOutputRecursive" does not exist in the project when referencing netstandard library

I have a Xamarin Android project, and I am trying to add a reference to my own netstandard1.4 class library. When I add the reference, my Android application will no longer build. I get error MSB4057: The target "GetBuiltProjectOutputRecursive" does not exist in the project.
If I remove the reference, my android project builds fine.
The class library is a brand new library that I just created. It doesn't contain any actual code yet.
I am using Visual Studio 2017.
UPDATE: If I add a reference to my dll using the "Browse" function, it works. I only get the error when I add the reference to the project in my solution.
This appears to be fixed in 15.4

Integrating C/C++ code in Xamarin for iOS

Under Visual Studio 2015, I have integrated Android C++ code into Xamarin and it works as expected. Now, I am trying to do the same for iOS and am running into some basic issues.
I am assuming the integration mechanism is the same for iOS as that of Android in the sense that a shared library (probably .so) is created that one can load using DllImport in C# code.
When I try to add a new C++ project for iOS to my solution, the only option that seems to make sense is Visual C++-->Cross Platform-->iOS-->Shared Library. I added this project type as MyTestShared. This actually ends up creating three projects - MyTestShared.Shared, MyTestShared.iOS, and MyTestShared.Android. Project MyTestShared.iOS already has an external method defined as char* iOSInfo(). However, when I try to add project MyTestShared.iOS as a reference to my MyMainApp.iOS project, I see an error "A reference to MyTestShared.iOS could not be added. An assembly must have a dll or exe extension."
Questions:
For Android C++, it generates exactly one project. Why does it create three projects for iOS C++?
How do I add a reference to MyTestShared.iOS? What is it that I am missing?
I see there is an option to create a static C++ library for iOS. Can I reference it somehow in my C# code?
Regards.

Resources