{"id":1830,"date":"2023-09-22T10:51:25","date_gmt":"2023-09-22T02:51:25","guid":{"rendered":"https:\/\/white-night.club\/?p=1830"},"modified":"2023-11-09T11:07:52","modified_gmt":"2023-11-09T03:07:52","slug":"appdev11","status":"publish","type":"post","link":"https:\/\/white-night.club\/index.php\/2023\/09\/22\/appdev11\/","title":{"rendered":"APK\u7684\u53cd\u7f16\u8bd1\uff0c\u7b7e\u540d\uff0c\u5bf9\u9f50"},"content":{"rendered":"\n<p>\u8bb0\u5f55\u4e0b\u76f8\u5173\u7684\u547d\u4ee4\u884c\u53c2\u6570\u3002<\/p>\n\n\n\n<div style=\"height:60px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<blockquote class=\"wp-block-quote has-luminous-vivid-amber-color has-text-color\">\n<p>APK\u7684\u6253\u5305\u4e0e\u89e3\u5305<\/p>\n<cite><em>java -jar apktool.jar<\/em><\/cite><\/blockquote>\n\n\n\n<p>\u9996\u5148\uff0c\u9700\u8981\u4e00\u4e2ajar\u5305\uff0c\u4ee5\u6211\u5728\u7528\u7684\u4e3a\u4f8b\uff1aapktool_2.8.1.jar\u3002\u5e76\u4e14\u4f60\u7684\u673a\u5b50\u8981\u6709java\u73af\u5883\u3002\u4e3a\u4e86\u65b9\u4fbf\u64cd\u4f5c\uff0c\u6211\u628a\u6240\u6709\u9700\u8981\u7528\u5230\u7684\u5de5\u5177\u90fd\u653e\u540c\u4e00\u4e2a\u6587\u4ef6\u5939\u5185\uff0c\u8fd9\u91cc\u5148\u653e\u4e0a\u96c6\u9f50\u4e86\u4e09\u76f8\u4e4b\u529b\uff08apktool\uff0capksigner\uff0czipalign\uff09\u7684\u56fe\u7247<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full is-resized has-custom-border\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/white-night.club\/wp-content\/uploads\/2023\/09\/716804355c989030859e3542a8fa558.png\" alt=\"\" class=\"wp-image-1838\" style=\"border-style:none;border-width:0px;border-radius:0px\" width=\"470\" height=\"147\" srcset=\"https:\/\/white-night.club\/wp-content\/uploads\/2023\/09\/716804355c989030859e3542a8fa558.png 470w, https:\/\/white-night.club\/wp-content\/uploads\/2023\/09\/716804355c989030859e3542a8fa558-300x94.png 300w\" sizes=\"(max-width: 470px) 100vw, 470px\" \/><\/figure>\n\n\n\n<p>\u518d\u6765\u8bf4\u4e0b\u524d\u60c5\u63d0\u8981\uff1a\u6211\u5df2\u7ecf\u53d7\u591f\u4e86\u67d0\u4e9b\u5e94\u7528\u7684\u5f00\u673a\u6447\u4e00\u6447\u5e7f\u544a\uff0c\u8fd8\u6709\u90a3\u79cd\u628a\u201c\u00d7\u201d\u653e\u7684\u5947\u5c0f\u65e0\u6bd4\u7684\u5751\u4eba\u5e7f\u544a\u3002\u6240\u4ee5\u5c31\u5f00\u59cb\u81ea\u5b66Android\u7684\u53cd\u7f16\u8bd1\u3002<\/p>\n\n\n\n<p>\u5176\u4e2d\uff0c\u5047\u8bbe\u8981\u5bf9demo.apk\u89e3\u5305\uff0c\u90a3\u4e48\u9700\u8981\u7528\u5230\u8be5\u6307\u4ee4\uff08CMD\uff09\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>java -jar apktool_2.8.1.jar d demo.apk -o test<\/code><\/pre>\n\n\n\n<p>\u89e3\u5305\u5b8c\u6210\u540e\uff0c\u5728test\u6587\u4ef6\u5939\u4e2d\u5c31\u80fd\u770b\u5230\u53cd\u7f16\u8bd1\u7684\u7ed3\u679c\u4e86\u3002\u5982\u679c\u53cd\u8fc7\u6765\uff0c\u628a\u53cd\u7f16\u8bd1\u7684APK\u91cd\u65b0\u6253\u5305\u56de\u53bb\u7684\u8bdd\uff0c\u9700\u8981\u7528\u5230\u4ee5\u4e0b\u6307\u4ee4\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>java -jar apktool_2.8.1.jar b test -o demo_repackage.apk<\/code><\/pre>\n\n\n\n<p>\u4e0d\u8fc7\u8fd9\u4e48\u505a\u8fd8\u4e0d\u591f\uff0c\u8981\u60f3\u5728\u624b\u673a\u4e0a\u5b89\u88c5\u91cd\u6253\u5305\u7684apk\u8fd8\u9700\u8981\u8fdb\u884c\u7b7e\u540d\u3002<\/p>\n\n\n\n<div style=\"height:60px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<blockquote class=\"wp-block-quote has-luminous-vivid-amber-color has-text-color\">\n<p>APK\u7684\u5bf9\u9f50<\/p>\n<cite><em>zipalign<\/em><\/cite><\/blockquote>\n\n\n\n<p>\u5728\u7b7e\u540d\u4e4b\u524d\uff0c\u5efa\u8bae\u4e0b\u4e2aAndroid Studio\uff0c\u8ddf\u7740\u7f51\u4e0a\u6b65\u9aa4\u5b89\u88c5\u5c31\u884c\u3002\u4e0d\u8fc7\u5b89\u88c5SDK\u7684\u65f6\u5019\u8bb0\u5f97\u7ffb\u5899\uff0c\u4e0d\u7136\u5927\u6982\u7387\u4e0b\u8f7d\u5931\u8d25\u3002<\/p>\n\n\n\n<p>\u5728\u7b7e\u540d\u4e4b\u524d\uff0cAPK\u8fd8\u9700\u8981\u5bf9\u9f50\uff0c\u4e0d\u7136\u5728Android 11\u53ca\u4ee5\u4e0a\u7684\u7248\u672c\u4f1a\u88c5\u4e0d\u4e0a\u62a5\u9519\u3002\u5bf9\u9f50\u7684\u8bdd\u5219\u9700\u8981\u7528\u5230zipalign\u3002\u8fd9\u4e1c\u897f\u5728\u5b89\u88c5Android Studio\u7684\u65f6\u5019\u5c31\u4f1a\u81ea\u5e26\u5728build_tool\u6587\u4ef6\u5939\u4e0b\u3002<\/p>\n\n\n\n<p>\u5bf9\u9f50apk\u7684\u8bdd\u8981\u7528\u5230\u8be5\u6307\u4ee4\uff0c<mark style=\"background-color:rgba(0, 0, 0, 0);color:#fcb900\" class=\"has-inline-color\">\u5982\u679c\u5bf9\u5df2\u7ecf\u6709\u7b7e\u540d\u7684apk\u5bf9\u9f50\u7684\u8bdd\uff0c\u8bb0\u5f97\u91cd\u65b0\u6253\u4e00\u6b21\u7b7e\u540d<\/mark>\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>zipalign -f -v 4 infile.apk outfile.apk\nzipalign -c -v 4 outfile.apk <mark style=\"background-color:rgba(0, 0, 0, 0);color:#00ff2f\" class=\"has-inline-color\">\/\/\u67e5\u770bAPK\u662f\u5426\u5bf9\u9f50<\/mark><\/code><\/pre>\n\n\n\n<div style=\"height:60px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<blockquote class=\"wp-block-quote has-luminous-vivid-amber-color has-text-color\">\n<p>APK\u7684\u7b7e\u540d<\/p>\n<cite><em>apksign\u4e0ekeytool<\/em><\/cite><\/blockquote>\n\n\n\n<p>\u8981\u7b7e\u540d\u7684\u8bdd\uff0c\u9700\u8981\u7528\u5230keytool\u548capksigner\u3002\u524d\u8005\u5728\u5b89\u88c5java\u73af\u5883\u7684\u65f6\u5019\u4e00\u822c\u6765\u8bf4\u4f1a\u81ea\u5e26\uff0c\u53ef\u4ee5CMD\u8f93\u5165keytool\u770b\u770b\u80fd\u4e0d\u80fd\u6b63\u5e38\u8fd0\u884c\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large has-custom-border\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"511\" src=\"https:\/\/white-night.club\/wp-content\/uploads\/2023\/09\/816d0cc35d154bb5267180785da7311-1024x511.png\" alt=\"\" class=\"wp-image-1834\" style=\"border-style:none;border-width:0px;border-radius:0px\" srcset=\"https:\/\/white-night.club\/wp-content\/uploads\/2023\/09\/816d0cc35d154bb5267180785da7311-1024x511.png 1024w, https:\/\/white-night.club\/wp-content\/uploads\/2023\/09\/816d0cc35d154bb5267180785da7311-300x150.png 300w, https:\/\/white-night.club\/wp-content\/uploads\/2023\/09\/816d0cc35d154bb5267180785da7311-768x384.png 768w, https:\/\/white-night.club\/wp-content\/uploads\/2023\/09\/816d0cc35d154bb5267180785da7311-1536x767.png 1536w, https:\/\/white-night.club\/wp-content\/uploads\/2023\/09\/816d0cc35d154bb5267180785da7311.png 1600w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>\u800c\u540e\u8005\u5728\u5b89\u88c5java\u73af\u5883\u7684\u65f6\u5019\u53ef\u80fd\u81ea\u5e26\uff0c\u4e5f\u53ef\u80fd\u6ca1\u6709\u3002\u6211\u5c31\u5c5e\u4e8e\u540e\u8005\u3002\u4f46\u8fd9\u4e2a\u5de5\u5177\u5728Android Studio\u91cc\u5934\u5b89\u88c5SDK\u7684\u65f6\u5019\u81ea\u5e26\u4e86\uff0c\u8def\u5f84\u4e00\u822c\u4e3a\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\uff08\u4f60\u9009\u62e9\u5b89\u88c5SDK\u7684\u6587\u4ef6\u5939\uff09\\build-tools\\34.0.0\\lib<\/code><\/pre>\n\n\n\n<p>\u800c\u751f\u6210\u7b7e\u540d\uff0c\u9700\u8981\u5148\u901a\u8fc7keytool\u751f\u6210\u7b7e\u540d\u6587\u4ef6.keystore\u3002\u6bd4\u5982\u8fd9\u91cc\u751f\u6210\u4e86\u4e00\u4e2a\u5bc6\u94a5\u5e93\u5bc6\u7801\u4e3a123456\uff08\u8be5\u5bc6\u7801\u6700\u5c11\u8981\u516d\u4f4d\uff0c\u4e5f\u53ef\u4ee5\u81ea\u5df1\u8bbe\u7f6e\uff09\u7684\u7b7e\u540d\u6587\u4ef6\uff0c\u8fd9\u4e2a\u5bc6\u7801\u540e\u9762\u8fd8\u8981\u7528\u5230\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>keytool -genkey -v -keystore adam.keystore -alias adam -storepass 123456 -keypass 123456 -keyalg RSA -validity 36000<\/code><\/pre>\n\n\n\n<p>\u63a5\u4e0b\u6765\u5c31\u662f\u901a\u8fc7apksigner\u7ed9apk\u7b7e\u540d\u4e86<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>apksigner sign --ks adam.keystore --ks-key-alias adam demo_repackage.apk<\/code><\/pre>\n\n\n\n<p>\u7b7e\u5b8c\u540d\u540e\u5c31\u53ef\u4ee5\u6254\u56de\u624b\u673a\u4e86\uff0c\u80fd\u5b89\u88c5\u5c31\u7b97OK\u3002<\/p>\n\n\n\n<blockquote class=\"wp-block-quote has-vivid-cyan-blue-color has-text-color\">\n<p>\u5199\u8005\u6ce8<\/p>\n<cite>\u6709\u7684APK\u5728\u53cd\u7f16\u8bd1\u524d\uff0c\u5efa\u8bae\u5148\u6254\u8fdb\u6a21\u62df\u5668\u6216\u8005\u865a\u62df\u673a\u91cc\u770b\u770b\u80fd\u4e0d\u80fd\u8dd1\u3002\u6bd4\u5982\u6211\u5728\u5f04\u7684\u8fd9\u4e2aA.apk\uff0c\u6254\u8fdb\u6a21\u62df\u5668\u672c\u8eab\u5c31\u65e0\u6cd5\u542f\u52a8\uff0c\u53ea\u80fd\u6254\u8fdb\u771f\u673a\u73af\u5883\u91cc\u9762\u8dd1\u3002\u641e\u5f97\u6211\u8fd8\u4ee5\u4e3a\u662f\u6211\u53cd\u7f16\u8bd1\u54ea\u4e00\u6b65\u51fa\u9519\u4e86\u3002<\/cite><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>apksigner\uff0capktool\uff0czipalig<\/p>\n","protected":false},"author":1,"featured_media":1838,"comment_status":"open","ping_status":"","sticky":false,"template":"base","format":"standard","meta":{"footnotes":""},"categories":[81,51],"tags":[82,54],"_links":{"self":[{"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/posts\/1830"}],"collection":[{"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/comments?post=1830"}],"version-history":[{"count":0,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/posts\/1830\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/media\/1838"}],"wp:attachment":[{"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/media?parent=1830"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/categories?post=1830"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/tags?post=1830"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}