Unfortunately, [App Name] has stopped.

I have been trying to deploy some small android apps on my vs2012 to Nexus 5(kitkat) emulator (Xamarin Android Player). And also the "hello world" first android application even with out editing anything. But it can't work for me. VS2012 says the Deploy is succeeded but when I try to open it on the emulator, it says " Unfortunately, Helloworld has stopped.". I have searched a lot to see any problem on it. but I haven't found helpful yet. I am a beginner for such development. Please help me why is it like this.

Answers

  • SebastianSeidel.9226SebastianSeidel.9226 DEInsider, University ✭✭✭✭

    Have you tried to debug the issue? Are there any exceptions?

  • MarewAtnafuMarewAtnafu USMember
    edited September 2015

    Yes, I have tried to debug it. No errors found. No exceptions. For the sake of testing, I have tried to debug and deploy the "Hello world" template with out editing anything.But it is all the same.

  • Thanks a lot @rzee7. I have tried the code snippet many times. But it doesn't work. No folder is created! I have edited the "GetLocalPath" to "GribLocalPath" in LogUnhandledException method of the code snippet. I had also provided write and read permissions for the app but no working yet.

  • rzee7rzee7 INUniversity ✭✭✭✭✭

    Hello @MarewAtnafu

    Where you have written this code? I can help you remotely if you say?

    Thanks
    RIYAZ

  • Hello @rzee7 Doha, Qatar. I am using the trial Xamarin platform. May this be the problem?

  • rzee7rzee7 INUniversity ✭✭✭✭✭

    I'd suggest you to use once Genymotion if an issue still there please upload your Hello App Demo and we'll sort out :smile:

    Cheers!!
    RIYAZ

  • Thanks @rzee7, I have tried in Genymotion. But it is the same. No folders created. Here is Main activity. cs file. If you need extra information I can provide you.

    using System;
    using Android.App;
    using Android.Content;
    using Android.Runtime;
    using Android.Views;
    using Android.Widget;
    using Android.OS;
    using System.IO;
    using System.Threading.Tasks;
    using System.Globalization;

    namespace App4
    {
    [Activity(Label = "App4", MainLauncher = true, Icon = "@drawable/icon")]
    public class MainActivity : Activity
    {
    int count = 1;

        protected override void OnCreate(Bundle bundle)
        {
            AppDomain.CurrentDomain.UnhandledException += CurrentDomainOnUnhandledException;
            TaskScheduler.UnobservedTaskException += TaskSchedulerOnUnobservedTaskException;  
    
    
            base.OnCreate(bundle);
    
            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);
    
            // Get our button from the layout resource,
            // and attach an event to it
            Button button = FindViewById<Button>(Resource.Id.MyButton);
    
            button.Click += delegate { button.Text = string.Format("{0} clicks!", count++); };
    
        }
        private static void TaskSchedulerOnUnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs unobservedTaskExceptionEventArgs)
        {
            var newExc = new Exception("TaskSchedulerOnUnobservedTaskException", unobservedTaskExceptionEventArgs.Exception);
            LogUnhandledException(newExc);
        }
    
        private static void CurrentDomainOnUnhandledException(object sender, UnhandledExceptionEventArgs unhandledExceptionEventArgs)
        {
            var newExc = new Exception("CurrentDomainOnUnhandledException", unhandledExceptionEventArgs.ExceptionObject as Exception);
            LogUnhandledException(newExc);
        }
    
        internal static void LogUnhandledException(Exception exception)
        {
            try
            {
                const string errorFileName = "Fatal.txt";
                var errorFilePath = GribLocalPath(errorFileName);
                var errorMessage = String.Format("Time: {0}\r\nError: Unhandled Exception\r\n{1}", DateTime.Now, exception.ToString());
                File.WriteAllText(errorFilePath, errorMessage);
    
    
            }
            catch (Exception ex)
            {
    
              var pat= System.IO.Path.Combine( Android.OS.Environment.DirectoryDownloads,ex.ToString(),"Error.txt");  // just suppress any error logging exceptions
              StreamWriter writer = new StreamWriter(pat, true);
              writer.Write(ex.ToString());
            }
        }
    
        public static string GribLocalPath(string fileName)
        {
            string dir = Path.Combine(Android.OS.Environment.ExternalStorageDirectory.ToString(), "Exception");
            if (Directory.Exists(dir))
                return Path.Combine(dir, fileName);
            return Path.Combine(Directory.CreateDirectory(dir).FullName, fileName);
        }
    }
    

    }

  • RenaudMotteRenaudMotte USMember

    Hi MarewAtnafu,

    Have you find a solution to your problem? I have the same problem... I did the "PhoneWord" app from the "Getting Started" tutorial of Xamarin without changing anything and when I try to start the app from vs2015 using the emulator, I got the error "unfortunately, PhoneWord has stopped"...

    Does someone know how to solve this problem?

    Thanks a lot!

  • RenaudMotteRenaudMotte USMember

    Sorry guys, I solved my problem by myself switching "Compile using Android version:" on the good option ...

  • N.Y.GudlanurN.Y.Gudlanur USMember

    Unfortunately, [App Name] has stopped.

    Please help me out for resolving above error

  • ArvindrajaArvindraja INMember ✭✭✭

    for solving this issue in Visual studio Inside the solution go to Properties--->Android options--->packaging--->here uncheck the "Use fast deployment". it will work :blush:

  • AlbertKAlbertK MYMember ✭✭✭✭

    Hi,

    If you are deploying to the emulator, try to check the X86 checkbox, Project-> 'Application Name' Properties ->Android Options->Advanced->Supported Architectures is armeabi-v7a. I am running the Hyper-V Android Emulator but i guess it is the same with the Android Player. Do it both for the Debug and Release version.

    Hope this helps.

  • ClausBehnClausBehn DKMember

    I have the same problem. I have set a break point at the very first line of code, but I do not even get to that line. The suggestions above did not help me. Is there a log file or something that I can look for?

  • ArvindrajaArvindraja INMember ✭✭✭

    @ClausBehn first of all your app not loading(as this thread is) how your break point will fire. If your app not stopping and loading properly than you are in the wrong thread. :) for that made another post or you can go through existing posts.

  • How did you fix it? Mine still wont work...

  • I have followed the instructions for the Introductory Phoneword app. If I try Debug Any CPU Android_Accelerated_x86 (Android 6.0 - API 23) I get "Unfortunately Phoneword has stopped".

    I set a breakpoint at line 14 base.OnCreate(bundle) but it doesn't reach it.

    Output is
    InspectorDebugSession(6): StateChange: Start -> EntryPointBreakpointRegistered
    InspectorDebugSession(6): Constructed
    Android application is debugging.
    InspectorDebugSession(6): HandleTargetEvent: TargetExited
    InspectorDebugSession(6): Disposed

    If I try to compile with Android_ARMv7a (Android 6.0 - API23) I get the message about Running an x86 based AVD is 10x faster, then once I go beyond that, the Android word appears on the emulator and just stays there.

    Then the output window of visual studio says:
    InspectorDebugSession(5): StateChange: Start -> EntryPointBreakpointRegistered
    InspectorDebugSession(5): Constructed
    Android application is debugging.
    Couldn't connect to logcat, GetProcessId returned: 0
    InspectorDebugSession(5): HandleTargetEvent: TargetExited
    InspectorDebugSession(5): Disposed

    The only thing that is maybe non-standard is that I installed the Android SDK on an external drive D: which is currently plugged in. That doesn't seem to be generating an error.

    Any help would be appreciated.

Sign In or Register to comment.