【问题标题】:Debug Ionic application with android:debuggable="false"使用 android:debuggable="false" 调试 Ionic 应用程序
【发布时间】:2017-09-24 10:25:52
【问题描述】:
A 已在真实设备上安装了我的 Ionic 应用程序。该应用程序已发布、签名并具有 android:debuggable="false"。
我在该特定设备上遇到了一些问题,我需要对其进行调试(而不是创建和安装新的 --debug build)。
有什么方法可以调试吗?以某种方式将其“附加”到要授权的密钥库或其他...?有什么想法吗?
【问题讨论】:
标签:
android
cordova
debugging
ionic-framework
signed
【解决方案1】:
我仍在努力寻找更好的方法,但到目前为止,我能够通过 Chrome(桌面)调试在真实设备上运行的 Ionic 应用程序(已签名 --release 构建)控制台,通过指定:
<application android:debuggable="true">
直接在AndroidManifest.xml 文件中。当我使用 Ionic CLI 构建项目时,该属性不会被覆盖。
我更喜欢从config.xml 文件中设置属性,这样我在删除/添加平台时就不必在AndroidManifest.xml 中手动添加它。
【解决方案2】:
你可以在你的 config.xml 中添加这个来解决它。
<platform name="android">
<edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application" xmlns:android="http://schemas.android.com/apk/res/android">
<application android:debuggable="true" />
</edit-config>
然后,您就可以在 Chrome 中调试了。
【解决方案3】:
我刚刚遇到了一个类似的问题(我想用 cordova build android --release 创建一个可调试的 Cordova 应用程序),我还想在 Cordova config.xml 中添加一些东西,而不是直接编辑 AndroidManifest.xml,即通常是个坏主意。
以下代码适用于 Cordova 8.1.2,Cordova Android 平台版本 7.1.4。只需将其放在您的 config.xml 文件中(在小部件标签内的某个位置),您就可以开始了:
<config-file mode="merge" parent="/manifest" platform="android" xmlns:android="http://schemas.android.com/apk/res/android">
<application android:debuggable="true" />
</config-file>
这也会导致 :app:lintVitalRelease linter 给你一个 [HardcodedDebugMode] 错误(并且有充分的理由),但无论如何 APK 都可以正常构建。