我使用Mono for Android Visual Studio 2010创建了一个简单的Android项目,在屏幕上显示欢迎字符串。可以在模拟器上运行但在真实设备中失败。你能救我吗?
活动类
using System;
using Android.App;
using Android.Content;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;
namespace Welcome
{
[Activity(Label = "Welcome", MainLauncher = true, Icon = "@drawable/icon")]
public class Activity1 : Activity
{
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
TextView txt = new TextView(this);
txt.Text = "Welcome, Android";
SetContentView(txt);
}
}
}
的Manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="preferExternal" android:versionCode="1" android:versionName="1">
<uses-sdk android:targetSdkVersion="10" />
<application android:label="WelcomeAndroid">
</application>
</manifest>
以下是日志:
Packaging application..
Microsoft (R) Build Engine Version 4.0.30319.1
[Microsoft .NET Framework, Version 4.0.30319.1]
Copyright (C) Microsoft Corporation 2007. All rights reserved.
Build started 6/8/2014 11:09:04 PM.
Project "C:\Users\yo\Documents\Visual Studio 2010\Projects\Welcome\Welcome\Welcome.csproj" on node 1 (SignAndroidPackage target(s)).
_GenerateAndroidAssetsDir:
Skipping target "_GenerateAndroidAssetsDir" because it has no outputs.
_GenerateAndroidResourceDir:
Copying file from "Resources\Layout\Main.axml" to "C:\Users\yo\Documents\Visual Studio 2010\Projects\Welcome\Welcome\obj\Release\res\layout\main.xml".
_ResolveMonoAndroidSdks:
MonoAndroid Tools: C:\Program Files\MSBuild\Xamarin\Android\
MonoAndroid Framework: C:\Program Files\Reference Assemblies\Microsoft\Framework\MonoAndroid\v2.3\;C:\Program Files\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0\
MonoAndroid Binaries: C:\Program Files\MSBuild\Xamarin\Android\
Android SDK: D:\My Downloads\Android Development\adt-bundle-windows-x86-20140321\adt-bundle-windows-x86-20140321\sdk\
Java SDK: C:\Program Files\Java\jdk1.6.0_45\
_ValidateAndroidPackageProperties:
GetAndroidPackageName Task
ManifestFile: C:\Users\yo\Documents\Visual Studio 2010\Projects\Welcome\Welcome\Properties\AndroidManifest.xml
AssemblyName: Welcome
PackageName: Welcome.Welcome
_ExtractLibraryProjectImports:
Assemblies:
C:\Program Files\Reference Assemblies\Microsoft\Framework\MonoAndroid\v2.3\Mono.Android.dll
C:\Program Files\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0\mscorlib.dll
C:\Program Files\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0\System.Core.dll
C:\Program Files\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0\System.dll
C:\Program Files\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0\System.Xml.dll
C:\Program Files\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0\System.Xml.Linq.dll
Jars:
ResolvedResourceDirectories:
_CheckDuplicateJavaLibraries:
JavaSourceFiles:
JavaLibraries:
_UpdateAndroidResgen:
Skipping target "_UpdateAndroidResgen" because all output files are up-to-date with respect to the input files.
GenerateTargetFrameworkMonikerAttribute:
Skipping target "GenerateTargetFrameworkMonikerAttribute" because all output files are up-to-date with respect to the input files.
CoreCompile:
Skipping target "CoreCompile" because all output files are up-to-date with respect to the input files.
CopyFilesToOutputDirectory:
Welcome -> C:\Users\yo\Documents\Visual Studio 2010\Projects\Welcome\Welcome\bin\Release\Welcome.dll
_ResolveAssemblies:
ResolveAssemblies Task
ReferenceAssembliesDirectory: C:\Program Files\Reference Assemblies\Microsoft\Framework\MonoAndroid\v2.3\;C:\Program Files\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0\;;
I18nAssemblies:
LinkMode: SdkOnly
Assemblies:
bin\Release\Welcome.dll
C:\Program Files\Reference Assemblies\Microsoft\Framework\MonoAndroid\v2.3\Mono.Android.dll
C:\Program Files\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0\mscorlib.dll
C:\Program Files\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0\System.Core.dll
C:\Program Files\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0\System.dll
C:\Program Files\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0\System.Xml.dll
C:\Program Files\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0\System.Xml.Linq.dll
[Output] ResolvedAssemblies:
C:\Users\yo\Documents\Visual Studio 2010\Projects\Welcome\Welcome\bin\Release\Welcome.dll
C:\Program Files\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0\mscorlib.dll
C:\Program Files\Reference Assemblies\Microsoft\Framework\MonoAndroid\v2.3\Mono.Android.dll
C:\Program Files\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0\System.Core.dll
C:\Program Files\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0\System.dll
C:\Program Files\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0\Mono.Security.dll
C:\Program Files\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0\System.Xml.dll
[Output] ResolvedUserAssemblies:
C:\Users\yo\Documents\Visual Studio 2010\Projects\Welcome\Welcome\bin\Release\Welcome.dll
[Output] ResolvedFrameworkAssemblies:
C:\Program Files\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0\mscorlib.dll
C:\Program Files\Reference Assemblies\Microsoft\Framework\MonoAndroid\v2.3\Mono.Android.dll
C:\Program Files\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0\System.Core.dll
C:\Program Files\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0\System.dll
C:\Program Files\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0\Mono.Security.dll
C:\Program Files\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0\System.Xml.dll
_StripEmbeddedLibraries:
Assemblies:
obj\Release\assemblies\Welcome.dll
obj\Release\assemblies\mscorlib.dll
obj\Release\assemblies\Mono.Android.dll
obj\Release\assemblies\System.Core.dll
obj\Release\assemblies\System.dll
obj\Release\assemblies\Mono.Security.dll
obj\Release\assemblies\System.Xml.dll
_ResetLinkingFlag:
Building target "_ResetLinkingFlag" partially, because some output files are out of date with respect to their input files.
Deleting file "obj\Release\link.flag".
_LinkAssemblies:
LinkAssemblies Task
UseSharedRuntime: False
MainAssembly: obj\Release\assemblies\Welcome.dll
OutputDirectory: obj\Release\android\assets\
I18nAssemblies:
LinkMode: SdkOnly
LinkDescriptions:
ResolvedAssemblies:
obj\Release\assemblies\Welcome.dll
obj\Release\assemblies\mscorlib.dll
obj\Release\assemblies\Mono.Android.dll
obj\Release\assemblies\System.Core.dll
obj\Release\assemblies\System.dll
obj\Release\assemblies\Mono.Security.dll
obj\Release\assemblies\System.Xml.dll
Creating "obj\Release\link.flag" because "AlwaysCreate" was specified.
_PrepareAssemblies:
Files
obj\Release\android\assets\Welcome.dll
obj\Release\android\assets\mscorlib.dll
obj\Release\android\assets\Mono.Android.dll
obj\Release\android\assets\System.Core.dll
obj\Release\android\assets\System.dll
obj\Release\android\assets\Mono.Security.dll
obj\Release\android\assets\System.Xml.dll
[Output] FilesThatExist
obj\Release\android\assets\Welcome.dll
obj\Release\android\assets\mscorlib.dll
obj\Release\android\assets\Mono.Android.dll
obj\Release\android\assets\System.Core.dll
obj\Release\android\assets\System.dll
obj\Release\android\assets\Mono.Security.dll
Files
obj\Release\android\assets\mscorlib.dll.mdb
obj\Release\android\assets\Mono.Android.dll.mdb
obj\Release\android\assets\System.Core.dll.mdb
obj\Release\android\assets\System.dll.mdb
obj\Release\android\assets\Mono.Security.dll.mdb
obj\Release\android\assets\System.Xml.dll.mdb
[Output] FilesThatExist
Files
obj\Release\android\assets\Welcome.dll
[Output] FilesThatExist
obj\Release\android\assets\Welcome.dll
Files
obj\Release\android\assets\mscorlib.dll
obj\Release\android\assets\Mono.Android.dll
obj\Release\android\assets\System.Core.dll
obj\Release\android\assets\System.dll
obj\Release\android\assets\Mono.Security.dll
obj\Release\android\assets\System.Xml.dll
[Output] FilesThatExist
obj\Release\android\assets\mscorlib.dll
obj\Release\android\assets\Mono.Android.dll
obj\Release\android\assets\System.Core.dll
obj\Release\android\assets\System.dll
obj\Release\android\assets\Mono.Security.dll
_GenerateJavaStubs:
ResolvedAssemblies:
obj\Release\android\assets\Welcome.dll
obj\Release\android\assets\mscorlib.dll
obj\Release\android\assets\Mono.Android.dll
obj\Release\android\assets\System.Core.dll
obj\Release\android\assets\System.dll
obj\Release\android\assets\Mono.Security.dll
ResolvedUserAssemblies:
obj\Release\android\assets\Welcome.dll
_AddStaticResources:
Resource obj\Release\android\assets\machine.config is unchanged. Skipping.
Resource obj\Release\android\src\mono\MonoRuntimeProvider.java is unchanged. Skipping.
_GeneratePackageManagerJava:
ResolvedAssemblies:
obj\Release\android\assets\Welcome.dll
obj\Release\android\assets\mscorlib.dll
obj\Release\android\assets\Mono.Android.dll
obj\Release\android\assets\System.Core.dll
obj\Release\android\assets\System.dll
obj\Release\android\assets\Mono.Security.dll
ResolvedUserAssemblies:
obj\Release\android\assets\Welcome.dll
_CreateBaseApk:
AdditionalResourceDirectories:
D:\My Downloads\Android Development\adt-bundle-windows-x86-20140321\adt-bundle-windows-x86-20140321\sdk\platform-tools\aapt.exe package -f -m -M obj\Release\android\AndroidManifest.xml -J C:\Users\yo\AppData\Local\Temp\nu1dup5n.g3c --custom-package welcome.welcome -F obj\Release\android\bin\packaged_resources.bk -S obj\Release\res -I "D:\My Downloads\Android Development\adt-bundle-windows-x86-20140321\adt-bundle-windows-x86-20140321\sdk\platforms\android-10\android.jar" --auto-add-overlay --debug-mode
RemovedDirectories:
C:\Users\yo\AppData\Local\Temp\nu1dup5n.g3c
_CompileJava:
Skipping target "_CompileJava" because all output files are up-to-date with respect to the input files.
_CompileDex:
Skipping target "_CompileDex" because all output files are up-to-date with respect to the input files.
_RemoveRegisterAttribute:
Copying file from "obj\Release\android\assets\mscorlib.dll" to "obj\Release\android\assets\shrunk\mscorlib.dll".
Copying file from "obj\Release\android\assets\Mono.Android.dll" to "obj\Release\android\assets\shrunk\Mono.Android.dll".
Copying file from "obj\Release\android\assets\System.Core.dll" to "obj\Release\android\assets\shrunk\System.Core.dll".
Copying file from "obj\Release\android\assets\System.dll" to "obj\Release\android\assets\shrunk\System.dll".
Copying file from "obj\Release\android\assets\Mono.Security.dll" to "obj\Release\android\assets\shrunk\Mono.Security.dll".
RemoveRegisterAttribute Task
ShrunkFrameworkAssemblies:
obj\Release\android\assets\shrunk\mscorlib.dll
obj\Release\android\assets\shrunk\Mono.Android.dll
obj\Release\android\assets\shrunk\System.Core.dll
obj\Release\android\assets\shrunk\System.dll
obj\Release\android\assets\shrunk\Mono.Security.dll
Touching "obj\Release\android\assets\shrunk\shrunk.flag".
_BuildApkEmbed:
ResolvedUserAssemblies:
obj\Release\android\assets\Welcome.dll
ResolvedFrameworkAssemblies:
obj\Release\android\assets\shrunk\mscorlib.dll
obj\Release\android\assets\shrunk\Mono.Android.dll
obj\Release\android\assets\shrunk\System.Core.dll
obj\Release\android\assets\shrunk\System.dll
obj\Release\android\assets\shrunk\Mono.Security.dll
NativeLibraries:
JavaSourceFiles:
JavaLibraries:
_Mandroid:
Deleting file "obj\Release\android\bin\Welcome.Welcome.apk".
Deleting file "bin\Release\Welcome.Welcome.apk".
Mandroid Task
Assemblies: bin\Release\Welcome.dll; C:\Program Files\Reference Assemblies\Microsoft\Framework\MonoAndroid\v2.3\Mono.Android.dll; C:\Program Files\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0\mscorlib.dll; C:\Program Files\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0\System.Core.dll; C:\Program Files\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0\System.dll; C:\Program Files\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0\System.Xml.dll; C:\Program Files\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0\System.Xml.Linq.dll
I18nAssemblies:
BuildDirectory: obj\Release\
ReferenceAssembliesDirectory: C:\Program Files\Reference Assemblies\Microsoft\Framework\MonoAndroid\v2.3\;C:\Program Files\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0\;;
AndroidSdkDirectory: D:\My Downloads\Android Development\adt-bundle-windows-x86-20140321\adt-bundle-windows-x86-20140321\sdk\
JavaSdkDirectory: C:\Program Files\Java\jdk1.6.0_45\
AssetDirectory: obj\Release\assets\
AndroidSdkPlatform: 10
MonoAndroidToolsDirectory: C:\Program Files\MSBuild\Xamarin\Android\
ResourceDirectory: obj\Release\res\
ManifestTemplate: C:\Users\yo\Documents\Visual Studio 2010\Projects\Welcome\Welcome\Properties\AndroidManifest.xml
Package: Welcome.Welcome
NativeLibrary:
JavaSource:
Debug: False
UseSharedRuntime: False
SupportedAbis: armeabi;armeabi-v7a;x86
LinkMode: SdkOnly
ExtraArgs:
C:\Program Files\MSBuild\Xamarin\Android\mandroid.exe -v --nosign --sdk-dir="D:\My Downloads\Android Development\adt-bundle-windows-x86-20140321\adt-bundle-windows-x86-20140321\sdk" --builddir="obj\Release\android" --framework-dir="C:\Program Files\Reference Assemblies\Microsoft\Framework\MonoAndroid\v2.3" --framework-dir="C:\Program Files\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0" -S="obj\Release\res" --package="Welcome.Welcome" --input="obj\Release\android\bin\resources_and_assemblies" --output="obj\Release\android\bin\Welcome.Welcome.apk" --linksdkonly --noshared --abi="armeabi;armeabi-v7a;x86" --java-sdk-dir="C:\Program Files\Java\jdk1.6.0_45" --manifest-template="C:\Users\yo\Documents\Visual Studio 2010\Projects\Welcome\Welcome\Properties\AndroidManifest.xml" --sdk-platform="10" "bin\Release\Welcome.dll" "C:\Program Files\Reference Assemblies\Microsoft\Framework\MonoAndroid\v2.3\Mono.Android.dll" "C:\Program Files\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0\mscorlib.dll" "C:\Program Files\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0\System.Core.dll" "C:\Program Files\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0\System.dll" "C:\Program Files\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0\System.Xml.dll" "C:\Program Files\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0\System.Xml.Linq.dll"
Copying file from "obj\Release\android\bin\Welcome.Welcome.apk" to "bin\Release\Welcome.Welcome.apk".
Deleting file "obj\Release\uploadflags.txt".
_Sign:
C:\Program Files\Java\jdk1.6.0_45\bin\jarsigner.exe -keystore "C:\Users\yo\AppData\Local\Xamarin\Mono for Android\debug.keystore" -storepass android -keypass android -digestalg SHA1 -sigalg md5withRSA -signedjar bin\Release\Welcome.Welcome-Signed-Unaligned.apk obj\Release\android\bin\Welcome.Welcome.apk androiddebugkey
Signed android package 'bin\Release\Welcome.Welcome-Signed.apk'
Deleting file "bin\Release\Welcome.Welcome-Signed.apk".
AndroidZipAlign Task
AndroidSdkDirectory: D:\My Downloads\Android Development\adt-bundle-windows-x86-20140321\adt-bundle-windows-x86-20140321\sdk\
Alignment: 4
Source: bin\Release\Welcome.Welcome-Signed-Unaligned.apk
Destination: bin\Release\Welcome.Welcome-Signed.apk
D:\My Downloads\Android Development\adt-bundle-windows-x86-20140321\adt-bundle-windows-x86-20140321\sdk\tools\zipalign.exe 4 "bin\Release\Welcome.Welcome-Signed-Unaligned.apk" "bin\Release\Welcome.Welcome-Signed.apk"
Aligned android package 'bin\Release\Welcome.Welcome-Signed.apk'
Deleting file "bin\Release\Welcome.Welcome-Signed-Unaligned.apk".
Done Building Project "C:\Users\yo\Documents\Visual Studio 2010\Projects\Welcome\Welcome\Welcome.csproj" (SignAndroidPackage target(s)).
Build succeeded.
0 Warning(s)
0 Error(s)
Time Elapsed 00:00:12.27
Waiting for device..
Detecting installed packages
Detecting installed packages...
Removing previous version of application
Removing previous version of application...
Installing application on device
Copying application to device...
之后,会打印以下内容:
In mgmain JNI_OnLoad
The program 'Mono' has exited with code 255 (0xff).