【问题标题】:App closes immediately after launch, no error, no step-through in VS debugger应用程序在启动后立即关闭,没有错误,在 VS 调试器中没有单步执行
【发布时间】:2018-06-01 17:11:20
【问题描述】:

我们收到了一批新手机,可用于集体测试。目前,要在设备上部署/安装应用程序,我只需通过 USB 电缆将其连接到开发计算机并从 VisualStudio 运行应用程序。

嗯,这些 ZTE Z798BL (Android 6.0.1) 完全出乎意料:

  1. 我在手机上配置了开发人员选项(启用 USB 调试和保持唤醒)。
  2. 我接上USB线,手机在另一端检测到VStudio,要求确认。现在该设备出现在 VStudio 的设备下拉列表中 - 我选择了它。
  3. 我“运行”应用程序。 VStudio 编译、打包、压缩对齐等等,然后部署 .apk。
  4. VStudio 切换到调试模式。
  5. 手机加载第一个活动,但没有内容 - 只是带有标签的标题。
  6. 几秒钟后活动消失,VStudio 切换回编辑模式.. 我们完成了

没有例外,没有错误,电话上没有“不幸......”消息。再试一次没有影响。在第一行代码上设置断点没有影响。尝试单步执行(使用 [F11] 而不是 [F5])没有任何影响 - 应用程序在到达我的代码之前就终止了

在启动尝试期间的设备日志中充满了来自各地的大量 shtuff

尝试使用 PID 进行过滤会导致 10 行完全没有任何线索:

一时兴起,我拿了一部尚未通过 USB 连接到开发计算机的全新 Google Pixel 手机。将其插入,启用 USB 调试,在 VisualStudio 中选择它(仍在同一个会话中 - 无需重新启动,无需重新启动!),单击“运行”,然后在输出窗口中可见通常的构建操作之后......瞧:这里是该应用首次在 Pixel 上完美运行


接下来我尝试了一个 ActivityLifecycle 示例。它做了同样的事情:没有按钮的“活动 A”标题在手机上闪烁并立即消失,没有任何错误或异常。我改为:

[Activity(Label = "Activity AZ", MainLauncher = true)]

导致标题更改为“Activity AZ”,但我仍然无法通过 ZTE 上的任何代码


不针对任何具体细节,该应用可在以下设备/Android 版本上运行:

  • Google Nexus 4(4.3,API:18)
  • BLU Vivo 5 Mini(6.0,API:23)
  • 三星 SM-T377V(7.1.1,API:25),从(6.0.1,API:23)更新
  • 谷歌像素(8.1.0,API:27)

因此,我的猜测是 - 这与中兴设备本身有关
我们有一堆,所以我拿下一个.. 每个人的行为方式都一样!什么鬼??

App 的 TargetPlatform 为 7.1,MinimumVersion 为 4.3,支持的 5 种架构全部启用。
VStudio - 15.5.4,.NET - 4.7.03056,Xamarin - 4.8.0.757,Xamarin.Android SDK - 8.1.3.0。


今天(2018-06-01)我更加关注设备日志输出,发现以下几行(当然其中很多不是来自我的流程!):

