快速調(diào)試Android應(yīng)用系統(tǒng)修改ro.debuggable屬性的兩種方式
前言
幾乎所有應(yīng)用市場中的 Android 應(yīng)用,都處于非可調(diào)試狀態(tài)。如果我們需要調(diào)試 Android 應(yīng)用,往往需要反編譯對應(yīng)的 apk , 然后修改 apk 的 AndroidManifest.xml 中的 application 標(biāo)簽,將android:debuggable 屬性設(shè)置為 true。然后進行回編譯
<application android:debuggable="true"> </application>
這樣做不僅麻煩,而且如果對應(yīng)的 app 做了簽名校驗,可能會使 app 無法正常運行。
在 Android 系統(tǒng)中一個應(yīng)用能否被調(diào)試是這樣判斷的: 當(dāng) android 啟動時,系統(tǒng)屬性 ro.debuggable 為1,系統(tǒng)中所有的程序都是可以調(diào)試的。如果系統(tǒng)中的 ro.debuggable 為 0, 則會判斷程序的 AndroidManifest.xml 中 application 標(biāo)簽中的 android:debuggable 屬性是否為 true。
所以,我們可以通過修改 default.prop 文件中的 ro.debuggable 屬性來調(diào)試設(shè)備中的所有應(yīng)用。
下面介紹二種修改 ro.debuggable 的方式
方式一(不推薦)
注入 init 進程,修改內(nèi)存中的屬性值,只要init進程不重啟,這些屬性值就會生效。但是如果設(shè)備重啟,則修改的屬性值就失效。
前提:需要有 su 命令(root)
具體方法:
- 在 Github 上搜索 mprop,下載對應(yīng)的 mprop 工具
adb push ./mprop /data/local/tmp
將 mprop 推送到手機adb shell
進入手機 shellsu
切換到 rootcd /data/local/tmp & chmod 777 ./mprop
./mprop ro.debuggable 1
方式二 (推薦)
前提:需要先安裝 Magisk
具體方法:
- 在 Github 上搜索 MagiskHidePropsConfig,下載對應(yīng)的 MagiskHidePropsConfig 模塊
- 在 Magisk 中安裝下載的 MagiskHidePropsConfig 模塊并開啟
adb shell
props
- 輸入 5 ,Add/edit custom props
MagiskHide Props Config v6.1.2 by Didgeridoohan @ XDA Developers ===================================== Select an option below. ===================================== 1 - Edit device fingerprint 2 - Force BASIC key attestation 3 - Device simulation (disabled) 4 - Edit MagiskHide props (active) 5 - Add/edit custom props 6 - Delete prop values 7 - Script settings 8 - Collect logs u - Perform module update check r - Reset all options/settings b - Reboot device e - Exit See the module readme or the support thread @ XDA for details. Enter your desired option: 5
- 輸入 n, New custom prop
MagiskHide Props Config v6.1.2 by Didgeridoohan @ XDA Developers ===================================== Custom props Select an option below: ===================================== Set or edit custom prop values for your device. Currently no custom props set. Please add one by selecting "New custom prop" below. n - New custom prop b - Go back to main menu e - Exit See the module readme or the support thread @ XDA for details. Enter your desired option: n
- 輸入 ro.debuggable
MagiskHide Props Config v6.1.2 by Didgeridoohan @ XDA Developers ===================================== New custom prop ===================================== Enter the prop to set. Example: ro.sf.lcd_density b - Go back e - Exit Enter your desired option: ro.debuggable
- 輸入 y
MagiskHide Props Config v6.1.2 by Didgeridoohan @ XDA Developers ===================================== ro.debuggable ===================================== ro.debuggable is one of the sensitive props that can be set by the MagiskHide props option. Are you sure you want to proceed? y - Yes n - No e - Exit Enter your desired option: y
- 輸入 1
MagiskHide Props Config v6.1.2 by Didgeridoohan @ XDA Developers ===================================== ro.debuggable ===================================== Enter the value you want to set ro.debuggable to, or select from the options below. The currently set value is: 0 Please enter the new value. b - Go back e - Exit Enter your desired option: 1
- 輸入 y
MagiskHide Props Config v6.1.2 by Didgeridoohan @ XDA Developers ===================================== ro.debuggable ===================================== This will set ro.debuggable to: 1 Pick an option below to change what boot stage the prop will be set in, or set/reset a delay: 1 - Default (current) 2 - post-fs-data 3 - late_start service 4 - Both boot stages d - Delay Do you want to continue? Enter y(es), n(o), e(xit) or an option from above: y Working. Please wait... Working. Please wait... Working. Please wait... Working. Please wait... Working. Please wait...
MagiskHide Props Config v6.1.2 by Didgeridoohan @ XDA Developers ===================================== Reboot - ro.debuggable ===================================== Reboot for changes to take effect. Do you want to reboot now (y/n)? Enter y(es), n(o) or e(xit): y Rebooting...
結(jié)語
通過上述兩種方式修改 ro.debuggable 的值后,在手機 shell 中輸入getprop ro.debuggble
應(yīng)該會得到 1。此時我們就能愉快地調(diào)試手機上的所有 app 了。
以上就是Android搞機之打開系統(tǒng)調(diào)試總開關(guān)ro.debuggable的詳細內(nèi)容,更多關(guān)于Android搞機之打開系統(tǒng)調(diào)試總開關(guān)ro.debuggable的資料請關(guān)注腳本之家其它相關(guān)文章!
相關(guān)文章
詳解Android控件之DatePicker、TimePicker探究
本篇文章主要介紹了Android控件之DatePicker、TimePicker探究,非常具有實用價值,需要的朋友可以參考下。2016-12-12解析activity之間數(shù)據(jù)傳遞方法的詳解
本篇文章是對activity之間數(shù)據(jù)傳遞的方法進行了詳細的分析介紹,需要的朋友參考下2013-05-05Android中使用DialogFragment編寫對話框的實例教程
這篇文章主要介紹了Android中使用DialogFragment編寫對話框的實例教程,DialogFragment也是一種Fragment,因而管理生命周期時比較給力,需要的朋友可以參考下2016-04-04使用PackageManager獲得應(yīng)用信息實例方法
PackageManager是Android中一個很有用的類,能夠獲取已安裝的應(yīng)用(包)的信息,如應(yīng)用名稱、圖標(biāo)、權(quán)限,安裝、刪除應(yīng)用(包)等2013-11-11