AndroidStudio:“可疑"功能是什么? [英] AndroidStudio: What does 'debuggable' do?

查看:110
本文介绍了AndroidStudio:“可疑"功能是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想确切地知道debuggable true语句的作用:

I would like to know exactly what the debuggable true statement does:

// build.gradle
android
  {         
    buildTypes
      {
        debug
          { debuggable true
          }       
      }
  }

能够在不使用模拟器的情况下对其进行调试(genymotion):断点有效; Log.d(...)语句输出到Android Monitor;

I am able to debug without it using the emulator (genymotion): the breakpoints work; the Log.d(...) statements output to the Android Monitor;

由于debuggable标志位于debug部分的内部,因此无论如何似乎都是多余的.它是否不应该在buildTypes部分之外,以提示是否应使用debug构建类型?

Since the debuggable flag is inside the debug section, it seems redundant anyway. Shouldn't it be outside the buildTypes section, indicating to the ide that the debug buildtype should be used?

debugrelease生成类型之间的区别进行一些简单的外行一般背景了解也将是一件好事.

It would also be nice to get some simple layperson general background understanding of the difference between the debug and release buildtypes.

推荐答案

在Android上,调试器使用

On Android, debuggers communicate with the virtual machine using JDWP. When debugging is enabled, the VM creates a dedicated thread that listens for JDWP traffic and responds to requests. (It's also possible to use a native debugger, such as gdb, but that's a different kettle of fish.)

在出售给消费者的设备上,通常不需要运行额外的线程,因此默认情况下应用程序不可调试.此外,恶意软件可能会使用调试器界面来检查或操纵正在运行的应用程序,因此禁用它是最安全的.另一方面,仿真器上运行的任何东西都应该是可调试的,因此默认行为是不同的. ro.debuggable系统属性确定此(adb shell getprop ro.debuggable).

On devices sold to consumers, there's generally no need to have the extra thread running, so by default apps are not debuggable. Also, malware could potentially use the debugger interface to examine or manipulate running apps, so it's safest to disable it. On the other hand, anything running on an emulator should be debuggable, so the default behavior there is different. The ro.debuggable system property determines this (adb shell getprop ro.debuggable).

应用程序清单中的debuggable标志告诉VM该应用程序正在开发中,并且无论该应用程序是否在生产设备上运行,都应允许来自调试器的连接.

The debuggable flag in the app manifest tells the VM that the app is under development, and connections from debuggers should be allowed whether or not the app is running on a production device.

以上所有内容均与应用程序的运行时行为有关,与构建无关.调试版本也与发行版本不同.将-g标志传递给javac会导致输出其他信息,并且有dx选项可以剥离或将其他调试信息保留在.dex文件中. (我不知道gradle标志如何与它们交互.)

All of the above relates to the app's runtime behavior, not the build. Debug builds are also different from release builds. Passing the -g flag to javac causes additional information to be output, and there are dx options that will strip or keep additional debug information in the .dex file. (I don't know how the gradle flag interacts with these.)

这篇关于AndroidStudio:“可疑"功能是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