Time    Device Name Type    PID Tag Message
06-01 09:27:13.786  ZTE Z798BL  Info    1456    ActivityManager START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=J7980ca.J7980ca/md54e704423a01db64492900da8de435cc0.ActMain} from uid 2000 (pid: 22859, caller: null) on display 0
06-01 09:27:13.786  ZTE Z798BL  Debug   22859   AndroidRuntime  Calling main entry com.android.commands.am.Am
06-01 09:27:13.806  ZTE Z798BL  Verbose 1456    BoostFramework  BoostFramework() : mPerf = com.qualcomm.qti.Performance@80107cc
06-01 09:27:13.806  ZTE Z798BL  Warning 1456    WindowManager   jiangmin Set focused app to: AppWindowToken{5ed5159 token=Token{2da09d2 ActivityRecord{8434c5d u0 J7980ca.J7980ca/md54e704423a01db64492900da8de435cc0.ActMain t20}}} old focus=AppWindowToken{79d17c2 token=Token{9731c0d ActivityRecord{d06a6a4 u0 com.android.launcher3/.Launcher t6}}} moveFocusNow=true
06-01 09:27:13.806  ZTE Z798BL  Verbose 1456    BoostFramework  BoostFramework() : mPerf = com.qualcomm.qti.Performance@173fdff
06-01 09:27:13.806  ZTE Z798BL  Debug   8462    Launcher_Launcher   Launcher onPause
06-01 09:27:13.806  ZTE Z798BL  Debug   22859   AndroidRuntime  Shutting down VM
06-01 09:27:13.816  ZTE Z798BL  Verbose 1456    BoostFramework  BoostFramework() : mPerf = com.qualcomm.qti.Performance@c98aa15
06-01 09:27:13.826  ZTE Z798BL  Verbose 1456    BoostFramework  BoostFramework() : mPerf = com.qualcomm.qti.Performance@81cd4b8
06-01 09:27:13.826  ZTE Z798BL  Info    1456    ActivityManager Start proc 22873:J7980ca.J7980ca/u0a91 for activity J7980ca.J7980ca/md54e704423a01db64492900da8de435cc0.ActMain
06-01 09:27:13.836  ZTE Z798BL  Info    22873   art Late-enabling -Xcheck:jni
06-01 09:27:13.836  ZTE Z798BL  Info    22464   Finsky  [1] com.google.android.finsky.setup.ar.run(35): Detected restoreservicev2://recovery not needed, will not run
06-01 09:27:13.906  ZTE Z798BL  Debug   1456    Settings    return value in isSelf
06-01 09:27:13.906  ZTE Z798BL  Debug   1456    Settings    return value in isSelf
06-01 09:27:13.926  ZTE Z798BL  Warning 22873   monodroid   Using override path: /storage/emulated/0/Android/data/J7980ca.J7980ca/files/.__override__
06-01 09:27:13.926  ZTE Z798BL  Warning 22873   monodroid   Creating public update directory: `/data/user/0/J7980ca.J7980ca/files/.__override__`
06-01 09:27:13.926  ZTE Z798BL  Warning 22873   monodroid   Trying to load sgen from: /storage/emulated/0/../legacy/Android/data/J7980ca.J7980ca/files/.__override__/libmonosgen-2.0.so
06-01 09:27:13.926  ZTE Z798BL  Warning 22873   monodroid   Trying to load sgen from: /data/app/J7980ca.J7980ca-1/lib/arm/libmonosgen-2.0.so
06-01 09:27:13.926  ZTE Z798BL  Warning 22873   monodroid   Using override path: /data/user/0/J7980ca.J7980ca/files/.__override__
06-01 09:27:13.926  ZTE Z798BL  Warning 22873   monodroid   Trying to load sgen from: /data/user/0/J7980ca.J7980ca/files/.__override__/libmonosgen-2.0.so
06-01 09:27:13.926  ZTE Z798BL  Warning 22873   monodroid   Trying to load sgen from: /storage/emulated/0/Android/data/J7980ca.J7980ca/files/.__override__/libmonosgen-2.0.so
06-01 09:27:13.936  ZTE Z798BL  Warning 22873   monodroid   Trying to load sgen from: /data/user/0/J7980ca.J7980ca/files/.__override__/links/libmonosgen-2.0.so
06-01 09:27:13.986  ZTE Z798BL  Warning 22873   monodroid-debug Trying to initialize the debugger with options: --debugger-agent=transport=dt_socket,loglevel=0,address=127.0.0.1:29382,server=y,embedding=1
..
06-01 09:27:21.836  ZTE Z798BL  Info    1456    ActivityManager Killing 22873:J7980ca.J7980ca/u0a91 (adj 0): stop J7980ca.J7980ca
..
06-01 09:27:21.876  ZTE Z798BL  Warning 1456    WindowManager   jiangmin Set focused app to: AppWindowToken{79d17c2 token=Token{9731c0d ActivityRecord{d06a6a4 u0 com.android.launcher3/.Launcher t6}}} old focus=AppWindowToken{5ed5159 token=Token{2da09d2 ActivityRecord{8434c5d u0 J7980ca.J7980ca/md54e704423a01db64492900da8de435cc0.ActMain t20}}} moveFocusNow=true
06-01 09:27:21.876  ZTE Z798BL  Warning 1456    ActivityManager Spurious death for ProcessRecord{64106cf 0:J7980ca.J7980ca/u0a91}, curProc for 22873: null
06-01 09:27:21.866  ZTE Z798BL  Info    1456    ActivityManager Start proc 22915:J7980ca.J7980ca/u0a91 for activity J7980ca.J7980ca/md54e704423a01db64492900da8de435cc0.ActMain
  Force finishing activity ActivityRecord{8434c5d u0 J7980ca.J7980ca/md54e704423a01db64492900da8de435cc0.ActMain t20}
