Monodroid引发错误

时间:2011-06-30 08:34:00

标签: xamarin.android

我正在尝试运行在Visual Studio中创建新项目时默认生成的简单代码。模拟器引发异常。它是Mono for Android的评估版。为什么会发生错误?感谢。

这里是代码

using System;

using Android.App;
using Android.Content;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;

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

    protected override void OnCreate(Bundle bundle)
    {
        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++); };
    }
}
}

此处错误

尝试启动活动'MonoAndroidApplication1.MonoAndroidApplication1 / monoandroidapplication1.Activity1',但设备无法找到它。

这种情况的一个常见原因是手动添加一个名称与您的Activity类不匹配的AndroidManifest.xml。

请考虑使用[Activity]属性: http://monodroid.net/Tutorials/Working_with_AndroidManifest.xml

2 个答案:

答案 0 :(得分:0)

您的设备上是否已成功安装该应用程序?您可以在应用托盘中检查是否有图标,或者检查设置 - &gt;应用程序屏幕。

我的猜测是应用程序由于某种原因未成功安装,并且IDE未正确检测到故障。

答案 1 :(得分:-1)

Here information from log file 

    -- Starting Process - 30.06.2011 23:41:35 --
Executable: C:\Program Files (x86)\Android\android-sdk\platform-tools\adb.exe
Arguments: start-server
Appending Java path: C:\Program Files\Java\jdk1.6.0_26\bin
[STDOUT] 
-- Process Finished [5000] --
-- Starting Process - 30.06.2011 23:41:36 --
Executable: C:\Program Files (x86)\Android\android-sdk\platform-tools\adb.exe
Arguments: -s emulator-5554 install "C:\MonoDroid\MonoAndroidApplication2\MonoAndroidApplication2\bin\Debug\MonoAndroidApplication2.MonoAndroidApplication2-Signed.apk"
Appending Java path: C:\Program Files\Java\jdk1.6.0_26\bin
[STDOUT]    pkg: /data/local/tmp/MonoAndroidApplication2.MonoAndroidApplication2-Signed.apk
[STDOUT] 
[STDOUT] Failure [INSTALL_PARSE_FAILED_NO_CERTIFICATES]
[STDOUT] 
[STDERR] 72 KB/s (139602 bytes in 1.883s)
-- Starting Process - 30.06.2011 23:41:54 --
Executable: C:\Program Files (x86)\Android\android-sdk\platform-tools\adb.exe
Arguments: start-server
Appending Java path: C:\Program Files\Java\jdk1.6.0_26\bin
[STDOUT] 
[STDERR] 
-- Process Finished [5000] --
-- Starting Process - 30.06.2011 23:41:54 --
Executable: C:\Program Files (x86)\Android\android-sdk\platform-tools\adb.exe
Arguments: -s emulator-5554 shell am start -a android.intent.action.MAIN -n MonoAndroidApplication2.MonoAndroidApplication2/monoandroidapplication2.Activity1
Appending Java path: C:\Program Files\Java\jdk1.6.0_26\bin
[STDOUT] Starting: Intent { act=android.intent.action.MAIN cmp=MonoAndroidApplication2.MonoAndroidApplication2/monoandroidapplication2.Activity1 }
[STDOUT] 
[STDOUT] Error type 3
[STDOUT] 
[STDOUT] Error: Activity class {MonoAndroidApplication2.MonoAndroidApplication2/monoandroidapplication2.Activity1} does not exist.
[STDOUT] 

So the error is INSTALL_PARSE_FAILED_NO_CERTIFICATES. How to resolve it? Thanks.