介紹:
配置系統共享android.uid.system應用分爲兩步:
- 1.AndroidManifest.xml文件中配置:android:sharedUserId="android.uid.system"
-
<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" package="xxx" android:sharedUserId="android.uid.system" android:versionCode="58" android:versionName="1.1.8">
- 2.使用系統平臺簽名在Android.mk文件中添加:LOCAL_CERTIFICATE := platform
問題:
以上兩步我都做過但發現應用只是系統應用但沒有共享android.uid.system,導致很多權限沒有。
可以通過反編譯apk拿到AndroidManifest.xml,我拿到AndroidManifest.xml文件後發現沒有加入android:sharedUserId="android.uid.system",說明打包合併AndroidManifest.xml的時候出了問題。
解決:
應用中我們通常會有多個代碼目錄和多個AndroidManifest.xml文件,這些文件都需要被引用進入最後編譯打包的時候合併到一個AndroidManifest.xml文件中,其中就包括兩種引入:
1.這些是引入依賴庫或者是其他目錄的AndroidManifest文件(庫文件)
LOCAL_FULL_LIBS_MANIFEST_FILES := \
$(LOCAL_PATH)/xxx/AndroidManifest.xml \
$(LOCAL_PATH)/AndroidManifest-common.xml
2.LOCAL_MANIFEST_FILE這個是主AndroidManifest.xml文件
LOCAL_MANIFEST_FILE := AndroidManifest.xml
因爲我把主AndroidManifest.xml文件寫到庫引入裏面了導致編譯合併的時候沒有寫入