0

I just installed the new Visual Studio for Mac, but I cannot run the standard app on an emulator. It's the "hello world" app that's created by Visual Studio itself when you create a new project. I've tried to run it using the included emulator but also Xamarin Android Player. However, for both emulators I get the following error:

"Unfortunately, app has stopped."

The emulators work fine. It's only the app that is giving problems.

I feel like I'm missing something in the manifest or something. But this is the standard app. It should work, right?

Code from main activity:

using Android.App;
using Android.Widget;
using Android.OS;

namespace Project_App3.Droid
{
    [Activity(Label = "App3", MainLauncher = true, Icon =     "@mipmap/icon")]
public class MainActivity : Activity
{
    int count = 1;

    protected override void OnCreate(Bundle savedInstanceState)
    {
        base.OnCreate(savedInstanceState);

        // 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 = $"{count++} clicks!"; };
    }
}
}

Manifest code:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"     android:versionCode="1" android:versionName="1.0"     package="com.test.app3">
<uses-sdk android:minSdkVersion="15" />
<application android:label="App3">
</application>
</manifest>

Application Output:

[art] Not late-enabling -Xcheck:jni (already on)
[AndroidRuntime] Shutting down VM
[AndroidRuntime] FATAL EXCEPTION: main

[AndroidRuntime] Process: com.test.app3, PID: 5225 [AndroidRuntime] java.lang.RuntimeException: Unable to get provider mono.MonoRuntimeProvider: java.lang.RuntimeException: Unable to find application Mono.Android.Platform.ApiLevel_24 or Xamarin.Android.Platform! [AndroidRuntime] at android.app.ActivityThread.installProvider(ActivityThread.java:5156) [AndroidRuntime] at android.app.ActivityThread.installContentProviders(ActivityThread.java:4748) [AndroidRuntime] at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4688) [AndroidRuntime] at android.app.ActivityThread.-wrap1(ActivityThread.java) [AndroidRuntime] at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1405) [AndroidRuntime] at android.os.Handler.dispatchMessage(Handler.java:102) [AndroidRuntime] at android.os.Looper.loop(Looper.java:148) [AndroidRuntime] at android.app.ActivityThread.main(ActivityThread.java:5417) [AndroidRuntime] at java.lang.reflect.Method.invoke(Native Method) [AndroidRuntime] at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) [AndroidRuntime] at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) [AndroidRuntime] Caused by: java.lang.RuntimeException: Unable to find application Mono.Android.Platform.ApiLevel_24 or Xamarin.Android.Platform! [AndroidRuntime] at mono.MonoRuntimeProvider.attachInfo(MonoRuntimeProvider.java:38) [AndroidRuntime] at android.app.ActivityThread.installProvider(ActivityThread.java:5153) [AndroidRuntime] ... 10 more [AndroidRuntime] Caused by: android.content.pm.PackageManager$NameNotFoundException: Xamarin.Android.Platform [AndroidRuntime] at android.app.ApplicationPackageManager.getApplicationInfo(ApplicationPackageManager.java:304) [AndroidRuntime] at mono.MonoRuntimeProvider.attachInfo(MonoRuntimeProvider.java:32) [AndroidRuntime] ... 11 more

Lex Li
  • 60,503
  • 9
  • 116
  • 147
Zarif
  • 587
  • 1
  • 4
  • 26
  • Of course, there are no build errors. – Zarif Nov 19 '16 at 15:17
  • You should see some error when it says "Unfortunately, app has stopped." – Nongthonbam Tonthoi Nov 19 '16 at 15:18
  • There must be some runtime errors. What API level is the emulator? – Andrius Nov 19 '16 at 15:20
  • @Andrius API level 23 for the included emulator and API level 22 for Xamarin Android Player. I will try to include a screenshot of the error in a minute – Zarif Nov 19 '16 at 15:22
  • Screenshot of the error: http://imgur.com/a/Ql0Xf – Zarif Nov 19 '16 at 15:25
  • @Zarif There should be some errors in your VS for Mac console. That would be helpful. Could you please add errors (stack trace) that you see to the bottom of your question? – Andrius Nov 19 '16 at 15:27
  • @Andrius I only get the following warning, but that's normal: "/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets: Warning: 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". – Zarif Nov 19 '16 at 15:30
  • @Andrius Maybe I'm not looking at the right place, I don't know. – Zarif Nov 19 '16 at 15:31
  • @Zarif Please post the content of your console window in VS for Mac after you see the `Unfortunately, app has stopped.` message in the emulator. – Andrius Nov 19 '16 at 15:35
  • @Andrius I've added the application output/console. Sorry for the bad formatting. – Zarif Nov 19 '16 at 15:40
  • I had the same error yesterday, changing app name , package name (anything that contains name) to a random name solved the problem for me. – abdallahesam Nov 19 '16 at 15:43
  • @Zarif What is your Android target version? You can try disabling shared mono runtime: Application Options -> Build -> Android Build -> uncheck Use Shared Mono Runtime. – Andrius Nov 19 '16 at 15:49
  • @abdallahesam I found the solution. Check the answer below. – Zarif Nov 19 '16 at 15:49
  • @Andrius I found the solution using your help. Thanks! See answer below. – Zarif Nov 19 '16 at 15:49

1 Answers1

1

I found the answer using Andrius' help. I googled the runtime exceptions and I found the solution here: unable to create helloworld

I changed the target framework to Android Marshmallow

Community
  • 1
  • 1
Zarif
  • 587
  • 1
  • 4
  • 26