{"id":31830,"date":"2024-04-28T15:08:16","date_gmt":"2024-04-28T07:08:16","guid":{"rendered":"https:\/\/www.zhidianwl.com\/zhidian\/?p=31830"},"modified":"2024-04-28T15:08:16","modified_gmt":"2024-04-28T07:08:16","slug":"android%e7%94%a8%e4%ba%8e%e7%94%9f%e6%88%90apk%e6%96%87%e4%bb%b6%e5%90%8d%e7%a7%b0%e7%9a%84%e6%98%af%e4%bb%80%e4%b9%88%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/www.zhidianwl.com\/zhidian\/2024\/31830\/","title":{"rendered":"android\u7528\u4e8e\u751f\u6210apk\u6587\u4ef6\u540d\u79f0\u7684\u662f\u4ec0\u4e48\uff1f"},"content":{"rendered":"

\u5728Android\u5f00\u53d1\u4e2d\uff0c\u751f\u6210APK\u6587\u4ef6\u7684\u540d\u79f0\u662f\u4f7f\u7528build.gradle\u6587\u4ef6\u8fdb\u884c\u914d\u7f6e\u7684\u3002build.gradle\u662f\u4e00\u4e2aGroovy\u8bed\u8a00\u811a\u672c\uff0c\u7528\u4e8e\u914d\u7f6eAndroid\u9879\u76ee\u7684\u6784\u5efa\u4fe1\u606f\u3002<\/p>\n

\u5728build.gradle\u6587\u4ef6\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u65b9\u5f0f\u914d\u7f6eAPK\u6587\u4ef6\u540d\u79f0\uff1a<\/p>\n

1. \u9ed8\u8ba4\u914d\u7f6e\uff1a\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0cAndroid Studio\u4f1a\u6839\u636e\u9879\u76ee\u7684\u6a21\u5757\u540d\u79f0\u548c\u7248\u672c\u53f7\u6765\u751f\u6210APK\u6587\u4ef6\u7684\u540d\u79f0\u3002\u4f8b\u5982\uff0c\u6a21\u5757\u540d\u79f0\u4e3aapp\uff0c\u7248\u672c\u53f7\u4e3a1.0\uff0c\u5219\u751f\u6210\u7684APK\u6587\u4ef6\u540d\u79f0\u4e3aapp-1.0.apk\u3002<\/p>\n

2. \u81ea\u5b9a\u4e49\u914d\u7f6e\uff1a\u5982\u679c\u5e0c\u671b\u81ea\u5b9a\u4e49APK\u6587\u4ef6\u540d\u79f0\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u65b9\u6cd5\u5b9e\u73b0\uff1a<\/p>\n

a. \u5728build.gradle\u6587\u4ef6\u4e2d\u627e\u5230android\u8282\u70b9\uff0c\u5728\u5176\u4e0b\u65b9\u6dfb\u52a0\u4ee5\u4e0b\u4ee3\u7801\uff1a<\/p>\n

“`<\/p>\n

android {<\/p>\n

…<\/p>\n

applicationVariants.all { variant -><\/p>\n

variant.outputs.all {<\/p>\n

outputFileName = “\u81ea\u5b9a\u4e49\u540d\u79f0.apk”<\/p>\n

}<\/p>\n

}<\/p>\n

}<\/p>\n

“`<\/p>\n

\u5728\u8fd9\u4e2a\u914d\u7f6e\u4e2d\uff0capplicationVariants\u8868\u793a\u6240\u6709\u7684\u6784\u5efa\u53d8\u4f53\uff08\u4f8b\u5982debug\u3001release\uff09\uff0coutputs\u8868\u793a\u8f93\u51fa\u6587\u4ef6\uff0coutputFileName\u8868\u793a\u8f93\u51fa\u6587\u4ef6\u7684\u540d\u79f0\u3002\u5c06”\u81ea\u5b9a\u4e49\u540d\u79f0.apk”\u66ff\u6362\u4e3a\u4f60\u5e0c\u671b\u7684\u540d\u79f0\u3002<\/p>\n

b. \u540c\u6837\uff0c\u53ef\u4ee5\u6839\u636e\u4e0d\u540c\u7684\u6784\u5efa\u7c7b\u578b\u548c\u6784\u5efa\u5b89\u5353\u5236\u4f5capk\u7b7e\u540d<\/a>\u53d8\u4f53\u6765\u81ea\u5b9a\u4e49APK\u6587\u4ef6\u540d\u79f0\u3002\u4f8b\u5982\uff0c\u4ee5\u4e0b\u7684\u4ee3\u7801\u5c06\u5206\u522b\u4e3adebug\u548crelease\u4e24\u79cd\u6784\u5efa\u7c7b\u578b\u751f\u6210\u4e0d\u540c\u7684APK\u6587\u4ef6\u540d\u79f0\uff1a<\/p>\n

“`<\/p>\n

android {<\/p>\n

…<\/p>\n

buildTypes {<\/p>\n

debug {<\/p>\n

applicationVariants.all { variant -><\/p>\n

variant.outputs.all {<\/p>\n

outputFileName = “debug-\u81ea\u5b9a\u4e49\u540d\u79f0.apk”<\/p>\n

}<\/p>\n

}<\/p>\n

}<\/p>\n

release {<\/p>\n

applicationVariants.all { variant -><\/p>\n

variant.outputs.all {<\/p>\n

outputFileName = “release-\u81ea\u5b9a\u4e49\u540d\u79f0.apk”<\/p>\n

}<\/p>\n

}<\/p>\n

}<\/p>\n

}<\/p>\n

}<\/p>\n

“`<\/p>\n

\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0cdebug\u6784\u5efa\u7c7b\u578b\u5bf9\u5e94\u7684APK\u6587\u4ef6\u540d\u79f0\u4e3a”debug-\u81ea\u5b9a\u4e49\u540d\u79f0.apk”\uff0crelease\u6784\u5efa\u7c7b\u578b\u5bf9\u5e94\u7684APK\u6587\u4ef6\u540d\u79f0\u4e3a”release-\u81ea\u5b9a\u4e49\u540d\u79f0.apk”\u3002<\/p>\n

hbuilder\u6253\u5305apk\u7f3a\u70b9<\/a>\u4ee5\u4e0a\u662f\u901a\u8fc7\u4fee\u6539build.g<\/p>\n

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

radle\u6587\u4ef6\u6765\u914d\u7f6eAPK\u6587\u4ef6\u540d\u79f0\u7684\u65b9\u6cd5\u3002\u6bcf\u6b21\u6784\u5efa\u65f6\uff0cAndroid Studio\u4f1a\u6839\u636ebuild.gradle\u4e2d\u7684\u914d\u7f6e\u751f\u6210\u76f8\u5e94\u7684APK\u6587\u4ef6\uff0c\u5e76\u5c06\u5176\u4fdd\u5b58\u5728\u9879\u76ee\u7684\u8f93\u51fa\u76ee\u5f55\u4e2d\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

\u5728Android\u5f00\u53d1\u4e2d\uff0c\u751f\u6210APK\u6587\u4ef6\u7684\u540d\u79f0\u662f\u4f7f\u7528build.gradle\u6587\u4ef6\u8fdb\u884c\u914d\u7f6e\u7684\u3002build.gradle\u662f\u4e00\u4e2aGroovy\u8bed\u8a00\u811a\u672c\uff0c\u7528\u4e8e\u914d\u7f6eAndroid\u9879\u76ee\u7684\u6784\u5efa\u4fe1\u606f\u3002\u5728build.gr<\/p>\n","protected":false},"author":10,"featured_media":0,"comment_status":"","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[31346,2637,31345,171,1332],"class_list":["post-31830","post","type-post","status-publish","format-standard","hentry","category-zuoapp","tag-hbuilderx-apk","tag-2637","tag-appapk","tag-171","tag-1332"],"_links":{"self":[{"href":"https:\/\/www.zhidianwl.com\/zhidian\/wp-json\/wp\/v2\/posts\/31830","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.zhidianwl.com\/zhidian\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.zhidianwl.com\/zhidian\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.zhidianwl.com\/zhidian\/wp-json\/wp\/v2\/users\/10"}],"replies":[{"embeddable":true,"href":"https:\/\/www.zhidianwl.com\/zhidian\/wp-json\/wp\/v2\/comments?post=31830"}],"version-history":[{"count":1,"href":"https:\/\/www.zhidianwl.com\/zhidian\/wp-json\/wp\/v2\/posts\/31830\/revisions"}],"predecessor-version":[{"id":31874,"href":"https:\/\/www.zhidianwl.com\/zhidian\/wp-json\/wp\/v2\/posts\/31830\/revisions\/31874"}],"wp:attachment":[{"href":"https:\/\/www.zhidianwl.com\/zhidian\/wp-json\/wp\/v2\/media?parent=31830"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.zhidianwl.com\/zhidian\/wp-json\/wp\/v2\/categories?post=31830"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.zhidianwl.com\/zhidian\/wp-json\/wp\/v2\/tags?post=31830"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}