AndroidManifest.xml文件何时被加载?如何查看apk的AndroidManifest

版权声明:本文为博主原创文章,转载希望能注明出处,感谢。 https://blog.csdn.net/u010126792/article/details/82854222

1 何时被加载

首先分析一波,四大组件需要在AndroidManifest文件中配置否则无法使用,类似Activity无法启动,

Activity可以被其他应用利用全类名或者action启动,就算此时要启动activity的应用没有被启动呢,

所以AndroidManifest在系统启动时或者应用安装完毕后已经被系统加载。

从系统代码级别解释就是系统启动过程中PMS会扫描特定目录下的apk进行安装,此时就会解析AndroidManifest文件。

源码解析AM.xml

PackageManagerService服务启动之后会扫描多个目录,下面存放着apk,调用scanDirLI对apk进行解析,经过一系列调用会调用到函数parseBaseApk,内部会利用XmlPullParser解析AndroidManifest文件,解析出信息会被放入Settings中,删除软件时信息会被删除,安装新的apk会重复调用scanDirLi。具体的详细过程大家可以参考源码。

2 如何查看apk的AndroidManifest.xml

拿到一个apk,利用解压文件解压apk可以看到AndroidManifest.xml文件,直接用文本文件打开会看到是乱码,

因为此时已经被编译成二进制文件,想要查看AndroidManifest文件可以利用工具AXMLPrinter2.jar

dos中:java -jar  AXMLPrinter2.jar AndroidManifest.xml

微信的部分AndroidManifest.xml文件:

