安卓中Settings.apk的修改

本文介绍了一种使用ApkManager工具修改Android系统Settings.apk的方法,包括反编译、编辑settings.xml文件、重新编译和安装等步骤。

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

原文地址

先转过来,慢慢看。。。

标题:Does anyone know how to edit Settings.apk? [Solved!]

提问:

I've been trying to do this for some time, but I've hit a wall. I want to take the Settings.apk from my current rom (which ever one it happens to be). Decompile it. Edit some entries. Then recompile and sign it, so that I can use it with said rom. 

I've tried using apktool (and a few automated versions of it). It works great to decompile and recompile. I then use signapk.jar to sign the apk using a test key. But when I copy Settings.apk over to my /system/app folder, change the permissions, and reboot, the settings menu fails to load and my wallpaper disappears.

I thought that it might be edits I am making. So I tried decompiling, recompiling, and signing with no edits and I still get the same problem where the settings menu fails to load. 

I even tried following this crazy guide: [HOW-TO] Modify the Keyboard and Screen Timeouts Settings
But I had the same problem. 

I have successfully used apktool and my signing tool to edit and use other apk files. So I know that they work. Can anyone (probably a dev) explain what I'm doing wrong?

Thanks!

Update: Solution

------------------------

Originally Posted by  mmarz  View Post
Here is how you can do it yourself:
(自己翻译一下下面的步骤,水平有效,可能有出入)
  1. Download: Apk Manager 4.9 - Makes Modifying Ur Apk A Breeze (Windows/Linux) - xda-developers(下载Apk Manager工具,最新下载地址http://apkmultitool.com/?q=node/5。注意5.0是linux版本,5.0.2是Windows的版本哦)
  2. Get your Settings.apk off of your phone either with root explorer or adb:(将Settings.apk文件从手机提取出来)
    Code:
    adb pull /system/app/Settings.apk
  3. Keep a copy of Settings.apk somewhere safe.(保存一份备份,以便修改失败后再来一次)
  4. Place one copy into the "place-apk-here-for-modding" folder in apk manager.(复制一份到"place-apk-here-for-modding" 目录
  5. Run Script.bat.(运行Script.bat脚本)
  6. Enter option 22.(进入选项22-Set Current Project,将APK文件加载到当前工程)
  7. Select the Settings.apk(选择 Settings.apk)
  8. Enter option 9.(进入选项9-Decompile apk,对apk反编译)
  9. Open folder projects\Settings.apk\res\xml\(打开文件夹 projects\Settings.apk\res\xml\
  10. Open settings.xml in notepad or any other simple text editor.(用记事本或其他文本编辑工具打开 settings.xml 文件
  11. Remove these lines:(删除以下内容)
    Code:
       <com.android.settings.IconPreferenceScreen android:title="@string/privacy_settings" android:key="privacy_settings" settings:icon="@drawable/ic_settings_privacy">
            <intent android:targetPackage="com.android.settings" android:action="android.intent.action.MAIN" android:targetClass="com.android.settings.PrivacySettings" />
      </com.android.settings.IconPreferenceScreen>
  12. Save the file.(保存文件)
  13. Enter option 11 in app manager. (进入选项11-Compile apk,编译apk)
  14. Enter "y" (yes) for if this is a system apk. (输入‘y’若修改的文件是系统文件的话,此处我们输入y)
  15. Enter "y" for the next option too.(接下来还是输入‘y’)
  16. Open the newly created "keep" folder inside of your app manager folder. (在app manager目录中打开最新生成的‘keep’文件夹)
  17. Delete resources.arsc (删除 resources.arsc 文件
  18. Then delete keep\res\xml\settings.xml (接着删除 keep\res\xml\settings.xml 文件
  19. Go back to app manager and hit enter to continue. (返回 app manager 目录,输入‘回车’继续)
  20. Look inside "place-apk-here-for-modding" and find your newly created "unsignedSettings.apk" (在"place-apk-here-for-modding" 目录找到最新生成的unsignedSettings.apk"文件
  21. I used this file and it worked great. Signing it broke it for some reason. ( 我试用过这个文件,它允许的很好,对其签名时由于一些问题损坏了)
  22. Copy "unsignedSettings.apk" to the folder that contains adb.exe and rename it to "Settings.apk" (复制unsignedSettings.apk"文件到包含 adb.exe的目录然后重命名为 Settings.apk"
  23. Open command prompt and enter: (打开命令行输入以下命令:)
    Code:
    adb remount
    adb push Settings.apk /system/app/Settings.apk
    adb shell chmod 644 /system/app/Settings.apk
    adb reboot

If everything went right, your settings should load like normal but privacy should be gone now. If something went wrong, your wallpaper will be gone and settings will not load. Retrace your steps in that event. Maybe try signing the  apk. Who knows why only the unsigned version works for me?
(如果一切正常的话,你的 Settings 会开起来正常但是“隐私”项会不见了。若是操作有误的话,你的壁纸会消失,而且Settings不能加载。你要重新再进行下上面的步骤。你也可以尝试对apk签名。谁知道为什么只有未签名的版本在我这上面有效?)
-----------------------------

Thank you so much for posting this walk-through. I was trying to change the icons in the settings menu to the ICS icons and for some reason it wasn't working. After reading the walk-through (and testing) I realized it was because I was entering "n" on the second question after compiling. Now my settings menu looks awesome! 


<think>好的,我现在需要帮助用户解决如何使用jadx工具反编译Settings.apk和MiuiBluetooth.apk的问题。首先,我应该回忆一下用户提供的引用内容,看看有没有相关的信息可以借鉴。 根据引用[1],用户提到在Android 5.0之后,系统应用的目录结构发生了变化,不再是直接在/system/app/下放APK文件,而是每个应用有一个目录,里面存放APK。同时,引用[2]指出反编译Settings.apk需要使用apktool_2.0.3,但用户现在想用jadx,所以可能需要确认jadx是否支持这些APK的结构。 引用[3]提到jadx支持的文件类型包括apk、dex等,所以应该没问题。不过,用户之前可能遇到问题是因为APK的位置或结构发生了变化,需要正确提取这些APK文件。 接下来,我需要整理使用jadx反编译的步骤。首先,用户需要获取目标APK文件。根据引用[1],可能需要从ROM固件中提取system分区的文件,或者通过ADB从设备中提取。例如,使用adb pull命令从/system/app/对应的目录下获取Settings.apk和MiuiBluetooth.apk。 然后,安装jadx工具。用户需要下载并安装jadx的GUI或命令行版本。启动GUI后,直接拖放APK文件即可。如果是命令行,使用命令如jadx -d output_dir input.apk。 需要注意的是,小米的系统APK可能被混淆或优化过,反编译后的代码可读性可能较差。此外,对于系统级APK,可能需要先获取root权限才能访问/system目录下的文件。如果APK是odex格式的,可能需要先转换为dex,但引用[1]提到可以使用工具将odex转为dex,而jadx是否直接支持odex呢?可能用户需要先处理odex文件,或者确保APK已经包含dex文件。 另外,引用[2]提到在Android 5.1上使用特定版本的apktool,但这里用户用的是jadx,可能不需要考虑版本问题,但最好建议用户使用最新的jadx版本以确保兼容性。 最后,用户可能需要处理反编译后的代码,比如查找特定类或资源,这时候可以指导他们如何使用jadx的搜索功能或导出Gradle项目到Android Studio中查看。 总结步骤应该是:获取APK文件→安装jadx→使用jadx打开或执行命令→处理可能的混淆或依赖问题。同时,提醒用户注意系统APK的位置变化和权限需求。</think>### 如何用 jadx 反编译 Settings.apk 和 MiuiBluetooth.apk #### 步骤 1:获取 APK 文件 1. **从设备中提取**(需 root 权限): - 使用 `adb shell` 进入设备,找到 APK 路径: - 小米系统应用路径一般为 `/system/app/应用名目录/应用名.apk`(如 `/system/app/Settings/Settings.apk` 和 `/system/app/MiuiBluetooth/MiuiBluetooth.apk`)[^2]。 - 通过 `adb pull /system/app/Settings/Settings.apk` 和 `adb pull /system/app/MiuiBluetooth/MiuiBluetooth.apk` 提取到本地。 2. **从 ROM 固件提取**: - 解压小米 ROM 的 `system.img` 文件,在 `system/app/` 下找到对应目录并提取 APK[^1]。 #### 步骤 2:安装 jadx 工具 1. 从 [jadx 官网](https://github.com/skylot/jadx) 下载最新版本(支持 Windows/Linux/macOS)。 2. 解压后运行: - **GUI 版本**:双击 `jadx-gui`(或 `jadx-gui.bat`),通过界面打开 APK。 - **命令行版本**:执行 `jadx -d 输出目录 Settings.apk`。 #### 步骤 3:反编译 APK 1. **GUI 操作**: - 打开 jadx-gui,将 APK 文件拖入窗口,自动解析代码和资源。 - 左侧导航栏可查看类、方法、资源文件(如图片、布局 XML)。 2. **命令行操作**: ```bash jadx -d ./output_settings ./Settings.apk jadx -d ./output_miui_bt ./MiuiBluetooth.apk ``` #### 注意事项 1. **代码混淆**:小米系统 APK 可能经过混淆,类名或方法名显示为 `a`、`b` 等,需结合上下文分析。 2. **依赖缺失**:系统 APK 可能依赖 `framework-res.apk`,若反编译时报错,可尝试通过 `--android-lib` 指定框架路径: ```bash jadx --android-lib /path/to/framework-res.apk -d ./output Settings.apk ``` 3. **资源解码**:jadx 会自动解析 XML 资源,若遇到二进制 XML,可尝试使用 `apktool` 辅助解码。 --- ###
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值