apk from Xamarin.Forms keeps crashing

TwoChainTwoChain CAMember ✭✭

Hi All,

Unfortunately when I load my apk onto a physical device, it crashes immediately. I have been playing around trying to figure out what is happening, and here are my observations:

1) If I set linking to 'none', it works. So clearly the problem has to do with the linking. However, this is clearly not a viable solution.

2) In debug mode, if I enable proguard and turn linking on, the app still works fine.

3) If I make a new blank Xamarin.Forms app, then follow the instructions to release the apk for Android, the same problem occurs (the app immediately crashes).

4) If I make a blank Xamarin.Android app, then follow the instructions, the apk works fine.

It is very difficult to troubleshoot without knowing why the App is crashing. Do you have any suggestions as to what is occurring, or how I can get a log file on my physical device to understand why the Xamarin.Forms version of the Android apk fails, when the Xamarin.Android version works fine?

Thanks,

Dustin

Tagged:

Answers

  • TwoChainTwoChain CAMember ✭✭

    Yes... specifically what part? I don't see any mention of my issue in that explanation. Can you provide some further input?

    Thanks,

    Dustin

  • AlessandroCaliaroAlessandroCaliaro ITMember ✭✭✭✭✭
    If I remember correctly on android there is the possibility to catch all unhandled exceptions...
  • TwoChainTwoChain CAMember ✭✭

    So you suggest I put a try/catch in the main page and get it to print off (maybe DisplayAlert) the error? I hadn't thought to try this, but will give it a shot and let you know.

    Thanks,

    Dustin

  • TwoChainTwoChain CAMember ✭✭

    Is anyone else having this problem? I've tried updating my Visual Studio to the latest version (15.7.5). Unfortunately, now even the Xamarin.Android template is generating an APK that crashes immediately. This is getting extremely frustrating...

    Any other suggestions/ideas? Is anyone else having this problem?

    Dustin

  • robbitrobbit CNMember Xamurai

    Please read this to get the error logs.

  • TwoChainTwoChain CAMember ✭✭

    Thanks for the comments. Unfortunately I am no further along in my struggles. To recap, here is my issue:

    1) Using Xamarin.Anroid, if I open a 'single view' template, and run this on an emulator (or physical device), it works fine. If I turn linking on and ProGuard, and run in debug mode, it still works fine.

    However, if I release an APK, and try to install that on a physical device, the app crashes immediately.

    If I turn the linking off, rebuild the APK, and install it on a physical device, the App works fine.

    2) Using Xamarin.Anroid, if I open a 'blank app' template, everything works fine (APK can be built with linking on, and the app does not crash).

    3) Using Xamarin.Forms, if I try to release an APK for the Android project, I get exactly the same issues as I am experiencing with 1).

    I have tried working through the solutions listed here (https://forums.xamarin.com/discussion/55666/app-runs-in-debug-mode-crashes-in-release-mode), but nothing has worked.

    I must stress that this problem persists even in the sample demo templates available in VS. .

    When I compare between the 'blank app' (which works) and the 'single view' (which doesn't work) the only clear difference I see is the use of Android.Support.V7.Widget.Toolbar.

    However, I have tried including Android.Support in the 'skip linking assemblies' and this doesn't seem to help (in fact, it seems like no matter what I type into the 'skip linking assemblies' section, the APK file size remains unchanged which makes me wonder if this is doing anything at all?)

    I am currently running Windows 10, and using VS 15.7.5.

    Question: If am experiencing this error even for the basic templates (with no additional code added) that are included in VS, then isn't this a bug that needs to be fixed? Why would even the basic templates not work?

  • 74hakansukur74hakansukur Member ✭✭
    edited January 29

    Hello

    You should play with ignored assemblies in Android Options menu.
    I ignored (Skip linking assemblies) System and mscorlib and application works fine.

  • rouge1nirouge1ni GBMember ✭✭✭

    This still appears to be an issue why can't we just get an apk built without all the fiddley changing build time options shouldn't be the case.

  • jtthjtth Member ✭✭

    @robbit said:
    Please read this to get the error logs.

    A no-go on our end. Any updates to this?? Deploying APKs inhouse using VSTS (Azure DevOps) and have no way of debugging the app to see why it is crashing... it works and deploys perfectly fine from VS.

Sign In or Register to comment.