2017-02-09 330 views
2

我試圖在VS2015中使用Xamarin來運行PhoneWord教程Android應用程序。我已經用c#編寫了一切代碼,它的構建很好。但是,當我在仿真器上運行它時,什麼都不會發生。我已經從現有的Nexus5和Nexus6定義創建了AVD,並且爲Galaxy S7添加了定義,全部使用API​​級別21(5.0 Lollipop)。我的應用程序針對API級別21(5.0 Lollipop),將其作爲最低要求,並編譯爲5.0(棒棒糖)。無法在Visual Studio 2015中使用Xamarin啓動Android模擬器

當我開始調試時,模擬器屏幕會彈出其控件,但沒有任何反應。有時我會在屏幕中心顯示「Android」文本,但有時候它只是一個黑屏。我已經從下面的一些日誌文件中複製了輸出,但是對於Android開發來說是完全新的,所以不知道其他日誌/調試信息是否可用,或者如果這是我的安裝,我的應用程序,我的仿真器設置,我的硬件或其他東西。

我試過在VS中調試或先調試並啓動模擬器之前啓動模擬器。我已經讓它坐了一個小時以上,沒有變化。

我見過有關VT-x和英特爾HAXM的參考,但並沒有改變那裏的任何東西。我的模擬器都是ARM(armeabi/armeabi-v7a)。

logcat

Xamarin IDE日誌輸出:

 
    Xamarin.VisualStudio.UnhandledExceptionsManager Error: 0 : [2017-02-09 15:31:41.9755] An unhandled error occurred. Details: Error type 2 
android.util.AndroidException: Can't connect to activity manager; is the system running? 
    at com.android.commands.am.Am.onRun(Am.java:298) 
    at com.android.internal.os.BaseCommand.run(BaseCommand.java:47) 
    at com.android.commands.am.Am.main(Am.java:99) 
    at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method) 
    at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:249) 


Mono.AndroidTools.AdbException: Error type 2 
android.util.AndroidException: Can't connect to activity manager; is the system running? 
    at com.android.commands.am.Am.onRun(Am.java:298) 
    at com.android.internal.os.BaseCommand.run(BaseCommand.java:47) 
    at com.android.commands.am.Am.main(Am.java:99) 
    at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method) 
    at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:249) 

    at Mono.AndroidTools.AndroidDevice.c__DisplayClass77_0.b__0(Task`1 t) 
    at System.Threading.Tasks.ContinuationTaskFromResultTask`1.InnerInvoke() 
    at System.Threading.Tasks.Task.Execute() 
Xamarin.VisualStudio.Devices.DeviceManager Error: 0 : [2017-02-09 15:34:22.9377] System.Runtime.InteropServices.COMException (0x80004005): Project unavailable. 
    at EnvDTE.Project.get_FullName() 
    at Clide.Solution.Adapters.MsBuildAdapter.Adapt(ProjectNode from) 
    at lambda_method(Closure , IAdapter , Object) 
    at Clide.Patterns.Adapter.AdapterService.Adapt[TSource,TTarget](TSource source) 
    at Clide.Patterns.Adapter.AdapterService.Adaptable`1.As[T]() 
    at Clide.Sdk.Solution.ProjectNode.As[T]() 
    at Clide.Solution.Implementation.UserProjectProperties..ctor(ProjectNode project) 
    at Clide.Sdk.Solution.ProjectNode.get_UserProperties() 
    at Xamarin.VisualStudio.Devices.DeviceManager.GetBestDeviceFor(IProjectNode projectNode, IEnumerable`1 availableDevices) in C:\data\lanes\3513\00fa5cc4\source\xamarinvs\src\Core\VisualStudio.Devices\DeviceManager.cs:line 128 

Xamarin MonoDroid的日誌:

 
MonoDroidLog Information: 0 : [2017-02-09 15:35:06.3451] [I:sdk]:     Key HKCU\SOFTWARE\Novell\Mono for Android\AndroidSdkDirectory found: 
    Path contains adb in \platform-tools (C:\Program Files (x86)\Android\android-sdk). 
MonoDroidLog Information: 0 : [2017-02-09 15:35:06.3521] [I:sdk]:     Key HKCU\SOFTWARE\Novell\Mono for Android\AndroidNdkDirectory found: 
    Path contains ndk-stack in \. (C:\ProgramData\Microsoft\AndroidNDK\android-ndk-r11c\). 
