Xamarin.Auth AccountStore - KeyStore was not initialized - xamarin.forms

I've had this Xamarin.Auth AccountStore working in my app for a while, but then decided to do some updates to some Nuget Packages and Target Android versions >_<
I now have no idea what went wrong and how to get it working again, here is the exception:
Java.Security.KeyStoreException: KeyStore was not initialized
The code is pretty simple and looks like this:
var accountStore = AccountStore.Create(Android.App.Application.Context);
var accounts = accountStore.FindAccountsForService(providerName);
The 2nd line is throwing the exception.
This is in the Android project, being called from a PCL DependencyService.
It has been working this way for a while, I guess something changed in a version update in one of the packages but I don't know what, any ideas?

try to repair your visual studio installation.
This made the trick for our project. We had the same problems like you.

Related

FirebaseDynamicLinks.Instance is null after update from 60.1142.1 to 71.1615.0

I was using FirebaseDynamicLinks in my Xamarin forms project (everything works fine) and I decided to update my nuget packages.. but after I update Xamarin.Firebase.DynamicLinks (and all dependencies) I got null after calling FirebaseDynamicLinks.Instance.
There was some major changes? Do I need to modify my code somehow after this update? Thanks for any help!
I found this in logs, so my google-services.json should be right, right?
FirebaseInitProvider: FirebaseApp initialization successful
Xamarin.Android SDK Version: 9.3.0.23
Operating System & Version: Win 10, 1803
So if not necessary now, suggest downgrading to previous version of Xamarin.Firebase.DynamicLinks. Maybe there are something not incompatible or new methods not be used correctly.

SQLite no longer seems to work on xamarin android

We have a Xamarin.Forms project that needed to use the sqlite local db to store date. EF Core's sqlite library was used to set this up and by different developers from different PCs (vs 2019). Initially, it was used with the Database.EnsureCreated() function and later with ef core's migrations. All went smooth for more than a month.
Last week all of a sudden the android app wouldn't start on any one's PC due to some error with sqlite. It showed the following error:
Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR)
I spent a while trying all kinds of fixes and rollbacks thinking it was an issue with the code. This included the following:
Deleted obj and bin folders, cleaned and rebuilt for all below steps.
Downgraded the version of ef to 2.2.3 (the version we started with)
Rolled back to git commits up to a week back
Upgraded the versions of dependencies of ef core
Removed the past few migrations
Downgraded xamarin forms to 3.6.x
After trying the above and several other fixes, finally upgrading the versions of java and android SDK worked last Friday (on all PCs). Once this fix worked everything went smooth that day. On Tuesday once again the issue was back (no library updates or code changes). A deeper look at EF Cores logging shows that it crashes the moment it attempts to connect to a db.
The issue can be replicated on the android devices but not the emulators. I am not sure if there is some new permission in android we need to request for.
I finally created a new xamarin forms project with sqlite setup. I used the pcl library and ef core. I still found the same error.
Here is the git hub that replicates the issue https://github.com/neville-nazerane/xamarin-site
Update
Just something i noticed. eariler my database file was named "main.db". Now no matter what i change this file name to or no matter what variables i change. it always shows database name as "main" in logs. Not sure if changing the db name would fix the issue. However, never found a way to change this db name. I tried different connection strings, it just said "database" and "db" were unknown keys
Update
Steps to replicate:
using (var db = new AppDbContext())
{
db.Add(new Person {
Age = 55,
Name = "Neville"
});
db.SaveChanges();
Person[] alldata = db.People.ToArray();
}
The definitions of Person and AppDbContext are quite obvious. So, with the spirit of not making the question too long, I am not posting it here. However, if required I can post them too.
This is a bug with the Xamarin.Forms and Mono.
It was detected since a couple of months ago, it was fixed but then there was some regression (with VS 2019 v16.1).
Even with the latest release (v16.1.2) the bug still happens, so we need to wait for a fix.
Sources:
https://github.com/mono/mono/issues/14170
https://github.com/xamarin/xamarin-android/issues/3112
https://github.com/xamarin/xamarin-android/issues/2920
Due to slight differences of the particular file systems on the native side, I would suggest creating an interface to handle the actual database file handling on the native application level.
So here is how I implemented SQLite using the nuget package SQLite.Net-PCL:
In the shared project, create a new interface, for instance FileHandler.cs
public interface IFileHandler
{
SQLite.SQLiteConnection GetDbConnection();
}
You may want to extend that with more methods to save or retrieve various files, but for now we will just have the GetDbConnection Method to retrieve a working SQLite Connection.
Now in your Android implementation, we add the native implementation to that interface:
Create a new class called FileHandler.cs in your android project:
[assembly: Dependency(typeof(FileHandler))]
namespace YourProjectName.Droid
{
public class FileHandler : IFileHandler
{
public SQLite.SQLiteConnection GetDbConnection()
{
string sqliteFilename = "YourDbName.db3";
string path = Path.Combine(GetPersonalPath(), sqliteFilename);
SQLiteConnectionString connStr = new SQLiteConnectionString(path, true);
SQLiteConnectionWithLock connection = new SQLiteConnectionWithLock(connStr, SQLiteOpenFlags.Create | SQLiteOpenFlags.ReadWrite | SQLiteOpenFlags.NoMutex);
return connection;
}
private string GetPersonalPath()
{
return Environment.GetFolderPath(Environment.SpecialFolder.Personal);
}
}
}
Now back again in your shared code you can access that connection with the following code:
using (SQLiteConnection connection = DependencyService.Get<IFileHandler>().GetDbConnection())
{
// Do whatever you want to do with the database connection
}
Alright mate, I don't understand what issue you are facing. It might be an issue with your machine, I'd suggest using another computer/laptop.
I took the exact code that you shared on the Github. I was able to build it on my Mac computer in VS 2019 and installed the application in debug mode on my phone. I was able to add a date successfully, as you can see in the picture, and I placed an Exception Catchpoint and faced no exceptions.
I then proceeded to add another entry with the same details and it errored out with the message that you can see here
I would also suggest using Xamarin Profiler or any other Android logger to see the Stack Trace that you aren't able to see in your application output. It will give you details of the error, that you can share here for us to understand better.

