Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xamarin Android app closes immediately after launching

I am using Xamarin in Visual Studio.

I created an boilerplate android app (click me) and I tried the following:

Scenario 1:

  1. Switch to release mode

  2. right click on project > Export Android Package (.apk)

  3. Side loaded generated .apk it onto my phone

  4. App launches with no issue

Scenario 2

  1. Switch to release mode

  2. Tools > Android > Publish Android App

  3. Signed APK after creating private key store

  4. Side load generated .apk (in release folder) onto phone

  5. App closes immediately after launching (no error message, nothing)

What could be the issue here?

Do I need to do anything else after signing the package?

In both scenarios, the output apk is the same size 5227kb

UPDATE:

I have tried the same thing running on the android emulator. Same results. The app runs fine in debug mode on the emulator. Once I've switched it to Release, I get "Unfortunately, App1 has stopped"

Here's the error log http://pastebin.com/4j1Vwtgf

UPDATE 2:

Here's the logs when I'm deploying under release mode:

1>Starting deploy 5" KitKat (4.4) XXHDPI Phone ...
1>Deploying 5" KitKat (4.4) XXHDPI Phone ...
1>Build started.
1>C:\Program Files (x86)\MSBuild\14.0\bin\csc.exe /noconfig /nowarn:1701,1702,2008 /nostdlib+ /errorreport:prompt /warn:4 /define:TRACE;__XAMARIN_ANDROID_v1_0__;__MOBILE__;__ANDROID__;__ANDROID_1__;__ANDROID_2__;__ANDROID_3__;__ANDROID_4__;__ANDROID_5__;__ANDROID_6__;__ANDROID_7__;__ANDROID_8__;__ANDROID_9__;__ANDROID_10__;__ANDROID_11__;__ANDROID_12__;__ANDROID_13__;__ANDROID_14__;__ANDROID_15__;__ANDROID_16__;__ANDROID_17__;__ANDROID_18__;__ANDROID_19__;__ANDROID_20__;__ANDROID_21__;__ANDROID_22__;__ANDROID_23__ /errorendlocation /preferreduilang:en-US /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\MonoAndroid\v6.0\Mono.Android.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0\mscorlib.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0\System.Core.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0\System.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0\System.Xml.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0\System.Xml.Linq.dll" /debug:pdbonly /filealign:512 /optimize+ /out:obj\Release\App1.dll /ruleset:"C:\Program Files (x86)\Microsoft Visual Studio 14.0\Team Tools\Static Analysis Tools\\Rule Sets\MinimumRecommendedRules.ruleset" /target:library /utf8output MainActivity.cs Resources\Resource.Designer.cs Properties\AssemblyInfo.cs "C:\Users\a\AppData\Local\Temp\MonoAndroid,Version=v6.0.AssemblyAttributes.cs" obj\Release\\TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs obj\Release\\TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs obj\Release\\TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs
1>App1 -> C:\Users\a\Documents\Visual Studio 2015\Projects\App1\App1\bin\Release\App1.dll
1>  Processing: obj\Release\res\layout\main.xml
1>  Processing: obj\Release\res\values\strings.xml
1>C:\Program Files (x86)\Java\jdk1.7.0_55\\bin\keytool.exe -list -alias androiddebugkey -storepass android -keypass android -keystore "C:\Users\al\AppData\Local\Xamarin\Mono for Android\debug.keystore" 
1>C:\Program Files (x86)\Java\jdk1.7.0_55\\bin\jarsigner.exe -keystore "C:\Users\a\AppData\Local\Xamarin\Mono for Android\debug.keystore" -storepass android -keypass android -digestalg SHA1 -sigalg md5withRSA -signedjar bin\Release\\App1.App1-Signed-Unaligned.apk "C:\Users\a\Documents\Visual Studio 2015\Projects\App1\App1\obj\Release\android\bin\App1.App1.apk" androiddebugkey 
1>No -tsa or -tsacert is provided and this jar is not timestamped. Without a timestamp, users may not be able to validate this jar after the signer certificate's expiration date (2046-02-20) or after any future revocation date.
1>C:\Program Files (x86)\Android\android-sdk\build-tools\23.0.1\zipalign.exe 4 "C:\Users\a\Documents\Visual Studio 2015\Projects\App1\App1\bin\Release\App1.App1-Signed-Unaligned.apk" "bin\Release\\App1.App1-Signed.apk" 
1>Build succeeded.
1>Deploy successfully on 5" KitKat (4.4) XXHDPI Phone

And here are the build logs for debug mode

2>Starting deploy 5" KitKat (4.4) XXHDPI Phone ...
2>Deploying 5" KitKat (4.4) XXHDPI Phone ...
2>Build started.
2>C:\Program Files (x86)\Java\jdk1.7.0_55\\bin\keytool.exe -list -alias androiddebugkey -storepass android -keypass android -keystore "C:\Users\a\AppData\Local\Xamarin\Mono for Android\debug.keystore" 
2>C:\Program Files (x86)\Java\jdk1.7.0_55\\bin\jarsigner.exe -keystore "C:\Users\a\AppData\Local\Xamarin\Mono for Android\debug.keystore" -storepass android -keypass android -digestalg SHA1 -sigalg md5withRSA -signedjar bin\Debug\\App1.App1-Signed-Unaligned.apk "C:\Users\a\Documents\Visual Studio 2015\Projects\App1\App1\obj\Debug\android\bin\App1.App1.apk" androiddebugkey 
2>No -tsa or -tsacert is provided and this jar is not timestamped. Without a timestamp, users may not be able to validate this jar after the signer certificate's expiration date (2046-02-20) or after any future revocation date.
2>C:\Program Files (x86)\Android\android-sdk\build-tools\23.0.1\zipalign.exe 4 "C:\Users\a\Documents\Visual Studio 2015\Projects\App1\App1\bin\Debug\App1.App1-Signed-Unaligned.apk" "bin\Debug\\App1.App1-Signed.apk" 
2>Build succeeded.
2>Deploy successfully on 5" KitKat (4.4) XXHDPI Phone
like image 552
Jack Shepherd Avatar asked Mar 24 '16 15:03

Jack Shepherd


1 Answers

I had the same error running release builds in the emulator (VS Android emulator). Turns out, we had disabled x86 as supported architecture.

Advanced build properties

like image 155
Louis Haußknecht Avatar answered Nov 15 '22 06:11

Louis Haußknecht