gpt4 book ai didi

c# - Xamarin Android 应用不幸停止工作

转载 作者:数据小太阳 更新时间:2023-10-29 03:00:57 25 4
gpt4 key购买 nike

我开始在 Xamarin 中开发一个 Android 应用程序,到目前为止我只在主要布局上做了一些工作(尚未完成),但每次我运行该应用程序以查看布局在模拟器上的外观时,它只是给我“不幸的是 appName(DOS-bot 在这种情况下)已停止工作”。

这是布局 XML:

 <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#2bced1">
<ImageView
android:id="@+id/botModel"
android:src="@drawable/botModel"
android:layout_height="match_parent"
android:layout_width="300dp"
android:layout_marginBottom="12dp"
android:layout_marginTop="12dp" />
<LinearLayout
android:orientation="vertical"
android:layout_toRightOf="@id/botModel"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:layout_marginTop="12dp"
android:layout_marginBottom="12dp"
android:layout_marginRight="8dp">
<ImageView
android:id="@+id/Title"
android:src="@drawable/Title"
android:layout_width="match_parent"
android:layout_height="80dp" />
<ImageButton
android:id="@+id/NewGame"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_marginTop="6dp" />
</LinearLayout>
</RelativeLayout>

以及后端代码:

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

namespace DOS_bot
{
[Activity(Label = "DOS_bot", MainLauncher = true, Icon = "@drawable/icon", Theme = "@android:style/Theme.NoTitleBar.Fullscreen", ScreenOrientation = ScreenOrientation.Landscape)]
public class MainActivity : Activity
{

protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);

SetContentView(Resource.Layout.Main);

}
}
}

在查看 Xamarin 论坛后,我尝试在属性中关闭共享运行时和快速部署以用于发布和调试,但仍然没有用。

这是调试日志,我希望它能对问题有所启发:

07-14 00:31:41.095 I/SurfaceComposerClient(  464): update getting screenshot size 452 x 803
07-14 00:31:41.095 I/SurfaceComposerClient( 464): Opening socket to screenshot pipe.
07-14 00:31:41.095 I/ActivityManager( 464): START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=DOS_bot.DOS_bot/md561025751d54c13647beead4a9be33f78.MainActivity} from pid 704
07-14 00:31:41.099 I/DonatelloScreenshot( 464): Capturing screenshot. (w=452 h=803, rot=0, crop l=0 r=1080 t=0 b=1920)
07-14 00:31:41.099 I/DonatelloService( 491): Checking type.
07-14 00:31:41.099 I/DonatelloService( 491): Read hal pipe type Gpu.
07-14 00:31:41.099 I/DonatelloService( 491): Donatello HAL screen shot
07-14 00:31:41.099 I/DonatelloService( 491): Forwarding request
07-14 00:31:41.099 I/DonatelloService( 491): Forwarding data, planning to write 28.
07-14 00:31:41.099 I/DonatelloService( 491): Reallocating bigger buffer
07-14 00:31:41.099 I/DonatelloService( 491): Request sent
07-14 00:31:41.203 I/DonatelloService( 491): Forwarding data, planning to write 1451824.
07-14 00:31:41.203 I/DonatelloService( 491): Reallocating bigger buffer
07-14 00:31:41.359 I/DonatelloService( 491): Done.
07-14 00:31:41.399 I/SurfaceComposerClient( 464): update screenshot succeeded!
07-14 00:31:41.407 D/dalvikvm( 464): GC_FOR_ALLOC freed 744K, 9% free 8611K/9424K, paused 11ms, total 11ms
07-14 00:31:41.407 I/dalvikvm-heap( 464): Grow heap (frag case) to 9.165MB for 723212-byte allocation
07-14 00:31:41.415 D/dalvikvm( 464): GC_FOR_ALLOC freed 14K, 9% free 9302K/10132K, paused 8ms, total 8ms
07-14 00:31:41.419 I/DonatelloService( 491): Channel has closed.
07-14 00:31:41.419 I/DonatelloService( 491): Closing channel.
07-14 00:31:41.435 D/dalvikvm( 1167): Late-enabling CheckJNI
07-14 00:31:41.435 I/ActivityManager( 464): Start proc DOS_bot.DOS_bot for activity DOS_bot.DOS_bot/md561025751d54c13647beead4a9be33f78.MainActivity: pid=1167 uid=10054 gids={50054, 3003}
07-14 00:31:41.455 D/PermissionCache( 139): checking android.permission.READ_FRAME_BUFFER for uid=1000 => granted (164 us)
07-14 00:31:41.455 E/gralloc_donatello( 139): gralloc_alloc: Mismatched usage flags: 1080 x 1920, usage b33
07-14 00:31:41.455 W/GraphicBufferAllocator( 139): alloc(1080, 1920, 1, 00000b33, ...) failed -22 (Invalid argument)
07-14 00:31:41.455 E/ ( 139): GraphicBufferAlloc::createGraphicBuffer(w=1080, h=1920) failed (Invalid argument), handle=0x0
07-14 00:31:41.455 E/BufferQueue( 139): [ScreenshotSurface] dequeueBuffer: SurfaceComposer::createGraphicBuffer failed
07-14 00:31:41.479 I/ActivityManager( 464): Config changes=480 {1.0 ?mcc?mnc en_US ldltr sw391dp w654dp h366dp 441dpi nrml land finger qwerty/v/v -nav/h s.6}
07-14 00:31:41.511 D/PhoneStatusBar( 580): mSettingsPanelGravity = 55
07-14 00:31:41.527 I/InputReader( 464): Reconfiguring input devices. changes=0x00000004
07-14 00:31:41.527 I/InputReader( 464): Device reconfigured: id=3, name='Donatello Virtual Touch Device', size 1080x1920, orientation 1, mode 1, display id 0
07-14 00:31:41.527 I/InputReader( 464): Device reconfigured: id=6, name='Microsoft Vmbus HID-compliant Mouse', size 1080x1920, orientation 1, mode 1, display id 0
07-14 00:31:41.527 I/InputReader( 464): Reconfiguring input devices. changes=0x00000004
07-14 00:31:41.551 D/AndroidRuntime( 1167): Shutting down VM
07-14 00:31:41.551 W/dalvikvm( 1167): threadid=1: thread exiting with uncaught exception (group=0xa8d2eb20)
07-14 00:31:41.551 E/AndroidRuntime( 1167): FATAL EXCEPTION: main
07-14 00:31:41.551 E/AndroidRuntime( 1167): Process: DOS_bot.DOS_bot, PID: 1167
07-14 00:31:41.551 E/AndroidRuntime( 1167): java.lang.UnsatisfiedLinkError: Couldn't load monodroid from loader dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/DOS_bot.DOS_bot-1.apk"],nativeLibraryDirectories=[/data/app-lib/DOS_bot.DOS_bot-1, /system/lib]]]: findLibrary returned null
07-14 00:31:41.551 E/AndroidRuntime( 1167): at java.lang.Runtime.loadLibrary(Runtime.java:358)
07-14 00:31:41.551 E/AndroidRuntime( 1167): at java.lang.System.loadLibrary(System.java:526)
07-14 00:31:41.551 E/AndroidRuntime( 1167): at mono.MonoPackageManager.LoadApplication(MonoPackageManager.java:34)
07-14 00:31:41.551 E/AndroidRuntime( 1167): at mono.MonoRuntimeProvider.attachInfo(MonoRuntimeProvider.java:22)
07-14 00:31:41.551 E/AndroidRuntime( 1167): at android.app.ActivityThread.installProvider(ActivityThread.java:4774)
07-14 00:31:41.551 E/AndroidRuntime( 1167): at android.app.ActivityThread.installContentProviders(ActivityThread.java:4369)
07-14 00:31:41.551 E/AndroidRuntime( 1167): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4309)
07-14 00:31:41.551 E/AndroidRuntime( 1167): at android.app.ActivityThread.access$1500(ActivityThread.java:135)
07-14 00:31:41.551 E/AndroidRuntime( 1167): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
07-14 00:31:41.551 E/AndroidRuntime( 1167): at android.os.Handler.dispatchMessage(Handler.java:102)
07-14 00:31:41.551 E/AndroidRuntime( 1167): at android.os.Looper.loop(Looper.java:136)
07-14 00:31:41.551 E/AndroidRuntime( 1167): at android.app.ActivityThread.main(ActivityThread.java:5001)
07-14 00:31:41.551 E/AndroidRuntime( 1167): at java.lang.reflect.Method.invokeNative(Native Method)
07-14 00:31:41.551 E/AndroidRuntime( 1167): at java.lang.reflect.Method.invoke(Method.java:515)
07-14 00:31:41.551 E/AndroidRuntime( 1167): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
07-14 00:31:41.551 E/AndroidRuntime( 1167): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
07-14 00:31:41.551 E/AndroidRuntime( 1167): at dalvik.system.NativeStart.main(Native Method)
07-14 00:31:41.555 W/ActivityManager( 464): Force finishing activity DOS_bot.DOS_bot/md561025751d54c13647beead4a9be33f78.MainActivity
07-14 00:31:41.603 D/dalvikvm( 580): GC_FOR_ALLOC freed 5328K, 25% free 9594K/12692K, paused 9ms, total 9ms
07-14 00:31:41.607 I/dalvikvm-heap( 580): Grow heap (frag case) to 12.356MB for 3072012-byte allocation
07-14 00:31:41.615 D/dalvikvm( 580): GC_CONCURRENT freed 76K, 21% free 12517K/15696K, paused 1ms+1ms, total 6ms
07-14 00:31:41.659 I/ActivityManager( 464): Config changes=480 {1.0 ?mcc?mnc en_US ldltr sw391dp w391dp h623dp 441dpi nrml port finger qwerty/v/v -nav/h s.7}
07-14 00:31:41.679 I/InputReader( 464): Reconfiguring input devices. changes=0x00000004
07-14 00:31:41.679 I/InputReader( 464): Device reconfigured: id=3, name='Donatello Virtual Touch Device', size 1080x1920, orientation 0, mode 1, display id 0
07-14 00:31:41.679 I/InputReader( 464): Device reconfigured: id=6, name='Microsoft Vmbus HID-compliant Mouse', size 1080x1920, orientation 0, mode 1, display id 0
07-14 00:31:41.695 E/BluetoothAdapter( 649): Bluetooth binder is null
07-14 00:31:41.743 I/WindowManager( 464): Screen frozen for +293ms due to Window{a9358f48 u0 Application Error: DOS_bot.DOS_bot}
07-14 00:31:41.747 D/dalvikvm( 580): GC_FOR_ALLOC freed 3007K, 25% free 9532K/12692K, paused 3ms, total 4ms
07-14 00:31:41.747 I/dalvikvm-heap( 580): Grow heap (frag case) to 12.295MB for 3072012-byte allocation
07-14 00:31:41.755 D/dalvikvm( 580): GC_CONCURRENT freed 49K, 21% free 12482K/15696K, paused 1ms+1ms, total 7ms
07-14 00:31:41.827 D/PhoneStatusBar( 580): mSettingsPanelGravity = 55
07-14 00:31:42.159 W/ActivityManager( 464): Activity pause timeout for ActivityRecord{a964ea20 u0 DOS_bot.DOS_bot/md561025751d54c13647beead4a9be33f78.MainActivity t3 f}
07-14 00:31:42.187 W/EGL_emulation( 704): eglSurfaceAttrib not implemented
07-14 00:31:43.776 D/dalvikvm( 464): GC_EXPLICIT freed 943K, 14% free 9356K/10840K, paused 0ms+1ms, total 21ms
07-14 00:31:43.840 I/Process ( 1167): Sending signal. PID: 1167 SIG: 9
07-14 00:31:43.840 W/InputMethodManagerService( 464): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@a933e328 attribute=null, token = android.os.BinderProxy@a932cd48
07-14 00:31:43.888 I/ActivityManager( 464): Process DOS_bot.DOS_bot (pid 1167) has died.

最佳答案

来自 Xamarin developer website :

发布应用无法在设备上启动

如果是这样,有两种可能的原因:

  1. .apk 不提供目标设备支持的 ABI。例如,.apk 仅包含 armeabi-v7a 二进制文件,目标设备仅支持 armeabi。
  2. Android 错误。如果是这种情况,请卸载该应用,双手合十,然后重新安装该应用。

要修复 (1),请编辑项目选项/属性并将对所需 ABI 的支持添加到支持的 ABI 列表中。要确定您需要添加哪个 ABI,请针对您的目标设备运行以下 adb 命令:

adb shell getprop ro.product.cpu.abi
adb shell getprop ro.product.cpu.abi2

输出将包含主要(和可选的次要)ABI。

$ adb shell getprop | grep ro.product.cpu
[ro.product.cpu.abi2]: [armeabi]
[ro.product.cpu.abi]: [armeabi-v7a]

关于c# - Xamarin Android 应用不幸停止工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38362094/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com