06-01 09:27:21.866  ZTE Z798BL  Verbose 1456    BoostFramework  BoostFramework() : mPerf = com.qualcomm.qti.Performance@2f65b2e
06-01 09:27:21.856  ZTE Z798BL  Debug   1456    ActivityManager cleanUpApplicationRecord -- 22873
06-01 09:27:21.836  ZTE Z798BL  Debug   22904   AndroidRuntime  Calling main entry com.android.commands.am.Am
06-01 09:27:21.836  ZTE Z798BL  Info    1456    ActivityManager Force stopping J7980ca.J7980ca appid=10091 user=0: from pid 22904
..
06-01 09:27:21.976  ZTE Z798BL  Warning 1456    WindowManager   This window was lost: Window{cf842c9 u0 Starting J7980ca.J7980ca}
06-01 09:27:21.976  ZTE Z798BL  Warning 1456    WindowManager   Frames: containing=[0,0][480,854] parent=[0,0][480,854]
    display=[0,0][480,854] overscan=[0,0][480,854]
    content=[0,36][480,854] visible=[0,36][480,854]
    decor=[0,36][480,854]
    outset=[0,0][0,0]
06-01 09:27:21.976  ZTE Z798BL  Warning 1456    WindowManager   mToken=AppWindowToken{5ed5159 token=Token{2da09d2 ActivityRecord{8434c5d u0 J7980ca.J7980ca/md54e704423a01db64492900da8de435cc0.ActMain t20}}}
06-01 09:27:21.976  ZTE Z798BL  Warning 1456    WindowManager   mSystemDecorRect=[0,36][480,854] last=[0,0][0,0]
06-01 09:27:21.976  ZTE Z798BL  Warning 1456    WindowManager   mSeq=0 mSystemUiVisibility=0x0
06-01 09:27:21.976  ZTE Z798BL  Warning 1456    WindowManager   On display=0 Rebuild removed 3 windows but added 2
06-01 09:27:21.976  ZTE Z798BL  Warning 1456    WindowManager   mOwnerUid=1000 mShowToOwnerOnly=false package=J7980ca.J7980ca appop=NONE
06-01 09:27:21.976  ZTE Z798BL  Warning 1456    WindowManager   mExiting=false mRemoveOnExit=false mDestroying=false mRemoved=true
06-01 09:27:21.976  ZTE Z798BL  Warning 1456    WindowManager   mRootToken=AppWindowToken{5ed5159 token=Token{2da09d2 ActivityRecord{8434c5d u0 J7980ca.J7980ca/md54e704423a01db64492900da8de435cc0.ActMain t20}}}
06-01 09:27:21.976  ZTE Z798BL  Warning 1456    WindowManager   mConfiguration={1.0 310mcc260mnc en_US ldltr sw320dp w320dp h545dp 240dpi nrml long port finger -keyb/v/h -nav/h s.9}
06-01 09:27:21.956  ZTE Z798BL  Debug   1456    ActivityManager cleanUpApplicationRecord -- 22436
06-01 09:27:23.316  ZTE Z798BL  Debug   3648    Settings    return value in isSelf
 iswfc:false