deploying Qt/QML App with LocalStorage (Sqlite) on OS X

I'm doing an app with QML that uses LocalStorage to store some informations.
It's working fine when I run in debug mode.
My storage.js that access the database is like that.
.import QtQuick.LocalStorage 2.0 as Sql
// First, let's create a short helper function to get the database connection
function getDatabase() {
return Sql.LocalStorage.openDatabaseSync("MyApp", "0.1", "StorageDatabase", 100000);
}
My Qt .pro file contains the Sql module:
QT += sql
And at first moment it runs fine in Release mode either.
But when I try to deploy on OSX, running macdeployqt like that:
macdeployqt MyApp.app -dmg -qmldir=../MyApp/qml/
First I got one error, but I think that's ok because I don't use MySQL: ERROR: no file at
"/opt/local/lib/mysql55/lib/libmysqlclient.18.dylib"
I'm using sqlite via LocalStorage.
Then trying to run in Release mode it doesn't work anymore, the database access doesn't work, not even the in the deployment it works... now when I try to run the app I got the error:
storage.js:5: ReferenceError: Sql is not defined
The line 5 is this one:
return Sql.LocalStorage.openDatabaseSync("MyApp", "0.1", "StorageDatabase", 100000);
And the Sql name is defined in the first line:
.import QtQuick.LocalStorage 2.0 as Sql
Looking for this error in the internet I found some places telling to do exactly what I did, like here: https://qt-project.org/forums/viewthread/28371
Any clue about this?
I'm using Qt5.2, Quick 2.0, Qt Creator 3.01
The problem was related to this Qt bug that is here since Qt5.1
https://qt-project.org/forums/viewthread/29805/
I've used the script and custom macdeployqt linked in the post to make this work.
Script: https://gist.github.com/lasconic/5965542
Custom macdeployqt: https://github.com/MaximAlien/macdeployqt
It seems that Qt is not giving much attention to desktop development, only that explains a bug like that not fixed yet.

ASP.NET using AtalaSoft to convert Tiff compression

