重新编译系统应用程序

时间:2013-08-18 22:19:36

标签: android decompiling recompile dex2jar

因为我正在创建一个自定义ROM我想从settings.apk中删除一些条目因为无法用XML隐藏首选项我必须从apk更改源代码并且必须从中删除首选项PreferenceScreen。所以我用dex2jar反编译classes.dex复制了源代码并添加以下行:

getPreferenceScreen().removePreference(findPreference("toggle_wifi"));

现在我的问题是我不知道如何重新编译应用程序。我无法用Eclipse编译它,因为它使用了一些系统命名空间(在Eclipse中它是一个错误所以我无法编译)我如何重新编译应用程序?我只有* .java文件。

编辑:我添加到smali文件的smali代码:

invoke-virtual {p0}, Lcom/android/settings/WirelessSettings;->getPreferenceScreen()Landroid/preference/PreferenceScreen;
move-result-object v12
const-string v13, "toggle_wifi"
invoke-virtual {p0, v13}, Lcom/android/settings/WirelessSettings;->findPreference(Ljava/lang/CharSequence;)Landroid/preference/Preference;
move-result-object v13
invoke-virtual {v12, v13}, Landroid/preference/PreferenceScreen;->removePreference(Landroid/preference/Preference;)Z

invoke-virtual {p0}, Lcom/android/settings/WirelessSettings;->getPreferenceScreen()Landroid/preference/PreferenceScreen;
move-result-object v12
const-string v13, "wifi_settings"
invoke-virtual {p0, v13}, Lcom/android/settings/WirelessSettings;->findPreference(Ljava/lang/CharSequence;)Landroid/preference/Preference;
move-result-object v13
invoke-virtual {v12, v13}, Landroid/preference/PreferenceScreen;->removePreference(Landroid/preference/Preference;)Z

invoke-virtual {p0}, Lcom/android/settings/WirelessSettings;->getPreferenceScreen()Landroid/preference/PreferenceScreen;
move-result-object v12
const-string v13, "toggle_bluetooth"
invoke-virtual {p0, v13}, Lcom/android/settings/WirelessSettings;->findPreference(Ljava/lang/CharSequence;)Landroid/preference/Preference;
move-result-object v13
invoke-virtual {v12, v13}, Landroid/preference/PreferenceScreen;->removePreference(Landroid/preference/Preference;)Z

invoke-virtual {p0}, Lcom/android/settings/WirelessSettings;->getPreferenceScreen()Landroid/preference/PreferenceScreen;
move-result-object v12
const-string v13, "bt_settings"
invoke-virtual {p0, v13}, Lcom/android/settings/WirelessSettings;->findPreference(Ljava/lang/CharSequence;)Landroid/preference/Preference;
move-result-object v13
invoke-virtual {v12, v13}, Landroid/preference/PreferenceScreen;->removePreference(Landroid/preference/Preference;)Z

1 个答案:

答案 0 :(得分:0)

您可以在以下链接中找到详细的教程:

Decompile and Recompile