Monodroid default application in VS2010 fails to run with "activity not found" error
I have installed MonoDroid (and all prerequisites) and trying to run the default Android project in VS2010. This is the code:
[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++); };
}
}
When running the application an error is returned:
Tried to launch activity 'MonoAndroidApplication1.MonoAndroidApplication1/monoandroidapplication1.Activity1', but the device could not find it.
A common cause of this is manually adding an to your AndroidManifest.xml whose name does not match your Activity class.
Consider using the [Activity] attribute instead: http://monodroid.net/Tutorials/Working_with_AndroidManifest.xml
I have installed the Android SDK in C:\Android_SDK and accordingly set the location in Tools->Options->Mono for Android.
Mono also seems to be correctly installed on the emulator and this is the final bit of log from ADB:
-- Process Finished [5000] --
-- Starting Process - 17/08/2011 12:01:03 --
Executable: C:\Android_SDK\platform-tools\adb.exe
Arguments: -s emulator-5554 install "C:\Users\***************\documents\visual studio 2010\Projects\MonoAndroidApplication1\MonoAndroidApplication1\bin\Debug\MonoAndroidApplication1.MonoAndroidApplication1-Signed.apk"
Appending Java path: C:\Program Files\Java\jdk1.7.0\bin
[STDOUT] pkg: /data/local/tmp/MonoAndroidApplication1.MonoAndroidApplication1-Signed.apk
[STDOUT]
[STDOUT] Failure [INSTALL_PARSE_FAILED_NO_CERTIFICATES]
[STDOUT]
[STDERR] 696 KB/s (139717 bytes in 0.196s)
-- Starting Process - 17/08/2011 12:01:05 --
Executable: C:\Android_SDK\platform-tools\adb.exe
Arguments: start-server
Appending Java path: C:\Program Files\Java\jdk1.7.0\bin
[STDOUT]
[STDERR]
-- Process Finished [5000] --
-- Starting Process - 17/08/2011 12:01:05 --
Executable: C:\Android_SDK\platform-tools\adb.exe
Arguments: -s emulator-5554 shell am start -a android.intent.action.MAIN -n MonoAndroidApplication1.MonoAndroidApplication1/monoandroidapplication1.Activity1
Appending Java path: C:\Program Files\Java\jdk1.7.0\bin
[STDOUT] Starting: Intent { act=android.intent.action.MAIN cmp=MonoAndroidApplication1.MonoAndroidApplication1/monoandroidapplication1.Activity1 }
[STDOUT]
[STDOUT] Error type 3
[STDOUT]
[STDOUT] Error: Activity class{MonoAndroidApplication1.MonoAndroidApplication1/monoandroidapplication1.Activity1} does not exist.
[STDOUT]
This post Monodroid raises error is about the same error but reinstalling Mono on the emulator doesn't seem to work for me.
Mono for Android is not compatible with Java 7. Uninstall Java 7, install Java 6, and try again.
精彩评论