This application does not have the ‘debuggable‘ attribute enabled in its manifest.

本文介绍了在AndroidStudio中遇到的无法调试应用的问题,由于manifest文件中没有设置debuggable属性导致。解决方案是将app模式改为Debug模式,并在BuildVariants中确认当前构建变体为可调试状态。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

项目场景:

Android studio进行dubug调试


问题描述

提示:想通过debug排查空指针问题,看看数据有没有为null`

Error running 'app': Cannot debug application from module xxx.app.main on device rockchip-rk3568-5e1kah7f4aee. `This application does not have the 'debuggable' attribute enabled in its manifest.` If you have manually set it in the manifest, then remove it and let the IDE automatically assign it. If you are using Gradle, make sure that your current variant is debuggable.

原因分析:

主要因为没有设置到debug调试模式


解决方案:

app模式设置成Debug模式

点击左下角的Build Variants
在这里插入图片描述

### 解决方案 为了确保 `debug-only` 项目包含一个根级别的可调试文件,可以采取以下措施: #### 修改 Gradle 文件中的依赖项配置 对于主应用程序的 `build.gradle` 文件,在 `dependencies` 块中应明确区分不同构建类型的依赖关系。这可以通过如下方式实现[^1]: ```groovy dependencies { debugImplementation project(path: ':commsdk', configuration: 'debug') releaseImplementation project(path: ':commsdk', configuration: 'release') } ``` 此设置允许仅在执行调试版本编译时加载特定于调试模式下的库。 #### 调整 AAPT Options 设置 通过调整 Android Asset Packaging Tool (aapt) 的选项来控制资源处理行为。可以在模块级 `build.gradle` 中加入 aapt options 来保留符号表和其他有助于调试的信息[^4]: ```groovy android { ... defaultConfig { ... aaptOptions { noCompress "txt", "xml" ignoreAssetsPattern "!.svn:!.git:!.ds_store:!*.scc:.*:<dir>_*:" } } } ``` 上述配置防止某些可能影响调试过程的数据被压缩或忽略掉。 #### 启用 Debug Information Remapping 如果涉及到 Rust 编写的组件,则需考虑启用调试信息重映射功能。虽然默认情况下该参数未开启,但在发布版中建议激活它以便更好地支持跨平台调试工具链的工作[^2]: ```toml [profile.release] opt-level = 3 debug = true strip = false codegen-units = 1 panic = 'abort' lto = true # Enable mapping of debug info paths which is useful for debugging. remap-debuginfo = true ``` #### 构建类型特定配置 利用 `compileOptions` 和其他与构建类型相关的属性来自定义编译器指令集以及 Java 字节码版本等细节[^3]: ```groovy android { ... compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } buildTypes { debug { minifyEnabled false shrinkResources false signingConfig signingConfigs.debug // Ensure that the generated APK includes full symbol tables and other information needed by profilers or analyzers. proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } } } ``` 以上更改将帮助确保即使是在单独用于开发测试目的的应用程序变体中也能获得足够的诊断数据访问权限和支持。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值