06-01 09:27:23.316  ZTE Z798BL  Debug   3181    systemUI_BmpofEbubWjfx  mIsMmsApnDataState: false isWFCState:false
06-01 09:27:23.316  ZTE Z798BL  Error   3181    systemUI_QipofTubuvt    Failed to GetSimBySub local
06-01 09:27:23.316  ZTE Z798BL  Debug   3648    Settings    return value in isSelf
06-01 09:27:23.316  ZTE Z798BL  Debug   3648    Settings    return value in isSelf
06-01 09:27:22.466  ZTE Z798BL  Warning 8462    OpenGLRenderer  Incorrectly called buildLayer on View: ShortcutAndWidgetContainer, destroying layer...
06-01 09:27:22.466  ZTE Z798BL  Warning 8462    OpenGLRenderer  Incorrectly called buildLayer on View: ShortcutAndWidgetContainer, destroying layer...
06-01 09:27:22.086  ZTE Z798BL  Debug   3648    Settings    return value in isSelf
06-01 09:27:22.016  ZTE Z798BL  Warning 22915   monodroid-debug Trying to initialize the debugger with options: --debugger-agent=transport=dt_socket,loglevel=0,address=127.0.0.1:29382,server=y,embedding=1
06-01 09:27:22.006  ZTE Z798BL  Warning 22915   monodroid   Creating public update directory: `/data/user/0/J7980ca.J7980ca/files/.__override__`
06-01 09:27:22.006  ZTE Z798BL  Warning 22915   monodroid   Trying to load sgen from: /storage/emulated/0/../legacy/Android/data/J7980ca.J7980ca/files/.__override__/libmonosgen-2.0.so
06-01 09:27:22.006  ZTE Z798BL  Warning 22915   monodroid   Trying to load sgen from: /data/app/J7980ca.J7980ca-1/lib/arm/libmonosgen-2.0.so
06-01 09:27:22.006  ZTE Z798BL  Warning 22915   monodroid   Trying to load sgen from: /data/user/0/J7980ca.J7980ca/files/.__override__/libmonosgen-2.0.so
06-01 09:27:22.006  ZTE Z798BL  Warning 22915   monodroid   Trying to load sgen from: /data/user/0/J7980ca.J7980ca/files/.__override__/links/libmonosgen-2.0.so
06-01 09:27:22.006  ZTE Z798BL  Warning 22915   monodroid   Using override path: /storage/emulated/0/Android/data/J7980ca.J7980ca/files/.__override__
06-01 09:27:22.006  ZTE Z798BL  Warning 22915   monodroid   Trying to load sgen from: /storage/emulated/0/Android/data/J7980ca.J7980ca/files/.__override__/libmonosgen-2.0.so
06-01 09:27:22.006  ZTE Z798BL  Warning 22915   monodroid   Using override path: /data/user/0/J7980ca.J7980ca/files/.__override__
06-01 09:27:21.986  ZTE Z798BL  Debug   1456    Settings    return value in isSelf
06-01 09:27:21.986  ZTE Z798BL  Debug   1456    Settings    return value in isSelf
06-01 09:27:21.976  ZTE Z798BL  Warning 1456    WindowManager   WindowStateAnimator{102a206 Starting J7980ca.J7980ca}:
06-01 09:27:21.976  ZTE Z798BL  Warning 1456    WindowManager   mViewVisibility=0x0 mHaveFrame=true mObscured=false
06-01 09:27:21.976  ZTE Z798BL  Warning 1456    WindowManager   mAppToken=AppWindowToken{5ed5159 token=Token{2da09d2 ActivityRecord{8434c5d u0 J7980ca.J7980ca/md54e704423a01db64492900da8de435cc0.ActMain t20}}}
06-01 09:27:21.976  ZTE Z798BL  Warning 1456    WindowManager   mHasSurface=false mShownFrame=[0.0,0.0][480.0,854.0] isReadyForDisplay()=false
..

我只发现这些搜索“J7980ca” - 项目名称。我很乐意包含完整的捕获,但它们占用了太多空间。有没有类似图片上传文本文件的方法?

奇怪的是,在假死之后(即使没有引用原始 PID?!)它看起来好像又重新加载了应用程序?我在 VStudio 停止调试后暂停记录约 15 秒,没有更多条目明确提及我的项目或其类。

【问题讨论】:

    标签: android xamarin.android visual-studio-2017


    【解决方案1】:

    我会使用模拟器进行虚拟测试,并使用这种技术创建手机图像:Run a full android phone rom on the Android Emulator

    这样您就可以“淘汰”中兴硬件,并可能使用仿真器映像进行更好的调试。

    注意:升级到 Visual Studio 15.7.3 并更新 Xamarin 后,我的应用程序不再在模拟器中启动。我必须手动删除“Mono 共享运行时”和“Xamarin.Android API-xx 支持”并最后安装我的应用程序。对应用程序进行了全面重建并进行了新部署,之后它运行良好。

    还建议尝试在没有共享运行时的情况下进行部署,删除属性 -> Android 选项 -> 使用共享运行时中的检查

    如果你仍然卡住;去海滩看看中兴通讯是否漂浮;)

    【讨论】:

    • 在最初尝试在模拟器中运行第一个“Hello, world”应用程序,然后看到部署甚至在物理设备上调试的效率之后,我发誓永远不再调用模拟器.在我看来,that^ 并不能证明问题(或不是)特别是中兴硬件。是否尝试过清理、删除 /bin 和 /obj 文件夹以及重建 - 没有骰子。可能需要更新 VS/Xamarin/SDK,但我讨厌触摸适用于其他一切的设置。
    • 我的意思是,Android 并非在所有设备上都有库存。也许中兴通讯开发人员以任何方式修改了 Android 安装。通过在模拟器中进行一对一的复制,它将消除 ZTE 上的软件错误以及您返回到硬件的错误。
    【解决方案2】:

    好吧,我偶然发现,一旦中兴通讯从 USB 电缆上拔下,应用程序就会正确加载。重新插入手机并尝试从 VStudio 运行应用程序仍然会导致“进程的虚假死亡..”没有任何有用的线索。 但再次拔掉电源似乎可以恢复应用的运行能力

    我唯一的解释是调试器的存在在某种程度上是不利的?!

    但我会接受,因为它允许我将下一个 dev-build 部署到手机并在不插电的情况下运行。

    【讨论】:

      猜你喜欢
      • 2019-06-03
      • 2019-10-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多