MonoDroidLog Information: 0 : [2017-02-09 15:35:06.3601] [I:sdk]:     Key HKCU\SOFTWARE\Novell\Mono for Android\JavaSdkDirectory not found. 
MonoDroidLog Information: 0 : [2017-02-09 15:35:06.3751] [I:sdk]:     Key HKCU\SOFTWARE\Novell\Mono for Android\JavaSdkDirectory not found. 
MonoDroidLog Information: 0 : [2017-02-09 15:35:06.3942] [I:sdk]:     Key HKLM\SOFTWARE\Novell\Mono for Android\JavaSdkDirectory not found. 
MonoDroidLog Information: 0 : [2017-02-09 15:35:06.4042] [I:sdk]:     Looking for Java 6 SDK.. 
MonoDroidLog Information: 0 : [2017-02-09 15:35:06.4112] [I:sdk]:     Key HKLM\SOFTWARE\JavaSoft\Java Development Kit\CurrentVersion found. 
MonoDroidLog Information: 0 : [2017-02-09 15:35:06.4192] [I:sdk]:     Key HKLM\SOFTWARE\JavaSoft\Java Development Kit\1.6\JavaHome not found. 
MonoDroidLog Information: 0 : [2017-02-09 15:35:06.4322] [I:sdk]:     Key HKLM\SOFTWARE\JavaSoft\Java Development Kit\1.7\JavaHome found: 
    Path contains jarsigner.exe in \bin (C:\Program Files (x86)\Java\jdk1.7.0_55). 
