android Settings項目安裝

來源:互聯網
上載者:User

接著前面的settings項目的建立,繼續講一下setting怎麼安裝到真機上
--1.先按普通run android application的方式運行settings,
[2011-05-19 11:31:24 - Settings] Uploading Settings.apk onto device '0123456789ABCDEF'
[2011-05-19 11:31:26 - Settings] Installing Settings.apk...
[2011-05-19 11:31:29 - Settings] Re-installation failed due to different application signatures.
[2011-05-19 11:31:29 - Settings] You must perform a full uninstall of the application. WARNING: This will remove the application data!
[2011-05-19 11:31:29 - Settings] Please execute 'adb uninstall com.android.settings' in a shell.
[2011-05-19 11:31:29 - Settings] Launch canceled!
--2.安裝出錯,需要先卸載setting,使用adb uninstall com.android.settings,發現也失敗,我這裡提供一種可用的卸載方法:
adb shell "cd /system/app;rm Settings.apk;"
adb uninstall com.android.settings
--3.卸載ok了再次安裝
[2011-05-19 12:02:36 - Settings] Installation error: INSTALL_FAILED_SHARED_USER_INCOMPATIBLE
[2011-05-19 12:02:36 - Settings] Please check logcat output for more details.
[2011-05-19 12:02:36 - Settings] Launch canceled!
開啟logcat:
01-02 09:49:09.882: ERROR/PackageManager(2002): Package com.android.settings has no signatures that match those in shared user android.uid.system; ignoring!
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="com.android.settings"
        android:sharedUserId="android.uid.system"
        android:versionCode="1"
在AndroidManifest中有一個屬性android:sharedUserId,上網google一下什麼意思,它使用來指定apk的許可權的,因為setings需要訪問系統級的一些資源,所以需要添加android.uid.system的許可權,但是系統許可權不是任意apk可以隨意擷取的,需要系統簽名,platform.x509.pem和platform.pk8可以讓你獲得系統許可權
--4.擷取platform.x509.pem和platform.pk8檔案,為你的apk進行簽名,下面是我寫的為settings進行簽名的批處理語句
java -jar signapk.jar platform.x509.pem platform.pk8 ../Settings/bin/Settings.apk output/Settings.apk
--5.簽名後重新安裝,你會發現你的setting不在安裝在/system/app下,而是在/data/app,跟普通的應用一樣,只不過它擁有系統許可權,使用的使用與原來的setting沒有任何區別

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.