关于调试:Android:如何将我的应用标记为可调试?

Android: how to mark my app as debuggable?

我想用手机调试我的应用程序。我该如何签名我的应用程序才能做到这一点?我对清单不太了解。


通过将android:debuggable="true"放入清单文件中,应用程序将进入调试模式,这意味着android将管理与您的应用程序有关的所有日志文件。但是,如果应用程序要运行或处于发布模式,请确保再次输入false(或删除此标记)。

1
2
3
4
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    ...
    <application android:icon="@drawable/icon"
        android:debuggable="true"


对于新的Gradle构建系统,建议的方法是在构建类型中进行分配。

在您的应用模块的build.gradle中:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
android {

    //...

    buildTypes {
        debug {
            debuggable true
        }
        customDebuggableBuildType {
            debuggable true
        }
        release {
            debuggable false
        }
    }

   //...

}