I have a Xamarin.Forms Android application, developed using Visual Studio 2017. If I run/debug the application from Visual studio, with a USB device, it works well (both debug and release configurations).
I then create the .apk using the archive command in visual studio. To test it I simply upload it from my dev. computer to google drive and then download it from the same device and install it. This works as well.
The problem comes out when I try to create the .apk from the command line. The file obtained in this way is recognized by the device, which installs it correctly, but when I start the app, it seems to start but after a second it closes abruptly. I don't even get the familiar popup "unofortunately the app stopped" that I got during the development phase when there were exceptions.
These are the commands I use:
msbuild /t:Clean /p:Configuration=Release
msbuild /t:PackageForAndroid /p:Configuration=Release
keytool -genkey -v -keystore SymCheck.keystore -alias SimCheck -keyalg RSA -keysize 2048 -validity 10000
jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore SymCheck.keystore my_application.apk SimCheck
According to https://learn.microsoft.com/en-gb/xamarin/android/deploy-test/signing/manually-signing-the-apk
I also tried this sequence
msbuild /t:Clean /p:Configuration=Release
msbuild /t:PackageForAndroid /p:Configuration=Release
keytool -genkey -v -keystore SymCheck.keystore -alias SimCheck -keyalg RSA -keysize 2048 -validity 10000
zipalign.exe -f -v 4 my_application.apk my_application_aligned.apk
apksigner.bat sign --ks SymCheck.keystore --ks-key-alias SimCheck my_application_aligned.apk
with the same outcome.