<?xml version="1.0" encoding="utf-8"?>
<manifest
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:versionCode="1320"
        android:versionName="6.6.7"
        android:installLocation="0"
        package="com.tencent.mm"
        platformBuildVersionCode="26"
        platformBuildVersionName="8.0.0"
        >
        <uses-sdk
                android:minSdkVersion="17"
                android:targetSdkVersion="23"
                >
        </uses-sdk>
        <permission
                android:name="com.tencent.mm.plugin.permission.WRITE"
                android:protectionLevel="0x00000002"
                >
        </permission>

        <uses-feature
                android:glEsVersion="0x00020000"
                android:required="true"
                >
        </uses-feature>
        <application
                android:theme="@7F0C003C"
                android:label="@7F080210"
                android:icon="@7F0203CD"
                android:name="com.tencent.mm.app.Application"
                android:persistent="false"
                android:allowBackup="false"
                android:hardwareAccelerated="true"
                android:largeHeap="true"
                >
                <activity
                        android:theme="@7F0C020E"
                        android:name="com.tencent.mm.app.WeChatSplashActivity"
                        android:launchMode="0"
                        android:screenOrientation="1"
                        >
                </activity>
                <activity
                        android:theme="@7F0C020E"
                        android:name="com.tencent.mm.app.WeChatSplashFallbackActivity"
                        android:process=":fallback"
                        >
                </activity>
                <uses-library
                        android:name="com.google.android.maps"
                        android:required="false"
                        >
                </uses-library>
                <uses-library
                        android:name="com.sec.android.app.multiwindow"
                        android:required="false"
                        >
                </uses-library>
                <meta-data
                        android:name="com.sec.android.support.multiwindow"
                        android:value="true"
                        >
                </meta-data>
                <meta-data
                        android:name="com.sec.android.multiwindow.DEFAULT_SIZE_W"
                        android:value="632.0dip"
                        >
                </meta-data>
                <meta-data
                        android:name="com.sec.android.multiwindow.DEFAULT_SIZE_H"
                        android:value="598.0dip"
                        >
                </meta-data>
                <meta-data
                        android:name="com.sec.android.multiwindow.MINIMUM_SIZE_W"
                        android:value="632.0dip"
                        >
                </meta-data>
                <meta-data
                        android:name="com.sec.android.multiwindow.MINIMUM_SIZE_H"
                        android:value="598.0dip"
                        >
                </meta-data>
                <meta-data
                        android:name="android.max_aspect"
                        android:value="2.4"
                        >
                </meta-data>
                <meta-data
                        android:name="android.vendor.full_screen"
                        android:value="true"
                        >
                </meta-data>
                <meta-data
                        android:name="android.notch_support"
                        android:value="true "
                        >
                </meta-data>
                <meta-data
                        android:name="wx_qlauncher_coop"
                        android:value="fun1,fun2"
                        >
                </meta-data>
                <meta-data
                        android:name="wechat_fun_support"
                        android:value="ext1"
                        >
                </meta-data>
                <meta-data
                        android:name="wechat_ext_api_level"
                        android:value="10"
                        >
                </meta-data>
                <meta-data
                        android:name="SupportedAirMsgVersion"
                        android:value="1.0.0"
                        >
                </meta-data>
                <meta-data
                        android:name="SupportedSharedFileVideoVersion"
                        android:value="1.0.0"
                        >
                </meta-data>
                <meta-data
                        android:name="com.tencent.mm.BuildInfo.CLIENT_VERSION"
                        android:value="0x26060734"
                        >
                </meta-data>
                <meta-data
                        android:name="com.tencent.mm.BuildInfo.OPEN_SDK_VERSION"
                        android:value="620823808"
                        >
                </meta-data>
                <meta-data
                        android:name="com.tencent.mm.BuildInfo.OPEN_SDK_PAY_ENTRY_CLASSNAME"
                        android:value="com.tencent.mm.plugin.base.stub.WXPayEntryActivity"
                        >
                </meta-data>
                <meta-data
                        android:name="com.tencent.mm.BuildInfo.BUILD_TAG"
                        android:value="MicroMessenger_Android_GIT_RELEASE_GRADLE #6868"
                        >
                </meta-data>
                <meta-data
                        android:name="com.tencent.mm.BuildInfo.BUILD_OWNER"
                        android:value="amm_code_helper"
                        >
                </meta-data>
                <meta-data
                        android:name="com.tencent.mm.BuildInfo.BUILD_HOSTNAME"
                        android:value="45ea8765cf33"
                        >
                </meta-data>
                <meta-data
                        android:name="com.tencent.mm.BuildInfo.BUILD_TIME"
                        android:value="2018-05-30 18:18:27"
                        >
                </meta-data>
                <meta-data
                        android:name="com.tencent.mm.BuildInfo.BUILD_COMMAND"
                        android:value="null"
                        >
                </meta-data>
                <meta-data
                        android:name="com.tencent.mm.BuildInfo.BUILD_REV"
                        android:value="5127a1256ea1bfead2c6916a936c0652ac2e63e9"
                        >
                </meta-data>
                <meta-data
                        android:name="com.tencent.mm.BuildInfo.BUILD_SVNPATH"
                        android:value="origin/RB-2018-APR@git"
                        >
                </meta-data>
                <activity
                        android:theme="@7F0C0094"
                        android:label="@7F080DAB"
                        android:name="com.tencent.mm.ui.LauncherUI"
                        android:launchMode="1"
                        android:configChanges="0x00000DA0"
                        android:windowSoftInputMode="0x00000012"
                        >
                        <intent-filter
                                >
                                <action
                                        android:name="android.intent.action.MAIN"
                                        >
                                </action>
                                <category
                                        android:name="android.intent.category.LAUNCHER"
                                        >
                                </category>
                                <category
                                        android:name="android.intent.category.MULTIWINDOW_LAUNCHER"
                                        >
                                </category>
                        </intent-filter>
                        <intent-filter
                                >
                                <action
                                        android:name="com.tencent.mm.action.BIZSHORTCUT"
                                        >
                                </action>
                                <category
                                        android:name="android.intent.category.DEFAULT"
                                        >
                                </category>
                        </intent-filter>
                </activity>
                <activity
                        android:name="com.tencent.mm.ui.DataTransferUI"
                        android:launchMode="2"
                        android:configChanges="0x000004A0"
                        >
                </activity>

  
        </application>
</manifest>

猜你喜欢

转载自blog.csdn.net/u010126792/article/details/82854222