MonoDroidLog Information: 0 : [2017-02-09 15:35:06.4662] [I:Unknown]:    Found Xamarin.Android 7.0.2 
MonoDroidLog Information: 0 : [2017-02-09 15:35:06.4772] [I:Unknown]:    Found Android SDK. API levels: 21, 22, 23 
MonoDroidLog Information: 0 : [2017-02-09 15:35:14.6236] [I:]:      Tracking android devices started 
MonoDroidLog Information: 0 : [2017-02-09 15:35:14.6446] [D:]:      Tracking avd started 
MonoDroidLog Information: 0 : [2017-02-09 15:35:14.6626] [D:]:      avd watcher *.ini path: 'C:\Users\Mark\.android\avd' 
MonoDroidLog Information: 0 : [2017-02-09 15:35:14.6746] [D:]:      TrackDeviceTask got: 
MonoDroidLog Information: 0 : [2017-02-09 15:35:14.6846] [I:]:      Got new device list from adb with 0 devices 
MonoDroidLog Information: 0 : [2017-02-09 15:35:14.6956] [D:]:      avd watcher android path: 'C:\PROGRA~2\Android\ANDROI~1\tools\android.BAT' 
MonoDroidLog Information: 0 : [2017-02-09 15:35:16.8547] [D:]:      avd watcher: got device list from avd with 2 devices 
MonoDroidLog Information: 0 : [2017-02-09 15:36:08.1347] [D:]:      TrackDeviceTask got: emulator-5554 offline 
MonoDroidLog Information: 0 : [2017-02-09 15:36:08.1457] [I:]:      Got new device list from adb with 1 devices 
MonoDroidLog Information: 0 : [2017-02-09 15:36:27.8368] [D:]:      TrackDeviceTask got: emulator-5554 device 
MonoDroidLog Information: 0 : [2017-02-09 15:36:27.8458] [I:]:      Got new device list from adb with 1 devices 
MonoDroidLog Information: 0 : [2017-02-09 15:36:27.8598] [D:RunShellCommand]:  emulator-5554 getprop 
MonoDroidLog Information: 0 : [2017-02-09 15:36:27.8748] [D:RunShellCommand]:  emulator-5554 getprop 
MonoDroidLog Information: 0 : [2017-02-09 15:36:49.6961] [I:Unknown]:    Found Android SDK. API levels: 21, 22, 23 
MonoDroidLog Information: 0 : [2017-02-09 15:36:49.7461] [D:RunShellCommand]:  emulator-5554 getprop 
MonoDroidLog Information: 0 : [2017-02-09 15:36:50.7321] [D:RunShellCommand]:  emulator-5554 am broadcast -a "mono.android.intent.action.PACKAGE_VERSIONS" -e "packages" "Mono.Android.DebugRuntime,Mono.Android.Platform.ApiLevel_21,HelloAndroid2.HelloAndroid2" -n "Mono.Android.DebugRuntime/com.xamarin.mono.android.PackageVersions" 
MonoDroidLog Information: 0 : [2017-02-09 15:36:58.2065] [D:RunShellCommand]:  emulator-5554 cat /data/system/packages.xml 
MonoDroidLog Information: 0 : [2017-02-09 15:37:18.2327] [D:RunShellCommand]:  emulator-5554 pm install "/data/local/tmp/HelloAndroid2.HelloAndroid2-Signed.apk" 
MonoDroidLog Information: 0 : [2017-02-09 15:37:23.6120] [D:RunShellCommand]:  emulator-5554 rm "/data/local/tmp/HelloAndroid2.HelloAndroid2-Signed.apk" 
MonoDroidLog Error: 0 : [2017-02-09 15:37:24.1470] [E:]:      Deployment failed 
Mono.AndroidTools.InstallFailedException: Unexpected install output: Error: Could not access the Package Manager. Is the system running? 

    at Mono.AndroidTools.Internal.AdbOutputParsing.CheckInstallSuccess(String output, String packageName) 
    at Mono.AndroidTools.AndroidDevice.c__DisplayClass91_0.b__0(Task`1 t) 
    at System.Threading.Tasks.ContinuationTaskFromResultTask`1.InnerInvoke() 
    at System.Threading.Tasks.Task.Execute() 
MonoDroidLog Information: 0 : [2017-02-09 15:37:24.8721] [D:RunShellCommand]:  emulator-5554 date +%s 
MonoDroidLog Information: 0 : [2017-02-09 15:37:25.2461] [D:RunShellCommand]:  emulator-5554 setprop "debug.mono.extra" "debug=127.0.0.1:8947:8948,timeout=1486676275,loglevel=0,server=y" 
MonoDroidLog Information: 0 : [2017-02-09 15:37:25.5571] [D:RunShellCommand]:  emulator-5554 getprop 
MonoDroidLog Information: 0 : [2017-02-09 15:37:25.8891] [D:RunShellCommand]:  emulator-5554 "echo" "-n" "${EMULATED_STORAGE_SOURCE}" 
MonoDroidLog Information: 0 : [2017-02-09 15:37:26.0201] [D:RunShellCommand]:  emulator-5554 "echo" "-n" "${EMULATED_STORAGE_TARGET}" 
MonoDroidLog Information: 0 : [2017-02-09 15:37:26.1601] [D:RunShellCommand]:  emulator-5554 am broadcast -a "mono.android.intent.action.EXTERNAL_STORAGE_DIRECTORY" -n "Mono.Android.DebugRuntime/com.xamarin.mono.android.ExternalStorageDirectory" 
MonoDroidLog Information: 0 : [2017-02-09 15:37:31.4024] [D:RunShellCommand]:  emulator-5554 "echo" "-n" "${EXTERNAL_STORAGE}" 
MonoDroidLog Information: 0 : [2017-02-09 15:37:31.5895] [D:RunShellCommand]:  emulator-5554 am start -a "android.intent.action.MAIN" -c "android.intent.category.LAUNCHER" -n "HelloAndroid2.HelloAndroid2/md5c35c20f10c18d97cfa5803a7c4a6812a.MainActivity" 
MonoDroidLog Information: 0 : [2017-02-09 15:37:41.6850] [D:RunShellCommand]:  emulator-5554 ps 
MonoDroidLog Information: 0 : [2017-02-09 15:37:42.2211] [D:RunShellCommand]:  emulator-5554 am force-stop HelloAndroid2.HelloAndroid2 
MonoDroidLog Information: 0 : [2017-02-09 15:37:42.2461] [D:RunShellCommand]:  emulator-5554 setprop "debug.mono.connect" "" 
MonoDroidLog Information: 0 : [2017-02-09 15:38:43.8396] [D:]:      TrackDeviceTask got: 
MonoDroidLog Information: 0 : [2017-02-09 15:38:43.8556] [I:]:      Got new device list from adb with 0 devices 
MonoDroidLog Information: 0 : [2017-02-09 15:39:05.9028] [D:]:      TrackDeviceTask got: emulator-5554 offline 
MonoDroidLog Information: 0 : [2017-02-09 15:39:05.9149] [I:]:      Got new device list from adb with 1 devices 
MonoDroidLog Information: 0 : [2017-02-09 15:39:24.8799] [D:]:      TrackDeviceTask got: emulator-5554 device 
MonoDroidLog Information: 0 : [2017-02-09 15:39:24.8919] [I:]:      Got new device list from adb with 1 devices 
MonoDroidLog Information: 0 : [2017-02-09 15:39:24.9049] [D:RunShellCommand]:  emulator-5554 getprop 
MonoDroidLog Information: 0 : [2017-02-09 15:39:24.9209] [D:RunShellCommand]:  emulator-5554 getprop 
MonoDroidLog Information: 0 : [2017-02-09 15:39:44.6171] [I:Unknown]:    Found Android SDK. API levels: 21, 22, 23 
MonoDroidLog Information: 0 : [2017-02-09 15:39:44.6371] [D:RunShellCommand]:  emulator-5554 getprop 
MonoDroidLog Information: 0 : [2017-02-09 15:39:45.2531] [D:RunShellCommand]:  emulator-5554 am broadcast -a "mono.android.intent.action.PACKAGE_VERSIONS" -e "packages" "Mono.Android.DebugRuntime,Mono.Android.Platform.ApiLevel_21,HelloAndroid2.HelloAndroid2" -n "Mono.Android.DebugRuntime/com.xamarin.mono.android.PackageVersions" 
MonoDroidLog Information: 0 : [2017-02-09 15:39:53.1496] [D:RunShellCommand]:  emulator-5554 cat /data/system/packages.xml 
MonoDroidLog Information: 0 : [2017-02-09 15:40:10.3725] [D:RunShellCommand]:  emulator-5554 pm install "/data/local/tmp/HelloAndroid2.HelloAndroid2-Signed.apk" 
MonoDroidLog Information: 0 : [2017-02-09 15:40:15.9999] [D:RunShellCommand]:  emulator-5554 rm "/data/local/tmp/HelloAndroid2.HelloAndroid2-Signed.apk" 
MonoDroidLog Error: 0 : [2017-02-09 15:40:16.4479] [E:]:      Deployment failed 
Mono.AndroidTools.InstallFailedException: Unexpected install output: Error: Could not access the Package Manager. Is the system running? 

    at Mono.AndroidTools.Internal.AdbOutputParsing.CheckInstallSuccess(String output, String packageName) 
    at Mono.AndroidTools.AndroidDevice.c__DisplayClass91_0.b__0(Task`1 t) 
    at System.Threading.Tasks.ContinuationTaskFromResultTask`1.InnerInvoke() 
    at System.Threading.Tasks.Task.Execute() 
MonoDroidLog Information: 0 : [2017-02-09 15:40:16.7279] [D:RunShellCommand]:  emulator-5554 date +%s 
MonoDroidLog Information: 0 : [2017-02-09 15:40:17.1079] [D:RunShellCommand]:  emulator-5554 setprop "debug.mono.extra" "debug=127.0.0.1:8949:8950,timeout=1486676447,loglevel=0,server=y" 
MonoDroidLog Information: 0 : [2017-02-09 15:40:17.4169] [D:RunShellCommand]:  emulator-5554 getprop 
MonoDroidLog Information: 0 : [2017-02-09 15:40:17.8090] [D:RunShellCommand]:  emulator-5554 "echo" "-n" "${EMULATED_STORAGE_SOURCE}" 
MonoDroidLog Information: 0 : [2017-02-09 15:40:18.0240] [D:RunShellCommand]:  emulator-5554 "echo" "-n" "${EMULATED_STORAGE_TARGET}" 
MonoDroidLog Information: 0 : [2017-02-09 15:40:18.1630] [D:RunShellCommand]:  emulator-5554 am broadcast -a "mono.android.intent.action.EXTERNAL_STORAGE_DIRECTORY" -n "Mono.Android.DebugRuntime/com.xamarin.mono.android.ExternalStorageDirectory" 
MonoDroidLog Information: 0 : [2017-02-09 15:40:23.6083] [D:RunShellCommand]:  emulator-5554 "echo" "-n" "${EXTERNAL_STORAGE}" 
MonoDroidLog Information: 0 : [2017-02-09 15:40:23.8193] [D:RunShellCommand]:  emulator-5554 am start -a "android.intent.action.MAIN" -c "android.intent.category.LAUNCHER" -n "HelloAndroid2.HelloAndroid2/md5c35c20f10c18d97cfa5803a7c4a6812a.MainActivity" 
MonoDroidLog Information: 0 : [2017-02-09 15:40:33.7989] [D:RunShellCommand]:  emulator-5554 ps 
MonoDroidLog Information: 0 : [2017-02-09 15:40:34.3339] [D:RunShellCommand]:  emulator-5554 am force-stop HelloAndroid2.HelloAndroid2 
MonoDroidLog Information: 0 : [2017-02-09 15:40:34.3509] [D:RunShellCommand]:  emulator-5554 setprop "debug.mono.connect" "" 
MonoDroidLog Information: 0 : [2017-02-09 15:42:05.8061] [D:]:      TrackDeviceTask got: 
MonoDroidLog Information: 0 : [2017-02-09 15:42:05.8201] [I:]:      Got new device list from adb with 0 devices 

回答

0

我能得到它的工作,雖然我不知道這是否是隻有我做過的一個步驟或它們的組合。

我在項目中有兩個佈局(Main.axml和ListLayout.axml),可能來自另一個教程,但只填寫了其中的一個。我的MainActivity正在調用空白布局。我改變它來調用正確的佈局。

我的項目設置也沒有任何支持的體系結構(項目 - >屬性 - > Android選項 - >高級),所以我檢查了armeabiarmeabi-v7a。我還檢查了選項(在「打包」選項卡上)爲每個體系結構生成一個包,並取消選中使用共享運行時和快速部署的選項。

這樣做,我能夠讓模擬器運行並測試Phoneword應用程序。

然後我啓用了虛擬化在我的BIOS,檢查了x86架構,採用英特爾的x86 CPU定義一個新的仿真設備,並很能現在能更快地運行模擬器。

相關問題