{"id":2147,"date":"2023-08-07T15:08:47","date_gmt":"2023-08-07T07:08:47","guid":{"rendered":"https:\/\/www.yimenyun.cn\/emen\/?p=2147"},"modified":"2023-08-07T15:08:47","modified_gmt":"2023-08-07T07:08:47","slug":"android%e5%88%b6%e4%bd%9capk%e6%93%8d%e4%bd%9c%e6%ad%a5%e9%aa%a4%e8%af%b4%e6%98%8e","status":"publish","type":"post","link":"https:\/\/www.yimenyun.cn\/emen\/2147\/","title":{"rendered":"android\u5236\u4f5capk\u64cd\u4f5c\u6b65\u9aa4\u8bf4\u660e"},"content":{"rendered":"

Android\u5e73\u53f0\u662f\u76ee\u524d\u6700\u6d41\u884c\u7684\u79fb\u52a8\u64cd\u4f5c\u7cfb\u7edf\u4e4b\u4e00\uff0c\u5f00\u53d1\u8005\u53ef\u4ee5\u4f7f\u7528Java\u7b49\u7f16\u7a0b\u8bed\u8a00\u6765\u5f00\u53d1Android\u5e94\u7528\u7a0b\u5e8f\u3002\u5f00\u53d1\u5b8c\u6210\u540e\uff0c\u53ef\u4ee5\u5c06\u5e94\u7528\u7a0b\u5e8f\u6253\u5305\u6210Android\u5b89\u88c5\u5305\uff08APK\uff09\u8fdb\u884c\u53d1\u5e03\u548c\u5b89\u88c5\u3002\u4e0b\u9762\u5c06\u8be6\u7ec6\u4ecb\u7ecdAndroid\u5236\u4f5cAPK\u7684\u539f\u7406\u548c\u6b65\u9aa4\u3002<\/p>\n

1. \u539f\u7406\uff1a<\/p>\n

Android\u5e94\u7528\u7a0b\u5e8f\u7684\u6838\u5fc3\u662f\u7531\u4e00\u7cfb\u5217Java\u7c7b\u6587\u4ef6\u3001\u8d44\u6e90\u6587\u4ef6\u548c\u914d\u7f6e\u6587\u4ef6\u7ec4\u6210\u7684\u3002\u5f53\u5f00\u53d1\u8005\u5c06\u5e94\u7528\u7a0b\u5e8f\u6253\u5305\u6210APK\u540e\uff0c\u5b9e\u9645\u4e0a\u662f\u5c06\u8fd9\u4e9b\u6587\u4ef6\u8fdb\u884c\u538b\u7f29\u548c\u52a0\u5bc6\uff0c\u5e76\u901a\u8fc7Android\u7684\u5b89\u88c5\u7a0b\u5e8f\u8fdb\u884c\u89e3\u6790\u548c\u5b89\u88c5\u3002\u5728\u5b89\u88c5\u8fc7\u7a0b\u4e2d\uff0c\u5b89\u88c5\u7a0b\u5e8f\u4f1a\u81ea\u52a8\u5206\u914d\u4e00\u4e2a\u552f\u4e00\u7684\u5305\u540d\uff08Package Name\uff09\u7ed9\u5e94\u7528\u7a0b\u5e8f\uff0c\u5e76\u5c06\u8be5\u5e94\u7528\u7a0b\u5e8f\u7684\u4fe1\u606f\u5199\u5165\u7cfb\u7edf\u7684\u5e94\u7528\u7a0b\u5e8f\u6e05\u5355\u6587\u4ef6\uff08AndroidManifest.xml\uff09\u4e2d\u3002<\/p>\n

2. \u6b65\u9aa4\uff1a<\/p>\n

\u4e0b\u9762\u662f\u5236\u4f5cAPK\u7684\u8be6\u7ec6\u6b65\u9aa4\uff1a<\/p>\n

\u6b65\u9aa4\u4e00\uff1a\u7f16\u5199\u4ee3\u7801\u548c\u8d44\u6e90\u6587\u4ef6<\/p>\n

\u9996\u5148\uff0c\u4f60\u9700\u8981\u4f7f\u7528Java\u7f16\u5199\u5e94\u7528\u7a0b\u5e8f\u7684\u903b\u8f91\u4ee3\u7801\uff0c\u5305\u62ec\u5404\u79cdActivity\u3001Fragment\u3001Service\u7b49\u7ec4\u4ef6\u7c7b\u7684\u5b9a\u4e49\u548c\u5b9e\u73b0\u3002\u540c\u65f6\uff0c\u4f60\u8fd8\u9700\u8981\u7f16\u5199\u5404\u79cd\u8d44\u6e90\u6587\u4ef6\uff0c\u5305\u62ec\u5e03\u5c40\u6587\u4ef6\u3001\u56fe\u7247\u3001\u97f3\u9891\u7b49\u7b49\u3002<\/p>\n

\u6b65\u9aa4<\/p>\n

<\/figure>\n<\/p>\n

\u4e8c\uff1a\u914d\u7f6e\u6e05\u5355\u6587\u4ef6<\/p>\n

\u5728\u9879\u76ee\u4e2d\u627e\u5230AndroidManifest.xml\u6587\u4ef6\uff0c\u8be5\u6587\u4ef6\u7528\u4e8e\u63cf\u8ff0\u5e94\u7528\u7a0b\u5e8f\u7684\u5404\u79cd\u4fe1\u606f\uff0c\u5305\u62ec\u5e94\u7528\u7a0b\u5e8f\u7684\u540d\u79f0\u3001\u56fe\u6807\u3001\u7248\u672c\u53f7\u7b49\u7b49\u3002\u4f60\u9700\u8981\u5c06\u5176\u4e2d\u7684\u4e00\u4e9b\u914d\u7f6e\u53c2\u6570\u8bbe\u7f6e\u4e3a\u9002\u5f53\u7684\u503c\uff0c\u4ee5\u4fbf\u5728\u5b89\u88c5\u8fc7\u7a0b\u4e2d\u663e\u793a\u6b63\u786e\u7684\u4fe1\u606f\u3002<\/p>\n

\u6b65\u9aa4\u4e09\uff1a\u751f\u6210\u7b7e\u540d\u5bc6\u94a5<\/p>\n

\u4e3a\u4e86\u786e\u4fddAPK\u7684\u5b89\u5168\u6027\uff0c\u4f60\u9700\u8981\u4f7f\u7528Java\u7684keytool\u5de5\u5177\u751f\u6210\u4e00\u4e2a\u7b7e\u540d\u5bc6\u94a5\u3002\u8fd9\u4e2a\u5bc6\u94a5\u5c06\u7528\u4e8e\u5bf9APK\u8fdb\u884c\u7b7e\u540d\uff0c\u4ee5\u4fbf\u9a8c\u8bc1\u5176\u6765\u6e90\u548c\u5b8c\u6574\u6027\u3002\u547d\u4ee4\u884c\u793a\u4f8b\uff1akeytool -genkey -keystore mykey.keystore -alias myalias -keyalg RSA -validity 10000<\/p>\n

\u6b65\u9aa4\u56db\uff1a\u6784\u5efaAPK\u6587\u4ef6<\/p>\n

\u5728\u5f00\u53d1\u73af\u5883\u4e2d\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528Android Studio\u6216Eclipse\u7b49\u96c6\u6210\u5f00\u53d1\u73af\u5883\u6765\u6784\u5efaAPK\u3002\u5728\u6784\u5efa\u8fc7\u7a0b\u4e2d\uff0cIDE\u4f1a\u5c06\u4ee3\u7801\u548c\u8d44\u6e90\u6587\u4ef6\u7f16\u8bd1\u6210Dalvik\u5b57\u8282\u7801\uff0c\u5e76\u5c06\u6240\u6709\u6587\u4ef6\u6253\u5305\u6210\u4e00\u4e2a\u538b\u7f29android apk \u6253\u5305<\/a>\u6587\u4ef6\uff08APK\uff09\u3002<\/p>\n

\u6b65\u9aa4\u4e94\uff1a\u7b7e\u540dAPK\u6587\u4ef6<\/p>\n

\u4f7f\u7528\u4e4b\u524d\u751f\u6210\u7684\u7b7e\u540d\u5bc6\u94a5\u5bf9APK\u8fdb\u884c\u7b7e\u540d\u3002\u547d\u4ee4\u884c\u793a\u4f8b\uff1ajarsigner -verbose -keystore mykey.keystore -signedjar myapp_signed.apk myapp_unsigned.apk myalias<\/p>\n

\u6b65\u9aa4\u516d\uff1a\u4f18\u5316APK\u6587\u4ef6<\/p>\n

\u6700\u540e\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528Androapk\u751f\u6210\u5668\u8f6f\u4ef6<\/a>id\u7684\u5de5\u5177\uff08\u5982zipalign\uff09\u5bf9APK\u8fdb\u884c\u4f18\u5316\uff0c\u4ee5\u51cf\u5c0f\u6587\u4ef6\u5927\u5c0f\u5e76\u63d0\u9ad8\u6027\u80fd\u3002\u547d\u4ee4\u884c\u793a\u4f8b\uff1azipalign -v 4 myapp_signed.apk myapp_final.apk<\/p>\n

\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\uff0c\u4f60\u5c31\u6210\u529f\u5236\u4f5c\u51fa\u4e00\u4e2aAndroid\u5e94\u7528\u7a0b\u5e8f\u7684APK\u6587\u4ef6\u4e86\u3002\u4f60\u53ef\u4ee5\u901a\u8fc7\u5404\u79cd\u65b9\u5f0f\u8fdb\u884c\u53d1\u5e03\u548c\u5b89\u88c5\uff0c\u5982\u4e0a\u4f20\u5230\u5e94\u7528\u5546\u5e97\u3001\u53d1\u9001\u5230\u7528\u6237\u7b49\u3002\u8bf7\u6ce8\u610f\uff0c\u4e3a\u4e86\u786e\u4fdd\u5e94\u7528\u7a0b\u5e8f\u7684\u5b8c\u6574\u6027\u548c\u5b89\u5168\u6027\uff0c\u5f3a\u70c8\u5efa\u8bae\u5728\u53d1\u5e03\u524d\u8fdb\u884c\u4e25\u683c\u7684\u6d4b\u8bd5\u548c\u9a8c\u8bc1\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

Android\u5e73\u53f0\u662f\u76ee\u524d\u6700\u6d41\u884c\u7684\u79fb\u52a8\u64cd\u4f5c\u7cfb\u7edf\u4e4b\u4e00\uff0c\u5f00\u53d1\u8005\u53ef\u4ee5\u4f7f\u7528Java\u7b49\u7f16\u7a0b\u8bed\u8a00\u6765\u5f00\u53d1Android\u5e94\u7528\u7a0b\u5e8f\u3002\u5f00\u53d1\u5b8c\u6210\u540e\uff0c\u53ef\u4ee5\u5c06\u5e94\u7528\u7a0b\u5e8f\u6253\u5305\u6210Android\u5b89\u88c5\u5305\uff08APK\uff09\u8fdb\u884c\u53d1\u5e03\u548c\u5b89\u88c5\u3002\u4e0b\u9762\u5c06\u8be6<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[4546,4547,12,16,797],"topic":[],"class_list":{"0":"post-2147","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"hentry","6":"category-appkf","7":"tag-apk","9":"tag-12","10":"tag-16","11":"tag-797"},"_links":{"self":[{"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/posts\/2147","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/comments?post=2147"}],"version-history":[{"count":0,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/posts\/2147\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/media?parent=2147"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/categories?post=2147"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/tags?post=2147"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/topic?post=2147"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}