Xamarin Cross-Platform MSAL Authentication: Invalid keystore format

Craig 0 Reputation points
2024-04-18T01:27:01.74+00:00

I followed this guide "https://damienaicheh.github.io/azure/xamarin/xamarin.forms/2019/07/01/sign-in-with-microsoft-account-with-xamarin-en.html" for setting up authentication for Xamarin android and ios msal. Everything seemed to going fine until I ran it and got an Invalid keystore format error. I ran this "keytool -genkeypair -v -keystore debug.keystore -alias androiddebugkey -keyalg RSA -keysize 2048 -validity 10000 -storepass android -keypass android -dname "CN=Android Debug,O=Android,C=US"" to create the keystore and put it in the same directory as the .csproj in the .Droid project. Then I included these lines in the .csproj file.

<PropertyGroup>
    <AndroidKeyStore>debug.keystore</AndroidKeyStore>
    <AndroidSigningKeyStore>debug.keystore</AndroidSigningKeyStore>
    <!-- Other properties related to signing -->
</PropertyGroup>

When I create a Xamarin solution, the eumulator runs for android, but when I update the configuration and code, I get the keystore error. I've even downloaded the project from above from the github page "https://github.com/damienaicheh/MicrosoftAuthenticationProject", replace the clientId with mine, and still get the same error.

Any Ideas?

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,362 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Craig 0 Reputation points
    2024-04-19T17:56:21.7933333+00:00

    @Yonglun Liu (Shanghai Wicresoft Co,.Ltd.)

    I was able to solve this from your link above by adding the following lines to the .Droid.csproj file.

    <EmbedAssembliesIntoApk>true</EmbedAssembliesIntoApk>
    <AndroidUseAssemblyStore>false</AndroidUseAssemblyStore>
    

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.