应用程序在adb调试上工作正常,但在部署apk到手机后崩溃

时间:2016-05-31 14:36:41

标签: c# android xamarin.android locationmanager

我是关于xamarin的新手,所以我从教程中获取了BackgroundlocationDemo示例并更改了一些内容。基本上是在位置变化时连接到api。

在我的手机上使用vs usb调试工作正常,但是当我部署apk并安装在同一部手机上时,它会崩溃(不确定是什么时候它获取位置或发布到api时),没有错误,只是"应用已停止"消息。

不确定如何调试,或查看问题所在,或从手机崩溃中获取任何信息。

我感谢您提前帮助我指明正确的方向。

1 个答案:

答案 0 :(得分:0)

有人指出我使用Android设备日志记录(logcat),并从手机运行应用程序,而不是VS.

这样做我得到了这个输出:

06-01 00:44:40.431 E/AndroidRuntime( 2986): FATAL EXCEPTION: main
06-01 00:44:40.431 E/AndroidRuntime( 2986): Process: Location.Droid, PID: 2986
06-01 00:44:40.431 E/AndroidRuntime( 2986): java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
06-01 00:44:40.431 E/AndroidRuntime( 2986): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:700)
06-01 00:44:40.431 E/AndroidRuntime( 2986): Caused by: java.lang.reflect.InvocationTargetException
06-01 00:44:40.431 E/AndroidRuntime( 2986): at java.lang.reflect.Method.invoke(Native Method)
06-01 00:44:40.431 E/AndroidRuntime( 2986): at java.lang.reflect.Method.invoke(Method.java:372)
06-01 00:44:40.431 E/AndroidRuntime( 2986): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905)
06-01 00:44:40.431 E/AndroidRuntime( 2986): ... 1 more
06-01 00:44:40.431 E/AndroidRuntime( 2986): Caused by: md52ce486a14f4bcd95899665e9d932190b.JavaProxyThrowable: System.Net.WebException: Error: NameResolutionFailure
06-01 00:44:40.431 E/AndroidRuntime( 2986): at System.Net.WebClient.UploadDataInternal (System.Uri address, System.String method, System.Byte[] data, System.Net.WebRequest& request) [0x000a6] in :0
06-01 00:44:40.431 E/AndroidRuntime( 2986): at System.Net.WebClient.UploadString (System.Uri address, System.String method, System.String data) [0x00054] in :0
06-01 00:44:40.431 E/AndroidRuntime( 2986): at System.Net.WebClient.UploadString (System.String address, System.String data) [0x00019] in :0
06-01 00:44:40.431 E/AndroidRuntime( 2986): at (wrapper remoting-invoke-with-check) System.Net.WebClient:UploadString (string,string)
06-01 00:44:40.431 E/AndroidRuntime( 2986): at Location.Droid.Services.LocationService.OnLocationChanged (Android.Locations.Location location) [0x00157] in :0
06-01 00:44:40.431 E/AndroidRuntime( 2986): at Android.Locations.ILocationListenerInvoker.n_OnLocationChanged_Landroid_location_Location_ (IntPtr jnienv, IntPtr native__this, IntPtr native_location) [0x00011] in :0
06-01 00:44:40.431 E/AndroidRuntime( 2986): at (wrapper dynamic-method) System.Object:cad3edbb-2ed8-4cac-ad94-e74d5e046d4e (intptr,intptr,intptr)
06-01 00:44:40.431 E/AndroidRuntime( 2986): at md5227b9e8295fbee87e0da67869d6e828e.LocationService.n_onLocationChanged(Native Method)
06-01 00:44:40.431 E/AndroidRuntime( 2986): at md5227b9e8295fbee87e0da67869d6e828e.LocationService.onLocationChanged(LocationService.java:68)
06-01 00:44:40.431 E/AndroidRuntime( 2986): at android.location.LocationManager$ListenerTransport._handleMessage(LocationManager.java:281)
06-01 00:44:40.431 E/AndroidRuntime( 2986): at android.location.LocationManager$ListenerTransport.access$000(LocationManager.java:210)
06-01 00:44:40.431 E/AndroidRuntime( 2986): at android.location.LocationManager$ListenerTransport$1.handleMessage(LocationManager.java:226)
06-01 00:44:40.431 E/AndroidRuntime( 2986): at android.os.Handler.dispatchMessage(Handler.java:102)
06-01 00:44:40.431 E/AndroidRuntime( 2986): at android.os.Looper.loop(Looper.java:135)
06-01 00:44:40.431 E/AndroidRuntime( 2986): at android.app.ActivityThread.main(ActivityThread.java:5343) 

所以,这似乎是一个解决网址的问题。经过一番研究后,我发现我需要向该应用程序授予INTERNET权限。