如何查看Android apk的包名?

时间:2022-08-20 16:36:41

有以下四种方法可以查看apk的包名,之后有别的方法,会接着更新文档的。

  1. 安装APK包名查看器;

  2. 源码AndroidManifest.xml中查看package包名;

  3. 利用"*\adt-bundle-windows-x86-20130917\sdk\tools\hierarchyviewer.bat"获取当前活动package的包名,同时可以获取控件的坐标和ID;

  4. 利用aapt查看包名: tools或者platform tools或者sdk/build-tools/aapt.exe(进入cmd)

    aapt dump badging *.apk

    由于输出信息比较多,容易覆盖包名,建议把info输出到txt文件中:

    aapt dump badging *.apk >info.txt

    输出如下:

    Package Groups (1)
    Package Group 0 id=127 packageCount=1 name=com.chartcross.gpstest
      Package 0 id=127 name=com.chartcross.gpstest typeCount=11
        type 0 configCount=1 entryCount=32
          spec resource 0x7f010000 com.chartcross.gpstest:attr/adSize: flags=0x00000000
          spec resource 0x7f010001 com.chartcross.gpstest:attr/adSizes: flags=0x00000000
          spec resource 0x7f010002 com.chartcross.gpstest:attr/adUnitId: flags=0x00000000

  5. adb logcat抓取当前运行的apk的包名:ActivityManager(数字):Displayed 包名/类名:+ **ms

    adb logcat > log.txt (从最后log开始找或者搜索关键字)

    输出如下:

      I/ActivityManager(  506): Displayed com.android.gallery3d/.app.GalleryActivity: +1s89ms

      I/ActivityManager(  506): Process com.android.music (pid 1009) has died

      W/BlobCache( 1520): cannot read header

      D/        (  136): RPCSendMsgToClient: remote_app_id = 0, context_id = 0

      D/        (  162): AppRecvFromRPCIFTask: recieved_bytes = 54

      D/        (  162): IPC ReadCB:  RSP/IND idx(91)

      D/        (  156): AppRecvFromRPCIFTask: recieved_bytes = 54

    又或者以关键字"android.intent.category.LAUNCHER"搜索:    

      W/RenderThread( 1030): type=1400 audit(0.0:86): avc: denied { read write } for path="/dev/mali" dev="tmpfs" ino=11374 scontext=u:r:untrusted_app:s0       tcontext=u:object_r:device:s0 tclass=chr_file

      I/ActivityManager(  506): START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.android.gallery3d/.app.GalleryActivity (has     extras)} from uid 10008 on display 0

      D/MSM     (  134): event = change@/devices/rk818.196/rk818-battery/power_supply/BATTERY

      D/MSM     (  134): event = !modem event ignore

      D/MSM     (  134): --> wait for event