Using Atalasoft's free SDK,
http://www.atalasoft.com/free-dotnet-image-sdk
I added reference to the DotImage and DotImage.Lib dlls' to Visual Studio 2010.
My code:-
Atalasoft.Imaging.AtalaImage image = new Atalasoft.Imaging.AtalaImage(fileName);
Atalasoft.Imaging.Codec.TiffEncoder encoder = new Atalasoft.Imaging.Codec.TiffEncoder();
encoder.Compression = Atalasoft.Imaging.Codec.TiffCompression.Group4FaxEncoding;
image.Save(fileName, encoder, null); // destroys the original.
However when I run the code I get an error on the very first line:-
Unable to retrieve security descriptor for this frame.
Can anyone help me out with this?
Update:-
I added a further line of code:-
System.Security.Permissions.FileIOPermission f2 = new System.Security.Permissions.FileIOPermission(System.Security.Permissions.FileIOPermissionAccess.AllAccess, fileName);
Still the same error.
Philo,
Hi, I'm the support engineer you called in to yesterday. I apologize - after you called in, I received a note from our chief software architect asking us to help you out.
If you are still experiencing your issue, please do call back in and/or create a support case on our portal at https://www.atalasoft.com/support/my-portal/cases
A couple of tings that come to mind from your case: make sure you're targeting either x86 or x64 in your project's platform target (DotImage "has bitness") and make sure you're using the appropriate x86 or x64 Atalasoft references. (I strongly suggest our x86 while getting started as x64 has some additional hoops to jump through to get the licensing working.
Atalasoft does ship some AnyCPU dlls but they're for an extremely limited subset of use cases and if you have referenced those and/or are attempting to target your project to AnyCPU, this will cause all sorts of odd behavior.
Also, if you're targeting our .NET framework 4.0, make sure you're targeting the full framework and not "Client Profile" as DotImage has dependencies on components not present in the Client Profile version.
~DigitalSorceress
Did you have the the file with .lic extension in project section on the right side? Make sure about that.

App crashes when using MagicalRecord in release build

Our app uses MagicalRecord to store data in Core Data. It have worked fine so far, but now, after adding fields to my tables, the app crashes, but only in release builds.
When I upgrade via cable, it works just fine, but when I use Ad-Hoc (Enterprise) distribtion to upgrade the app, the app crashes.
The problem is I don't get any debug data on the crash because of this. The only thing I get is a "exited abnormally with signal 11: Segmentation fault: 11" error.
Crash report:
(http://pastebin.com/64c4jvgJ)
I assume the issue might be related to needing migration, but I can't find any good documentation on how this is supposed to work. Any pointers in the right direction is welcome.
Update:
More info -
Before updating my datamodel, i had a store called PAM.sqlite, and a non-versioned store called PAM.xcdatamodeld. Now i have a versioned store, called PAM & PAM 2.
I use this code to attempt an automigration, but it does not work:
[MagicalRecord setDefaultModelNamed:#"PAM 2.xcdatamodel"];
[MagicalRecord setupCoreDataStackWithAutoMigratingSqliteStoreNamed:#"PAM.sqlite"];
You need to specify the extenstion of the data model (e.g. MyProjectDB.momd)
so, the code syntax would be:
[MagicalRecord setDefaultModelNamed:#"MyProjectDB.momd"];
Found the answer here
I had the same issue. Try to add new version in xcdatamodeld. Then activate it as current. Open it in finder. Choose show package content. You will see two files for both of your versions. Replace the one for old version with non-versioned file from your old build. Use this
[MagicalRecord setupCoreDataStackWithAutoMigratingSqliteStoreNamed:#"PAM.sqlite"];
So your project will have two versions of db. And will have an ability to migrate automatically.
Default settings of MagicalRecord for iOS (https://github.com/magicalpanda/MagicalRecord) is something like this
#ifdef DEBUG
[self setShouldDeleteStoreOnModelMismatch:YES];
#else
[self setShouldDeleteStoreOnModelMismatch:NO];
#endif
That means,If there is change in database model in DEBUG mode,they will simply delete older version of data model.I believe this has been fixed in latest version of Magical record.
If not, change it to
#ifdef DEBUG
[self setShouldDeleteStoreOnModelMismatch:NO];
#else
[self setShouldDeleteStoreOnModelMismatch:NO];
#endif
and fix migration code

Resources