1222.html 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720
  1. <!DOCTYPE html>
  2. <html lang="en" data-default-color-scheme=auto>
  3. <head><!-- hexo injector head_begin start -->
  4. <script async src="https://analytics.umami.is/script.js" data-website-id="e59ec28a-c9a7-4104-9e62-a9f7eb3fac0b"></script>
  5. <!-- hexo injector head_begin end -->
  6. <meta charset="UTF-8">
  7. <link rel="apple-touch-icon" sizes="76x76" href="https://img.limour.top/2023/08/29/64ee07361815a.webp">
  8. <link rel="icon" href="https://img.limour.top/2023/08/29/64ee07361815a.webp">
  9. <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0, shrink-to-fit=no">
  10. <meta http-equiv="x-ua-compatible" content="ie=edge">
  11. <meta name="theme-color" content="#2f4154">
  12. <meta name="author" content="Limour">
  13. <meta name="keywords" content="">
  14. <meta name="description" content="来源apk的包名修改@tianxiaozzApktool重打包Apk详细介绍Android修改应用包名和ApplicationId:实战和理解 第一步 安装依赖 JDK:安装JDK@廖雪峰 Apktool:Installation for Apktool 12pip3 install python-magicpip3 install python-magic-bin 第二步 逆向解包APK1.">
  15. <meta property="og:type" content="article">
  16. <meta property="og:title" content="APK的包名修改">
  17. <meta property="og:url" content="https://b.limour.top/1222.html">
  18. <meta property="og:site_name" content="Limour&#39;s Blog">
  19. <meta property="og:description" content="来源apk的包名修改@tianxiaozzApktool重打包Apk详细介绍Android修改应用包名和ApplicationId:实战和理解 第一步 安装依赖 JDK:安装JDK@廖雪峰 Apktool:Installation for Apktool 12pip3 install python-magicpip3 install python-magic-bin 第二步 逆向解包APK1.">
  20. <meta property="og:locale" content="en_US">
  21. <meta property="og:image" content="https://img-cdn.limour.top/blog_wp/2021/11/0f25ad37e69eea0f05ffdd4ba6cbbab.png">
  22. <meta property="og:image" content="https://img-cdn.limour.top/blog_wp/2021/11/image-3.png">
  23. <meta property="og:image" content="https://img-cdn.limour.top/blog_wp/2021/11/9abeda08b2b408d196779f058d37a9b.png">
  24. <meta property="og:image" content="https://img-cdn.limour.top/blog_wp/2021/11/5e2d83c8f998a1e3b69761778c0e5cc.png">
  25. <meta property="og:image" content="https://img-cdn.limour.top/blog_wp/2021/11/53bbb0390bb68b8704845cabf3edf0f.png">
  26. <meta property="article:published_time" content="2021-11-03T09:41:02.000Z">
  27. <meta property="article:modified_time" content="2023-09-01T13:32:00.645Z">
  28. <meta property="article:author" content="Limour">
  29. <meta name="twitter:card" content="summary_large_image">
  30. <meta name="twitter:image" content="https://img-cdn.limour.top/blog_wp/2021/11/0f25ad37e69eea0f05ffdd4ba6cbbab.png">
  31. <title>APK的包名修改 - Limour&#39;s Blog</title>
  32. <link rel="stylesheet" href="https://jscdn.limour.top/npm/bootstrap@4.6.1/dist/css/bootstrap.min.css" />
  33. <link rel="stylesheet" href="https://jscdn.limour.top/npm/github-markdown-css@4.0.0/github-markdown.min.css" />
  34. <link rel="stylesheet" href="https://jscdn.limour.top/npm/hint.css@2.7.0/hint.min.css" />
  35. <link rel="stylesheet" href="https://lib.baomitu.com/fancybox/3.5.7/jquery.fancybox.min.css" />
  36. <!-- 主题依赖的图标库,不要自行修改 -->
  37. <!-- Do not modify the link that theme dependent icons -->
  38. <link rel="stylesheet" href="//at.alicdn.com/t/font_1749284_hj8rtnfg7um.css">
  39. <link rel="stylesheet" href="//at.alicdn.com/t/font_1736178_lbnruvf0jn.css">
  40. <link rel="stylesheet" href="/css/main.css" />
  41. <link id="highlight-css" rel="stylesheet" href="/css/highlight.css" />
  42. <link id="highlight-css-dark" rel="stylesheet" href="/css/highlight-dark.css" />
  43. <link rel="stylesheet" href="/theme-inject/custom.css">
  44. <script id="fluid-configs">
  45. var Fluid = window.Fluid || {};
  46. Fluid.ctx = Object.assign({}, Fluid.ctx)
  47. var CONFIG = {"hostname":"b.limour.top","root":"/","version":"1.9.5-a","typing":{"enable":true,"typeSpeed":70,"cursorChar":"_","loop":false,"scope":[]},"anchorjs":{"enable":true,"element":"h1,h2,h3,h4,h5,h6","placement":"left","visible":"hover","icon":"§"},"progressbar":{"enable":true,"height_px":3,"color":"#29d","options":{"showSpinner":false,"trickleSpeed":100}},"code_language":{"enable":true,"default":"TEXT"},"copy_btn":true,"image_caption":{"enable":true},"image_zoom":{"enable":true,"img_url_replace":["",""]},"toc":{"enable":true,"placement":"right","headingSelector":"h1,h2,h3,h4,h5,h6","collapseDepth":0},"lazyload":{"enable":true,"loading_img":"https://jscdn.limour.top/gh/Limour-dev/Sakurairo_Vision/load_svg/inload.svg","onlypost":false,"offset_factor":2},"web_analytics":{"enable":false,"follow_dnt":true,"baidu":null,"google":{"measurement_id":null},"tencent":{"sid":null,"cid":null},"woyaola":null,"cnzz":null,"leancloud":{"app_id":null,"app_key":null,"server_url":null,"path":"window.location.pathname","ignore_local":false}},"search_path":"/local-search.xml","include_content_in_search":true};
  48. if (CONFIG.web_analytics.follow_dnt) {
  49. var dntVal = navigator.doNotTrack || window.doNotTrack || navigator.msDoNotTrack;
  50. Fluid.ctx.dnt = dntVal && (dntVal.startsWith('1') || dntVal.startsWith('yes') || dntVal.startsWith('on'));
  51. }
  52. </script>
  53. <script src="/js/utils.js" ></script>
  54. <script src="/js/color-schema.js" ></script>
  55. <meta name="generator" content="Hexo 6.3.0"></head>
  56. <body>
  57. <header>
  58. <div class="header-inner" style="height: 70vh;">
  59. <nav id="navbar" class="navbar fixed-top navbar-expand-lg navbar-dark scrolling-navbar">
  60. <div class="container">
  61. <a class="navbar-brand" href="/">
  62. <strong>Limour&#39;s Blog</strong>
  63. </a>
  64. <button id="navbar-toggler-btn" class="navbar-toggler" type="button" data-toggle="collapse"
  65. data-target="#navbarSupportedContent"
  66. aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
  67. <div class="animated-icon"><span></span><span></span><span></span></div>
  68. </button>
  69. <!-- Collapsible content -->
  70. <div class="collapse navbar-collapse" id="navbarSupportedContent">
  71. <ul class="navbar-nav ml-auto text-center">
  72. <li class="nav-item">
  73. <a class="nav-link" href="/">
  74. <i class="iconfont icon-home-fill"></i>
  75. <span>Home</span>
  76. </a>
  77. </li>
  78. <li class="nav-item">
  79. <a class="nav-link" href="/archives/">
  80. <i class="iconfont icon-archive-fill"></i>
  81. <span>Archives</span>
  82. </a>
  83. </li>
  84. <li class="nav-item" id="search-btn">
  85. <a class="nav-link" target="_self" href="javascript:;" data-toggle="modal" data-target="#modalSearch" aria-label="Search">
  86. <i class="iconfont icon-search"></i>
  87. </a>
  88. </li>
  89. <li class="nav-item" id="color-toggle-btn">
  90. <a class="nav-link" target="_self" href="javascript:;" aria-label="Color Toggle">
  91. <i class="iconfont icon-dark" id="color-toggle-icon"></i>
  92. </a>
  93. </li>
  94. </ul>
  95. </div>
  96. </div>
  97. </nav>
  98. <div id="banner" class="banner" parallax=true
  99. style="background: url('https://img.limour.top/2023/08/29/64ee08e108638.webp') no-repeat center center; background-size: cover;">
  100. <div class="full-bg-img">
  101. <div class="mask flex-center" style="background-color: rgba(0, 0, 0, 0.3)">
  102. <div class="banner-text text-center fade-in-up">
  103. <div class="h2">
  104. <span id="subtitle" data-typed-text="APK的包名修改"></span>
  105. </div>
  106. <div class="mt-3">
  107. <span class="post-meta">
  108. <i class="iconfont icon-date-fill" aria-hidden="true"></i>
  109. <time datetime="2021-11-03 17:41" pubdate>
  110. November 3, 2021 pm
  111. </time>
  112. </span>
  113. </div>
  114. <div class="mt-1">
  115. <span class="post-meta mr-2">
  116. <i class="iconfont icon-chart"></i>
  117. 3.9k words
  118. </span>
  119. <span class="post-meta mr-2">
  120. <i class="iconfont icon-clock-fill"></i>
  121. 33 mins
  122. </span>
  123. </div>
  124. </div>
  125. </div>
  126. </div>
  127. </div>
  128. </div>
  129. </header>
  130. <main>
  131. <div class="container-fluid nopadding-x">
  132. <div class="row nomargin-x">
  133. <div class="side-col d-none d-lg-block col-lg-2">
  134. </div>
  135. <div class="col-lg-8 nopadding-x-md">
  136. <div class="container nopadding-x-md" id="board-ctn">
  137. <div id="board">
  138. <article class="post-content mx-auto">
  139. <h1 id="seo-header">APK的包名修改</h1>
  140. <div class="markdown-body">
  141. <h2 id="来源"><a href="#来源" class="headerlink" title="来源"></a>来源</h2><p><a target="_blank" rel="noopener" href="https://www.cnblogs.com/tianxiaozz/archive/2012/12/26/change_apk_package_name.html">apk的包名修改</a>@<a target="_blank" rel="noopener" href="https://www.cnblogs.com/tianxiaozz/">tianxiaozz</a><br><a target="_blank" rel="noopener" href="https://blog.csdn.net/u010889616/article/details/78198822">Apktool重打包Apk详细介绍</a><br><a target="_blank" rel="noopener" href="https://www.jianshu.com/p/7643fe0967c1">Android修改应用包名和ApplicationId:实战和理解</a></p>
  142. <h2 id="第一步-安装依赖"><a href="#第一步-安装依赖" class="headerlink" title="第一步 安装依赖"></a>第一步 安装依赖</h2><ul>
  143. <li>JDK:<a target="_blank" rel="noopener" href="https://www.liaoxuefeng.com/wiki/1252599548343744/1280507291631649">安装JDK@廖雪峰</a></li>
  144. <li>Apktool:<a target="_blank" rel="noopener" href="https://ibotpeaches.github.io/Apktool/install/">Installation for Apktool</a></li>
  145. </ul>
  146. <figure class="highlight powershell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs powershell">pip3 install python<span class="hljs-literal">-magic</span><br>pip3 install python<span class="hljs-literal">-magic-bin</span><br></code></pre></td></tr></table></figure>
  147. <h2 id="第二步-逆向解包APK"><a href="#第二步-逆向解包APK" class="headerlink" title="第二步 逆向解包APK"></a>第二步 逆向解包APK</h2><figure class="highlight powershell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs powershell">.\apktool.bat d .\xpushdemo.apk<br></code></pre></td></tr></table></figure>
  148. <p><a target="_blank" rel="noopener" href="https://img-cdn.limour.top/blog_wp/2021/11/0f25ad37e69eea0f05ffdd4ba6cbbab.png"><img src="https://img-cdn.limour.top/blog_wp/2021/11/0f25ad37e69eea0f05ffdd4ba6cbbab.png" srcset="https://jscdn.limour.top/gh/Limour-dev/Sakurairo_Vision/load_svg/inload.svg" lazyload></a></p>
  149. <h2 id="第三步-使用python批量替换"><a href="#第三步-使用python批量替换" class="headerlink" title="第三步 使用python批量替换"></a>第三步 使用python批量替换</h2><ul>
  150. <li>该文件保存为 <code>isBinaryFile.py</code> 用于判断文件是否为文本型文件</li>
  151. </ul>
  152. <figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br></pre></td><td class="code"><pre><code class="hljs python"><span class="hljs-comment"># -*- coding:utf-8 -*-</span><br><span class="hljs-comment"># @Author:zgd</span><br><span class="hljs-comment"># @time:2019/6/21</span><br><span class="hljs-comment"># @File:operateSystem.py</span><br><br><span class="hljs-keyword">import</span> magic, os, stat<br><span class="hljs-keyword">import</span> re<br><span class="hljs-keyword">import</span> codecs<br> <br><span class="hljs-keyword">def</span> <span class="hljs-title function_">is_binary_file_1</span>(<span class="hljs-params">file_path</span>):<br> <span class="hljs-string">&#x27;&#x27;&#x27;</span><br><span class="hljs-string"> 根据text文件数据类型判断是否是二进制文件</span><br><span class="hljs-string"> :param ff: 文件名(含路径)</span><br><span class="hljs-string"> :return: True或False,返回是否是二进制文件</span><br><span class="hljs-string"> &#x27;&#x27;&#x27;</span><br> TEXT_BOMS = (<br> codecs.BOM_UTF16_BE,<br> codecs.BOM_UTF16_LE,<br> codecs.BOM_UTF32_BE,<br> codecs.BOM_UTF32_LE,<br> codecs.BOM_UTF8,<br> )<br> <span class="hljs-keyword">with</span> <span class="hljs-built_in">open</span>(file_path, <span class="hljs-string">&#x27;rb&#x27;</span>) <span class="hljs-keyword">as</span> file:<br> CHUNKSIZE = <span class="hljs-number">8192</span><br> initial_bytes = file.read(CHUNKSIZE)<br> file.close()<br> <span class="hljs-comment">#: BOMs to indicate that a file is a text file even if it contains zero bytes.</span><br> <span class="hljs-keyword">return</span> <span class="hljs-keyword">not</span> <span class="hljs-built_in">any</span>(initial_bytes.startswith(bom) <span class="hljs-keyword">for</span> bom <span class="hljs-keyword">in</span> TEXT_BOMS) <span class="hljs-keyword">and</span> <span class="hljs-string">b&#x27;\0&#x27;</span> <span class="hljs-keyword">in</span> initial_bytes<br> <br> <br><span class="hljs-keyword">def</span> <span class="hljs-title function_">is_binary_file_2</span>(<span class="hljs-params">ff</span>):<br> <span class="hljs-string">&#x27;&#x27;&#x27;</span><br><span class="hljs-string"> 根据magic文件的魔术判断是否是二进制文件</span><br><span class="hljs-string"> :param ff: 文件名(含路径)</span><br><span class="hljs-string"> :return: True或False,返回是否是二进制文件</span><br><span class="hljs-string"> &#x27;&#x27;&#x27;</span><br> mime_kw = <span class="hljs-string">&#x27;x-executablex-sharedliboctet-streamx-object&#x27;</span> <span class="hljs-comment">###可执行文件、链接库、动态流、对象</span><br> <span class="hljs-keyword">try</span>:<br> magic_mime = magic.from_file(ff, mime=<span class="hljs-literal">True</span>)<br> magic_hit = re.search(mime_kw, magic_mime, re.I)<br> <span class="hljs-keyword">if</span> magic_hit:<br> <span class="hljs-keyword">return</span> <span class="hljs-literal">True</span><br> <span class="hljs-keyword">else</span>:<br> <span class="hljs-keyword">return</span> <span class="hljs-literal">False</span><br> <span class="hljs-keyword">except</span> Exception <span class="hljs-keyword">as</span> e:<br> <span class="hljs-keyword">return</span> <span class="hljs-literal">False</span><br><br><br><span class="hljs-keyword">def</span> <span class="hljs-title function_">is_ELFfile</span>(<span class="hljs-params">filepath</span>):<br> <span class="hljs-keyword">if</span> <span class="hljs-keyword">not</span> os.path.exists(filepath):<br> logger.info(<span class="hljs-string">&#x27;file path &#123;&#125; doesnot exits&#x27;</span>.<span class="hljs-built_in">format</span>(filepath))<br> <span class="hljs-keyword">return</span> <span class="hljs-literal">False</span><br> <span class="hljs-comment"># 文件可能被损坏,捕捉异常</span><br> <span class="hljs-keyword">try</span>:<br> FileStates = os.stat(filepath)<br> FileMode = FileStates[stat.ST_MODE]<br> <span class="hljs-keyword">if</span> <span class="hljs-keyword">not</span> stat.S_ISREG(FileMode) <span class="hljs-keyword">or</span> stat.S_ISLNK(FileMode): <span class="hljs-comment"># 如果文件既不是普通文件也不是链接文件</span><br> <span class="hljs-keyword">return</span> <span class="hljs-literal">False</span><br> <span class="hljs-keyword">with</span> <span class="hljs-built_in">open</span>(filepath, <span class="hljs-string">&#x27;rb&#x27;</span>) <span class="hljs-keyword">as</span> f:<br> header = (<span class="hljs-built_in">bytearray</span>(f.read(<span class="hljs-number">4</span>))[<span class="hljs-number">1</span>:<span class="hljs-number">4</span>]).decode(encoding=<span class="hljs-string">&quot;utf-8&quot;</span>)<br> <span class="hljs-comment"># logger.info(&quot;header is &#123;&#125;&quot;.format(header))</span><br> <span class="hljs-keyword">if</span> header <span class="hljs-keyword">in</span> [<span class="hljs-string">&quot;ELF&quot;</span>]:<br> <span class="hljs-comment"># print header</span><br> <span class="hljs-keyword">return</span> <span class="hljs-literal">True</span><br> <span class="hljs-keyword">except</span> UnicodeDecodeError <span class="hljs-keyword">as</span> e:<br> <span class="hljs-comment"># logger.info(&quot;is_ELFfile UnicodeDecodeError &#123;&#125;&quot;.format(filepath))</span><br> <span class="hljs-comment"># logger.info(str(e))</span><br> <span class="hljs-keyword">pass</span><br> <br> <span class="hljs-keyword">return</span> <span class="hljs-literal">False</span><br><br><span class="hljs-keyword">def</span> <span class="hljs-title function_">is_binary_file</span>(<span class="hljs-params">filepath</span>):<br> <span class="hljs-keyword">return</span> <span class="hljs-built_in">any</span>((is_binary_file_1(filepath), is_binary_file_2(filepath), is_ELFfile(filepath)))<br></code></pre></td></tr></table></figure>
  153. <ul>
  154. <li>运行该文件 <code>replacetxt.py</code> 用于替换包名 和 包路径</li>
  155. </ul>
  156. <figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br></pre></td><td class="code"><pre><code class="hljs python"><span class="hljs-comment">#!/usr/bin/python</span><br> <br><span class="hljs-keyword">import</span> os<br> <br><span class="hljs-keyword">import</span> re<br><br><span class="hljs-keyword">from</span> isBinaryFile <span class="hljs-keyword">import</span> is_binary_file<br><span class="hljs-comment">#list files</span><br> <br><span class="hljs-keyword">def</span> <span class="hljs-title function_">listFiles</span>(<span class="hljs-params">dirPath</span>):<br> <br> fileList=[]<br> <br> <span class="hljs-keyword">for</span> root,dirs,files <span class="hljs-keyword">in</span> os.walk(dirPath):<br> <br> <span class="hljs-keyword">for</span> fileObj <span class="hljs-keyword">in</span> files:<br> <br> fileList.append(os.path.join(root,fileObj))<br> <br> <span class="hljs-keyword">return</span> fileList<br> <br><span class="hljs-keyword">def</span> <span class="hljs-title function_">main</span>():<br> <br> fileDir = <span class="hljs-string">r&quot;E:\apktool\xpushdemo&quot;</span><br> <br> regex = <span class="hljs-string">r&#x27;FUNC_SYS_ADD_ACCDETAIL&#x27;</span><br> <br> fileList = listFiles(fileDir)<br> <br> <span class="hljs-keyword">for</span> fileObj <span class="hljs-keyword">in</span> fileList:<br> <span class="hljs-keyword">if</span> is_binary_file(fileObj):<br> <span class="hljs-keyword">continue</span><br> <span class="hljs-keyword">try</span>:<br> f = <span class="hljs-built_in">open</span>(fileObj,<span class="hljs-string">&#x27;r+&#x27;</span>,encoding=<span class="hljs-string">&#x27;utf-8&#x27;</span>)<br> all_the_lines=f.readlines()<br> <span class="hljs-keyword">except</span>:<br> f.close()<br> <span class="hljs-keyword">continue</span><br> <br> f.seek(<span class="hljs-number">0</span>)<br> <br> f.truncate()<br> <br> <span class="hljs-keyword">for</span> line <span class="hljs-keyword">in</span> all_the_lines:<br> line = line.replace(<span class="hljs-string">r&#x27;com.xuexiang.pushdemo&#x27;</span>,<span class="hljs-string">r&#x27;com.limour.pushdemo&#x27;</span>)<br> line = line.replace(<span class="hljs-string">r&#x27;com/xuexiang/pushdemo&#x27;</span>,<span class="hljs-string">r&#x27;com/limour/pushdemo&#x27;</span>)<br> f.write(line) <br> <br> f.close() <br> <br><span class="hljs-keyword">if</span> __name__==<span class="hljs-string">&#x27;__main__&#x27;</span>:<br> main() <br></code></pre></td></tr></table></figure>
  157. <ul>
  158. <li>如有 <code>provider</code> 的 <code>authorities</code> 未更改,自行修改.py文件进行批量修改</li>
  159. <li>找到所有这种层级的 <code>com/xuexiang/pushdemo</code> 文件夹<br>把对应的文件夹名称更改为包名对应的名称 <code>com/limour/pushdemo</code></li>
  160. <li>用 Notepad++ 手动替换 解包目录下 <code>AndroidManifest.xml</code> 内的 <code>com.xuexiang.pushdemo</code> 为 <code>com.limour.pushdemo</code></li>
  161. </ul>
  162. <h2 id="第四步-打包apk"><a href="#第四步-打包apk" class="headerlink" title="第四步 打包apk"></a>第四步 打包apk</h2><figure class="highlight powershell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs powershell">.\apktool.bat b .\xpushdemo<br></code></pre></td></tr></table></figure>
  163. <p><a target="_blank" rel="noopener" href="https://img-cdn.limour.top/blog_wp/2021/11/image-3.png"><img src="https://img-cdn.limour.top/blog_wp/2021/11/image-3.png" srcset="https://jscdn.limour.top/gh/Limour-dev/Sakurairo_Vision/load_svg/inload.svg" lazyload></a></p>
  164. <p>新打包的apk在解包文件夹的 <code>dist</code> 目录下</p>
  165. <ul>
  166. <li>出现 \res\values\xxx.xml 111 <code>xx.xx.xx</code> 找不到时,就手动将 <code>.</code> 改成 <code>_</code></li>
  167. </ul>
  168. <h2 id="第五步-生成证书"><a href="#第五步-生成证书" class="headerlink" title="第五步 生成证书"></a>第五步 生成证书</h2><figure class="highlight powershell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs powershell">keytool <span class="hljs-literal">-genkey</span> <span class="hljs-literal">-alias</span> abc.keystore <span class="hljs-literal">-keyalg</span> RSA <span class="hljs-literal">-validity</span> <span class="hljs-number">20000</span> <span class="hljs-literal">-keystore</span> abc.keystore<br></code></pre></td></tr></table></figure>
  169. <p><a target="_blank" rel="noopener" href="https://img-cdn.limour.top/blog_wp/2021/11/9abeda08b2b408d196779f058d37a9b.png"><img src="https://img-cdn.limour.top/blog_wp/2021/11/9abeda08b2b408d196779f058d37a9b.png" srcset="https://jscdn.limour.top/gh/Limour-dev/Sakurairo_Vision/load_svg/inload.svg" lazyload></a></p>
  170. <p><a target="_blank" rel="noopener" href="https://img-cdn.limour.top/blog_wp/2021/11/5e2d83c8f998a1e3b69761778c0e5cc.png"><img src="https://img-cdn.limour.top/blog_wp/2021/11/5e2d83c8f998a1e3b69761778c0e5cc.png" srcset="https://jscdn.limour.top/gh/Limour-dev/Sakurairo_Vision/load_svg/inload.svg" lazyload></a></p>
  171. <h2 id="第六步-给apk签名"><a href="#第六步-给apk签名" class="headerlink" title="第六步 给apk签名"></a>第六步 给apk签名</h2><ul>
  172. <li>新打包的apk在解包文件夹的 <code>dist</code> 目录下,先移动到证书目录,再运行下面的命令</li>
  173. </ul>
  174. <figure class="highlight powershell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs powershell">jarsigner <span class="hljs-literal">-verbose</span> <span class="hljs-literal">-keystore</span> abc.keystore <span class="hljs-literal">-signedjar</span> xpushdemo_signed.apk xpushdemo.apk abc.keystore<br></code></pre></td></tr></table></figure>
  175. <p><a target="_blank" rel="noopener" href="https://img-cdn.limour.top/blog_wp/2021/11/53bbb0390bb68b8704845cabf3edf0f.png"><img src="https://img-cdn.limour.top/blog_wp/2021/11/53bbb0390bb68b8704845cabf3edf0f.png" srcset="https://jscdn.limour.top/gh/Limour-dev/Sakurairo_Vision/load_svg/inload.svg" lazyload></a></p>
  176. <ul>
  177. <li>验证签名有效</li>
  178. </ul>
  179. <figure class="highlight powershell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs powershell">jarsigner <span class="hljs-literal">-verify</span> <span class="hljs-literal">-verbose</span> <span class="hljs-literal">-certs</span> xpushdemo_signed.apk <br></code></pre></td></tr></table></figure>
  180. <h2 id="第七步-优化apk-(可选,需安装-Android-SDK)"><a href="#第七步-优化apk-(可选,需安装-Android-SDK)" class="headerlink" title="第七步 优化apk (可选,需安装 Android SDK)"></a>第七步 优化apk (可选,需安装 Android SDK)</h2><ul>
  181. <li><a target="_blank" rel="noopener" href="https://developer.android.com/studio">Android Studio &amp;&amp; SDK</a></li>
  182. <li>将以下路径添加到环境变量Path<br>C:\Users\11248\AppData\Local\Android\Sdk\build-tools\31.0.0<br>C:\Users\11248\AppData\Local\Android\Sdk\tools\bin<br>C:\Users\11248\AppData\Local\Android\Sdk\platform-tools</li>
  183. </ul>
  184. <figure class="highlight powershell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs powershell">zipalign <span class="hljs-literal">-v</span> <span class="hljs-number">4</span> xpushdemo_signed.apk xpushdemo_latest.apk<br></code></pre></td></tr></table></figure>
  185. </div>
  186. <hr/>
  187. <div>
  188. <div class="post-metas my-3">
  189. <div class="post-meta mr-3 d-flex align-items-center">
  190. <i class="iconfont icon-category"></i>
  191. <span class="category-chains">
  192. <span class="category-chain">
  193. <a href="/categories/%E6%9C%89%E8%B6%A3%E6%8A%80%E8%83%BD/" class="category-chain-item">有趣技能</a>
  194. </span>
  195. <span class="category-chain">
  196. <a href="/categories/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%9B%B8%E5%85%B3/" class="category-chain-item">计算机相关</a>
  197. </span>
  198. </span>
  199. </div>
  200. </div>
  201. <div class="license-box my-3">
  202. <div class="license-title">
  203. <div>APK的包名修改</div>
  204. <div>https://b.limour.top/1222.html</div>
  205. </div>
  206. <div class="license-meta">
  207. <div class="license-meta-item">
  208. <div>Author</div>
  209. <div>Limour</div>
  210. </div>
  211. <div class="license-meta-item license-meta-date">
  212. <div>Posted on</div>
  213. <div>November 3, 2021</div>
  214. </div>
  215. <div class="license-meta-item">
  216. <div>Licensed under</div>
  217. <div>
  218. <a class="print-no-link" target="_blank" href="https://creativecommons.org/licenses/by-nc-sa/4.0/">
  219. <span class="hint--top hint--rounded" aria-label="BY - Attribution">
  220. <i class="iconfont icon-by"></i>
  221. </span>
  222. </a>
  223. <a class="print-no-link" target="_blank" href="https://creativecommons.org/licenses/by-nc-sa/4.0/">
  224. <span class="hint--top hint--rounded" aria-label="NC - Non-commercial">
  225. <i class="iconfont icon-nc"></i>
  226. </span>
  227. </a>
  228. <a class="print-no-link" target="_blank" href="https://creativecommons.org/licenses/by-nc-sa/4.0/">
  229. <span class="hint--top hint--rounded" aria-label="SA - Share-alike">
  230. <i class="iconfont icon-sa"></i>
  231. </span>
  232. </a>
  233. </div>
  234. </div>
  235. </div>
  236. <div class="license-icon iconfont"></div>
  237. </div>
  238. <div class="post-prevnext my-3">
  239. <article class="post-prev col-6">
  240. <a href="/1231.html" title="Seurat (八) BoxPlot:不同组间不同细胞的基因表达">
  241. <i class="iconfont icon-arrowleft"></i>
  242. <span class="hidden-mobile">Seurat (八) BoxPlot:不同组间不同细胞的基因表达</span>
  243. <span class="visible-mobile">Previous</span>
  244. </a>
  245. </article>
  246. <article class="post-next col-6">
  247. <a href="/1213.html" title="转载:Nginx安全设置防源站泄漏">
  248. <span class="hidden-mobile">转载:Nginx安全设置防源站泄漏</span>
  249. <span class="visible-mobile">Next</span>
  250. <i class="iconfont icon-arrowright"></i>
  251. </a>
  252. </article>
  253. </div>
  254. </div>
  255. <article id="comments" lazyload>
  256. <div id="waline"></div>
  257. <script type="text/javascript">
  258. Fluid.utils.loadComments('#waline', function() {
  259. Fluid.utils.createCssLink('https://cdn.staticfile.org/waline/2.15.5/waline.min.css')
  260. Fluid.utils.createScript('https://cdn.staticfile.org/waline/2.15.5/waline.min.js', function() {
  261. var options = Object.assign(
  262. {"serverURL":"https://comments.limour.top","path":"window.location.pathname","meta":["nick","mail","link"],"requiredMeta":["nick"],"lang":"zh-CN","emoji":["https://jscdn.limour.top/gh/walinejs/emojis/weibo"],"dark":"html[data-user-color-scheme=\"dark\"]","wordLimit":0,"pageSize":10},
  263. {
  264. el: '#waline',
  265. path: window.location.pathname
  266. }
  267. )
  268. Waline.init(options);
  269. Fluid.utils.waitElementVisible('#waline .vcontent', () => {
  270. var imgSelector = '#waline .vcontent img:not(.vemoji)';
  271. Fluid.plugins.imageCaption(imgSelector);
  272. Fluid.plugins.fancyBox(imgSelector);
  273. })
  274. });
  275. });
  276. </script>
  277. <noscript>Please enable JavaScript to view the comments</noscript>
  278. </article>
  279. </article>
  280. </div>
  281. </div>
  282. </div>
  283. <div class="side-col d-none d-lg-block col-lg-2">
  284. <aside class="sidebar" style="margin-left: -1rem">
  285. <div id="toc">
  286. <p class="toc-header">
  287. <i class="iconfont icon-list"></i>
  288. <span>Table of Contents</span>
  289. </p>
  290. <div class="toc-body" id="toc-body"></div>
  291. </div>
  292. </aside>
  293. </div>
  294. </div>
  295. </div>
  296. <a id="scroll-top-button" aria-label="TOP" href="#" role="button">
  297. <i class="iconfont icon-arrowup" aria-hidden="true"></i>
  298. </a>
  299. <div class="modal fade" id="modalSearch" tabindex="-1" role="dialog" aria-labelledby="ModalLabel"
  300. aria-hidden="true">
  301. <div class="modal-dialog modal-dialog-scrollable modal-lg" role="document">
  302. <div class="modal-content">
  303. <div class="modal-header text-center">
  304. <h4 class="modal-title w-100 font-weight-bold">Search</h4>
  305. <button type="button" id="local-search-close" class="close" data-dismiss="modal" aria-label="Close">
  306. <span aria-hidden="true">&times;</span>
  307. </button>
  308. </div>
  309. <div class="modal-body mx-3">
  310. <div class="md-form mb-5">
  311. <input type="text" id="local-search-input" class="form-control validate">
  312. <label data-error="x" data-success="v" for="local-search-input">Keyword</label>
  313. </div>
  314. <div class="list-group" id="local-search-result"></div>
  315. </div>
  316. </div>
  317. </div>
  318. </div>
  319. </main>
  320. <footer>
  321. <div class="footer-inner">
  322. <div class="footer-content">
  323. <a target="_blank" rel="nofollow noopener" href="http://www.beian.gov.cn/portal/registerSystemInfo?recordcode=43130202000203"><img src="https://img.limour.top/2023/08/27/64eadeb81d6a0.webp" srcset="https://jscdn.limour.top/gh/Limour-dev/Sakurairo_Vision/load_svg/inload.svg" lazyload>湘公网安备 43130202000203号 </a> <a target="_blank" rel="nofollow noopener" href="https://beian.miit.gov.cn/">湘ICP备20008299号 </a> <a target="_blank" rel="nofollow noopener" href="https://icp.gov.moe/?keyword=20210128">萌ICP备20210128号</a> <br> <a href="https://www.foreverblog.cn/" target="_blank"> <img src="https://img.foreverblog.cn/logo_en_default.png" srcset="https://jscdn.limour.top/gh/Limour-dev/Sakurairo_Vision/load_svg/inload.svg" lazyload alt="" style="width:auto;height:24px"> </a> <br> <a href="https://hexo.io" target="_blank" rel="nofollow noopener"><span>Hexo</span></a> <i class="iconfont icon-love"></i> <a href="https://github.com/fluid-dev/hexo-theme-fluid" target="_blank" rel="nofollow noopener"><span>Fluid</span></a> <i class="iconfont icon-love"></i> <a href="https://github.com/limour-blog/archives-b" target="_blank" rel="nofollow noopener"><span>SRC</span></a>
  324. </div>
  325. </div>
  326. </footer>
  327. <!-- Scripts -->
  328. <script src="https://jscdn.limour.top/npm/nprogress@0.2.0/nprogress.min.js" ></script>
  329. <link rel="stylesheet" href="https://jscdn.limour.top/npm/nprogress@0.2.0/nprogress.min.css" />
  330. <script>
  331. NProgress.configure({"showSpinner":false,"trickleSpeed":100})
  332. NProgress.start()
  333. window.addEventListener('load', function() {
  334. NProgress.done();
  335. })
  336. </script>
  337. <script src="https://jscdn.limour.top/npm/jquery@3.6.4/dist/jquery.min.js" ></script>
  338. <script src="https://jscdn.limour.top/npm/bootstrap@4.6.1/dist/js/bootstrap.min.js" ></script>
  339. <script src="/js/events.js" ></script>
  340. <script src="/js/plugins.js" ></script>
  341. <script src="https://lib.baomitu.com/typed.js/2.0.12/typed.min.js" ></script>
  342. <script>
  343. (function (window, document) {
  344. var typing = Fluid.plugins.typing;
  345. var subtitle = document.getElementById('subtitle');
  346. if (!subtitle || !typing) {
  347. return;
  348. }
  349. var text = subtitle.getAttribute('data-typed-text');
  350. typing(text);
  351. })(window, document);
  352. </script>
  353. <script src="/js/img-lazyload.js" ></script>
  354. <script>
  355. Fluid.utils.createScript('https://jscdn.limour.top/npm/tocbot@4.20.1/dist/tocbot.min.js', function() {
  356. var toc = jQuery('#toc');
  357. if (toc.length === 0 || !window.tocbot) { return; }
  358. var boardCtn = jQuery('#board-ctn');
  359. var boardTop = boardCtn.offset().top;
  360. window.tocbot.init(Object.assign({
  361. tocSelector : '#toc-body',
  362. contentSelector : '.markdown-body',
  363. linkClass : 'tocbot-link',
  364. activeLinkClass : 'tocbot-active-link',
  365. listClass : 'tocbot-list',
  366. isCollapsedClass: 'tocbot-is-collapsed',
  367. collapsibleClass: 'tocbot-is-collapsible',
  368. scrollSmooth : true,
  369. includeTitleTags: true,
  370. headingsOffset : -boardTop,
  371. }, CONFIG.toc));
  372. if (toc.find('.toc-list-item').length > 0) {
  373. toc.css('visibility', 'visible');
  374. }
  375. Fluid.events.registerRefreshCallback(function() {
  376. if ('tocbot' in window) {
  377. tocbot.refresh();
  378. var toc = jQuery('#toc');
  379. if (toc.length === 0 || !tocbot) {
  380. return;
  381. }
  382. if (toc.find('.toc-list-item').length > 0) {
  383. toc.css('visibility', 'visible');
  384. }
  385. }
  386. });
  387. });
  388. </script>
  389. <script src=https://lib.baomitu.com/clipboard.js/2.0.11/clipboard.min.js></script>
  390. <script>Fluid.plugins.codeWidget();</script>
  391. <script>
  392. Fluid.utils.createScript('https://jscdn.limour.top/npm/anchor-js@4.3.1/anchor.min.js', function() {
  393. window.anchors.options = {
  394. placement: CONFIG.anchorjs.placement,
  395. visible : CONFIG.anchorjs.visible
  396. };
  397. if (CONFIG.anchorjs.icon) {
  398. window.anchors.options.icon = CONFIG.anchorjs.icon;
  399. }
  400. var el = (CONFIG.anchorjs.element || 'h1,h2,h3,h4,h5,h6').split(',');
  401. var res = [];
  402. for (var item of el) {
  403. res.push('.markdown-body > ' + item.trim());
  404. }
  405. if (CONFIG.anchorjs.placement === 'left') {
  406. window.anchors.options.class = 'anchorjs-link-left';
  407. }
  408. window.anchors.add(res.join(', '));
  409. Fluid.events.registerRefreshCallback(function() {
  410. if ('anchors' in window) {
  411. anchors.removeAll();
  412. var el = (CONFIG.anchorjs.element || 'h1,h2,h3,h4,h5,h6').split(',');
  413. var res = [];
  414. for (var item of el) {
  415. res.push('.markdown-body > ' + item.trim());
  416. }
  417. if (CONFIG.anchorjs.placement === 'left') {
  418. anchors.options.class = 'anchorjs-link-left';
  419. }
  420. anchors.add(res.join(', '));
  421. }
  422. });
  423. });
  424. </script>
  425. <script>
  426. Fluid.utils.createScript('https://lib.baomitu.com/fancybox/3.5.7/jquery.fancybox.min.js', function() {
  427. Fluid.plugins.fancyBox();
  428. });
  429. </script>
  430. <script>Fluid.plugins.imageCaption();</script>
  431. <script src="/js/local-search.js" ></script>
  432. <!-- 主题的启动项,将它保持在最底部 -->
  433. <!-- the boot of the theme, keep it at the bottom -->
  434. <script src="/js/boot.js" ></script>
  435. <noscript>
  436. <div class="noscript-warning">Blog works best with JavaScript enabled</div>
  437. </noscript>
  438. <!-- hexo injector body_end start -->
  439. <script defer src="/theme-inject/timeliness.js"></script>
  440. <!-- hexo injector body_end end --></body>
  441. </html>