{"id":10005979,"date":"2022-07-22T11:57:13","date_gmt":"2022-07-22T03:57:13","guid":{"rendered":"https:\/\/ityet.com\/?p=10005979"},"modified":"2022-07-22T11:57:13","modified_gmt":"2022-07-22T03:57:13","slug":"%e5%8f%aa%e7%94%a8-1-%e5%88%86%e9%92%9f-%e8%b6%85%e7%ae%80%e6%9e%81%e9%80%9f-apk-%e7%ad%be%e5%90%8d-%e5%a4%9a%e6%b8%a0%e9%81%93%e6%89%93%e5%8c%85%e7%a5%9e%e5%99%a8","status":"publish","type":"post","link":"https:\/\/itmax.cn\/?p=10005979","title":{"rendered":"\u201d \u53ea\u7528 1 \u5206\u949f \u201c- \u8d85\u7b80\u6781\u901f Apk \u7b7e\u540d &amp; \u591a\u6e20\u9053\u6253\u5305\u795e\u5668"},"content":{"rendered":"<p>\u4f17\u6240\u5468\u77e5\uff0c\u6e20\u9053\u5305\u4f5c\u4e3a\u5f53\u4e0b\u56fd\u5185 Android \u5e94\u7528\u5e02\u573a\u5e38\u89c1\u7684\u5206\u53d1\u65b9\u5f0f\uff0c\u5f53 APP \u548c\u540e\u53f0\u4ea4\u4e92\u6216\u8fdb\u884c\u6570\u636e\u4e0a\u62a5\u65f6\uff0c\u4f1a\u5e26\u4e0a\u5404\u81ea\u7684 channel \u6e20\u9053\u4fe1\u606f\uff0c\u4ee5\u6b64\u65b9\u4fbf\u4f01\u4e1a &#038; \u5f00\u53d1\u8005\u7edf\u8ba1 APP \u5728\u5404\u6e20\u9053\u7684\u4e0b\u8f7d\u91cf\u3001\u7528\u6237\u91cf\u3001\u7559\u5b58\u7387\u7b49\u5173\u952e\u6d3b\u8dc3\u6570\u636e\uff0c\u5e76\u9488\u5bf9\u6027\u7684\u8c03\u6574\u5e94\u7528\u5185\u5bb9\u548c\u63a8\u5e7f\u65b9\u6848\u3002\u800c Android \u5e94\u7528\u5e02\u573a\u5b58\u5728\u5927\u5927\u5c0f\u5c0f\u51e0\u767e\u4e2a\u5546\u5e97\uff0c\u6bcf\u5f53\u9700\u8981\u53d1\u5e03 APP \u6216\u8fed\u4ee3\u65b0\u7248\u672c\uff0c\u5f80\u5f80\u9700\u8981\u5f00\u53d1\u8005\u751f\u6210\u591a\u4e2a\u6e20\u9053\u5305\u6216\u662f\u5728\u5404\u5e94\u7528\u5e02\u573a\u91cd\u65b0\u5206\u53d1\uff0c\u4e14\u5b98\u65b9\u63d0\u4f9b\u7684 ProductFlavor \u591a\u6e20\u9053\u6253\u5305\u5de5\u5177\uff0c\u5bf9\u4e8e\u6bcf\u4e00\u4e2a\u6e20\u9053\u5305\uff0c\u90fd\u9700\u8981\u8fdb\u884c\u4e00\u6b21\u5b8c\u6574\u7684 APK \u6253\u5305\u8fc7\u7a0b\uff0c\u5bf9\u4e8e\u6ce8\u91cd\u6548\u7387\u7684\u5f00\u53d1\u8005\u800c\u8a00\u6574\u4e2a\u73af\u8282\u5176\u5b9e\u76f8\u5f53\u8017\u65f6\uff0c\u662f\u5426\u6709\u66f4\u597d\u7684\u591a\u6e20\u9053\u7b7e\u540d\u6253\u5305\u65b9\u6848\u5462\uff1f    <\/p>\n<p>\u8fd1\u671f\uff0c\u9876\u8c61\u6280\u672f\u56e2\u961f\u5f00\u6e90\u4e86\u81ea\u5df1\u7684 Android apk \u6253\u5305\u5de5\u5177\uff0c\u7cbe\u7b80\uff0c\u9ad8\u6548\uff0c\u5e94\u7528\u5f00\u53d1\u8005\u9700\u8981\u7684\u591a\u6e20\u9053\u6253\u5305\u795e\u5668\u6765\u4e86\uff01<\/p>\n<p>Github\u5730\u5740\uff1a<a href=\"https:\/\/link.segmentfault.com\/?enc=63GyLbPXpa9%2FuZuH6I2K1A%3D%3D.%2F%2BpMRpthKXz%2Bo3BiSVoovmmRLT5eKUsZfdRuNpVZ%2Ficc1lp5zSBhjBUwR6RNrahW\" rel=\"nofollow\">https:\/\/github.com\/dingxiangt&#8230;<\/a><\/p>\n<h2>\u9876\u8c61 Apk \u7b7e\u540d\u548c\u591a\u6e20\u9053\u6253\u5305\u5de5\u5177<\/h2>\n<p>\u4e0b\u8f7d\u540e\u7684\u5305\u5185\u6587\u4ef6\uff1a<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVc0jEh\" alt=\"\" title=\"\" loading=\"lazy\" ><\/p>\n<h4><strong>\u4e00\uff0e\u7b7e\u540d\u529f\u80fd\u7b80\u4ecb<\/strong><\/h4>\n<p><strong>\u6211\u4eec\u5148\u6765\u770b\u770b V1 \u548c V2 \u7b7e\u540d\u7684\u533a\u522b\uff1a<\/strong><\/p>\n<p>\u5728 Android Studio \u4e2d\u70b9\u51fb\u83dc\u5355 Build-&gt;Generate signed apk&#8230; \u6253\u5305\u7b7e\u540d\u6709\u4e24\u79cd\u7b7e\u540d\u9009\u9879 V1 (Jar Signature) V2 (Full APK Signature),<em>*<\/em>*<\/p>\n<p>\u4ece Android 7.0 \u5f00\u59cb\uff0c\u8c37\u6b4c\u589e\u52a0\u65b0\u7b7e\u540d\u65b9\u6848 V2 Scheme (APK Signature);<\/p>\n<p>\u4f46 Android 7.0 \u4ee5\u4e0b\u7248\u672c\uff0c\u53ea\u80fd\u7528\u65e7\u7b7e\u540d\u65b9\u6848 V1 scheme (JAR signing)<\/p>\n<p>V1 \u7b7e\u540d:<\/p>\n<ul>\n<li>\u6765\u81ea JDK (jarsigner), \u5bf9 zip \u538b\u7f29\u5305\u7684\u6bcf\u4e2a\u6587\u4ef6\u8fdb\u884c\u9a8c\u8bc1\uff0c\u7b7e\u540d\u540e\u8fd8\u80fd\u5bf9\u538b\u7f29\u5305\u4fee\u6539 (\u79fb\u52a8 \/ \u91cd\u65b0\u538b\u7f29\u6587\u4ef6)<\/li>\n<li>\u5bf9 V1 \u7b7e\u540d\u7684 apk\/jar \u89e3\u538b\uff0c\u5728 META-INF \u5b58\u653e\u7b7e\u540d\u6587\u4ef6 (MANIFEST.MF, CERT.SF, CERT.RSA),<\/li>\n<li>\u5176\u4e2d MANIFEST.MF \u6587\u4ef6\u4fdd\u5b58\u6240\u6709\u6587\u4ef6\u7684 SHA1 \u6307\u7eb9 (\u9664\u4e86 META-INF \u6587\u4ef6), \u7531\u6b64\u53ef\u77e5: V1 \u7b7e\u540d\u662f\u5bf9\u538b\u7f29\u5305\u4e2d\u5355\u4e2a\u6587\u4ef6\u7b7e\u540d\u9a8c\u8bc1<\/li>\n<\/ul>\n<p>V2 \u7b7e\u540d:<\/p>\n<ul>\n<li>\u6765\u81ea Google (apksigner), \u5bf9 zip \u538b\u7f29\u5305\u7684\u6574\u4e2a\u6587\u4ef6\u9a8c\u8bc1\uff0c\u7b7e\u540d\u540e\u4e0d\u80fd\u4fee\u6539\u538b\u7f29\u5305 (\u5305\u62ec zipalign),<\/li>\n<li>\u5bf9 V2 \u7b7e\u540d\u7684 apk \u89e3\u538b\uff0c\u6ca1\u6709\u53d1\u73b0\u7b7e\u540d\u6587\u4ef6\uff0c\u91cd\u65b0\u538b\u7f29\u540e V2 \u7b7e\u540d\u5c31\u5931\u6548\uff0c\u7531\u6b64\u53ef\u77e5: V2 \u7b7e\u540d\u662f\u5bf9\u6574\u4e2a APK \u7b7e\u540d\u9a8c\u8bc1<\/li>\n<\/ul>\n<p>V2 \u7b7e\u540d\u4f18\u70b9\u5f88\u660e\u663e:<\/p>\n<ul>\n<li>\u7b7e\u540d\u66f4\u5b89\u5168 (\u4e0d\u80fd\u4fee\u6539\u538b\u7f29\u5305)<\/li>\n<li>\u7b7e\u540d\u9a8c\u8bc1\u65f6\u95f4\u66f4\u77ed (\u4e0d\u9700\u8981\u89e3\u538b\u9a8c\u8bc1), \u56e0\u800c\u5b89\u88c5\u901f\u5ea6\u52a0\u5feb<\/li>\n<\/ul>\n<p>\u9876\u8c61 apk \u7b7e\u540d\u5de5\u5177\u9ed8\u8ba4\u540c\u65f6\u4f7f\u7528 V1+V2 \u7b7e\u540d\u65b9\u5f0f\uff0c\u7528\u4e8e\u5bf9 android \u52a0\u56fa\u540e\u7684 apk \u8fdb\u884c\u91cd\u65b0\u7b7e\u540d\u3002<\/p>\n<p><strong>\u542f\u7528\u5de5\u5177\u754c\u9762\uff1a<\/strong><\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVc0jEm\" alt=\"\" title=\"\" loading=\"lazy\" ><\/p>\n<p><strong>\u4f7f\u7528\u8bf4\u660e\uff1a<\/strong><\/p>\n<ul>\n<li>\u4e0b\u8f7d\u9876\u8c61\u7b7e\u540d\u5de5\u5177 dx-signer.jar\uff0c\u53cc\u51fb\u8fd0\u884c\u3002<\/li>\n<li>\u9009\u62e9\u8f93\u5165 apk\u3001aab \u6587\u4ef6\u3002<\/li>\n<li>\u9009\u62e9\u7b7e\u540d\u7684 key \u6587\u4ef6\uff0c\u5e76\u8f93\u5165 key \u5bc6\u7801\u3002<\/li>\n<li>\u9009\u62e9\u91cd\u7b7e\u540e apk\u3001aab \u7684\u8def\u5f84\uff0c\u4ee5 apk \u7ed3\u675f\u3002\u5982\uff1aD:\/sign.apk<\/li>\n<li>\u70b9\u51fb \u201c\u7b7e\u540d\u201d \u6309\u94ae\uff0c\u7b49\u5f85\u5373\u53ef\u7b7e\u540d\u5b8c\u6210\u3002<\/li>\n<\/ul>\n<p>ps: \u5982\u679c\u6709 alias\uff08\u8bc1\u4e66\u522b\u540d\uff09\u5bc6\u94a5\u7684\u6216\u8005\u6709\u591a\u4e2a\u8bc1\u4e66\u7684\uff0c\u8bf7\u5728\u9ad8\u7ea7 tab \u4e2d\u9009\u62e9 alias \u5e76\u8f93\u5165 alias \u5bc6\u7801<\/p>\n<p><strong>\u547d\u4ee4\u884c\u754c\u9762\uff1a<\/strong><\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVc0jEZ\" alt=\"\" title=\"\" loading=\"lazy\" ><\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVc0jE0\" alt=\"\" title=\"\" loading=\"lazy\" ><\/p>\n<p>\u652f\u6301\u7684 option \u5982\u4e0b\uff1a<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVc0jFc\" alt=\"\" title=\"\" loading=\"lazy\" ><\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVc0jF3\" alt=\"\" title=\"\" loading=\"lazy\" ><\/p>\n<p>\u4f8b\u5982\uff1a<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVc0jF6\" alt=\"\" title=\"\" loading=\"lazy\" ><\/p>\n<h3><strong>\u4e8c\uff0e\u591a\u6e20\u9053\u529f\u80fd\u7b80\u4ecb<\/strong><\/h3>\n<p>\u9876\u8c61\u591a\u6e20\u9053\u5de5\u5177\u517c\u5bb9\u53cb\u76df\u548c\u7f8e\u56e2 walle \u98ce\u683c\u7684\u591a\u6e20\u9053\u5305\uff0c\u65b9\u4fbf\u5ba2\u6237\u628a APP \u53d1\u5e03\u5230\u4e0d\u540c\u7684\u5e94\u7528\u5e73\u53f0\uff0c\u8fdb\u884c\u6e20\u9053\u7edf\u8ba1\u3002<br \/><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVc0jGs\" alt=\"\" title=\"\" loading=\"lazy\" ><\/p>\n<p><strong>\u4f7f\u7528\u8bf4\u660e\uff1a<\/strong><\/p>\n<ul>\n<li>\u5728 app \u4e2d\u9884\u7559\u8bfb\u53d6\u6e20\u9053\u4fe1\u606f\u7684\u5165\u53e3\uff0c\u5177\u4f53\u89c1\u8bfb\u53d6\u6e20\u9053\u4fe1\u606f<\/li>\n<li>\u5728\u7b7e\u540d\u4f7f\u7528\u57fa\u7840\u4e0a\uff0c\u70b9\u51fb\u9009\u62e9\u6e20\u9053\u6e05\u5355<\/li>\n<li>\u9009\u62e9\u6e05\u5355\u6587\u4ef6 channel.txt\u3002\u5177\u4f53\u6587\u4ef6\u683c\u5f0f\u89c1\u6e20\u9053\u683c\u5f0f\u6587\u4ef6\u8bf4\u660e<\/li>\n<li>\u70b9\u51fb\u7b7e\u540d\uff0c\u7b49\u5f85\u751f\u6210\u591a\u4e2a\u5e26\u7b7e\u540d\u7684\u6e20\u9053 app<\/li>\n<\/ul>\n<p><strong>\u8bfb\u53d6\u6e20\u9053\u4fe1\u606f<\/strong><\/p>\n<p>\u9876\u8c61\u591a\u6e20\u9053\u5de5\u5177\u517c\u5bb9\u53cb\u76df\u548c\u7f8e\u56e2 walle \u98ce\u683c\u7684\u591a\u6e20\u9053\u5305\uff0c\u4e0b\u9762\u662f\u4e24\u79cd\u4e0d\u540c\u98ce\u683c\u7684\u6e20\u9053\u4fe1\u606f\u8bfb\u53d6\u65b9\u6cd5\u3002\u9009\u5176\u4e2d\u4e4b\u4e00\u5373\u53ef\u3002<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVc0jGH\" alt=\"\" title=\"\" loading=\"lazy\" ><\/p>\n<p>\u60a8\u53ef\u4ee5\u8bfb\u53d6\u8fd9\u4e2a\u5b57\u6bb5\u3002<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVc0jGK\" alt=\"\" title=\"\" loading=\"lazy\" ><\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVc0jGQ\" alt=\"\" title=\"\" loading=\"lazy\" ><\/p>\n<p><strong>\u6e20\u9053\u6587\u4ef6\u683c\u5f0f\u8bf4\u660e<\/strong><\/p>\n<p>\u8bf7\u51c6\u5907\u6e20\u9053\u6e05\u5355\u6587\u4ef6 channel.txt\uff0c \u683c\u5f0f\u4e3a\u6bcf\u4e00\u884c\u4e00\u4e2a\u6e20\u9053\uff0c \u4f8b\u5982\uff1a<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVc0jG0\" alt=\"\" title=\"\" loading=\"lazy\" ><\/p>\n<h3><strong>License<\/strong><\/h3>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVc0jG1\" alt=\"\" title=\"\" loading=\"lazy\" ><\/p>\n<h3><strong>\u4e09\uff0e\u5e38\u89c1\u95ee\u9898\uff1a<\/strong><\/h3>\n<p><strong>\u5173\u4e8e app \u7b7e\u540d\uff1a<\/strong><\/p>\n<p>Q: app \u7b7e\u540d\u662f\u4ec0\u4e48\uff1f<\/p>\n<p>A: \u7b7e\u540d\u5c31\u662f\u7528\u4e8e\u8bc6\u522b app \u5f00\u53d1\u8005\uff0c\u5e76\u4fdd\u8bc1 apk \u5b8c\u6574\u6027\u7684\u4e00\u4e2a\u673a\u5236\uff0c\u8c37\u6b4c\u8981\u6c42\u6bcf\u4e00\u4e2a app \u90fd\u9700\u8981\u6709\u7b7e\u540d\u3002<\/p>\n<p>Q: \u4e3a\u4ec0\u4e48\u4e0a\u4f20\u7684 app \u9700\u8981\u6709\u7b7e\u540d\uff1f<\/p>\n<p>A: \u52a0\u56fa\u6709\u9632\u4e8c\u6b21\u6253\u5305\u7684\u529f\u80fd\uff0c\u9700\u8981\u63d0\u524d apk \u539f\u672c\u7684\u7b7e\u540d\uff0c\u4f9b\u52a0\u56fa\u540e\u9a8c\u8bc1\u7b7e\u540d\u6b63\u786e\u6027\u7528\u3002<\/p>\n<p>Q: \u5728 androidstudio \u4e2d\u6253\u51fa\u7684 debug \u7248\u672c\u5305\uff0c\u53ef\u4ee5\u52a0\u56fa\u5417\uff1f<\/p>\n<p>A: \u4e0d\u5efa\u8bae\u7528 debug \u7248\u672c\u5305\u52a0\u56fa\uff0c\u56e0\u4e3a debug \u7248\u672c\u7684\u5305\u4f7f\u7528\u7684\u662f androidstudio \u7684 debug \u7b7e\u540d\uff0c\u53ef\u80fd\u5bfc\u81f4\u52a0\u56fa\u540e\u65e0\u6cd5\u91cd\u7b7e\u540d\uff0c\u6216\u8005\u7b7e\u9519\u540d\u7684\u60c5\u51b5\u3002\u5bfc\u81f4\u65e0\u6cd5\u6b63\u5e38\u8fd0\u884c\u3002<\/p>\n<p><strong>\u5173\u4e8e\u52a0\u56fa\u540e\u91cd\u7b7e\u540d\uff1a<\/strong><\/p>\n<p>Q: \u4e0a\u4f20\u4e4b\u524d apk \u5df2\u7ecf\u7b7e\u8fc7\u540d\u4e86\uff0c\u4e3a\u4ec0\u4e48\u52a0\u56fa\u540e\u53c8\u8981\u91cd\u65b0\u7b7e\u4e00\u6b21\uff1f<\/p>\n<p>A: \u52a0\u56fa\u4e4b\u540e\u4f1a\u7834\u574f apk \u539f\u6709\u7684\u7b7e\u540d\uff0c\u6240\u4ee5\u9700\u8981\u91cd\u65b0\u7b7e\u540d\uff0c\u5426\u5219\u65e0\u6cd5\u5b89\u88c5\u3002<\/p>\n<p>Q: \u4e3a\u4ec0\u4e48\u91cd\u7b7e\u540d\u9700\u8981\u548c\u52a0\u56fa\u524d\u4fdd\u6301\u4e00\u81f4\uff1f<\/p>\n<p>A: \u5982\u679c\u4e0d\u4fdd\u6301\u4e00\u81f4\uff0c\u5219\u4f1a\u89e6\u53d1\u52a0\u56fa\u7684\u9632\u4e8c\u6b21\u6253\u5305\u529f\u80fd\uff0c\u65e0\u6cd5\u6b63\u5e38\u8fd0\u884c\u3002<\/p>\n<p><a href=\"https:\/\/segmentfault.com\/a\/1190000041982373\">https:\/\/segmentfault.com\/a\/1190000041982373<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4f17\u6240\u5468\u77e5\uff0c\u6e20\u9053\u5305\u4f5c\u4e3a\u5f53\u4e0b\u56fd\u5185 Android \u5e94\u7528\u5e02\u573a\u5e38\u89c1\u7684\u5206\u53d1\u65b9\u5f0f\uff0c\u5f53 APP \u548c\u540e\u53f0\u4ea4\u4e92\u6216\u8fdb\u884c\u6570\u636e\u4e0a\u62a5\u65f6\uff0c [&hellip;]<\/p>\n","protected":false},"author":0,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[],"tags":[],"class_list":["post-10005979","post","type-post","status-publish","format-standard","hentry"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts\/10005979","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"replies":[{"embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=10005979"}],"version-history":[{"count":0,"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts\/10005979\/revisions"}],"wp:attachment":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=10005979"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=10005979"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=10005979"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}