{"id":6673,"date":"2023-04-11T12:02:09","date_gmt":"2023-04-11T04:02:09","guid":{"rendered":"https:\/\/www.zhidianwl.net\/zhidianwl\/2023\/04\/11\/android-apk%e9%87%8c%e5%86%85%e7%bd%aeapk\/"},"modified":"2023-04-11T12:02:09","modified_gmt":"2023-04-11T04:02:09","slug":"android-apk%e9%87%8c%e5%86%85%e7%bd%aeapk","status":"publish","type":"post","link":"https:\/\/www.zhidianwl.net\/zhidianwl\/2023\/04\/11\/android-apk%e9%87%8c%e5%86%85%e7%bd%aeapk\/","title":{"rendered":"android apk\u91cc\u5185\u7f6eapk"},"content":{"rendered":"

\u5728Android\u7cfb\u7edf\u4e2d\uff0c\u53ef\u4ee5\u5c06\u4e00\u4e2aapk\u6587\u4ef6\u5185\u5d4c\u5230\u53e6\u4e00\u4e2aapk\u6587\u4ef6\u4e2d\uff0c\u8fd9\u88ab\u79f0\u4e3a\u5185\u7f6eapk\u3002\u5185\u7f6eapk\u7684\u4e3b\u8981\u4f5c\u7528\u662f\u5c06\u591a\u4e2a\u5e94\u7528\u7a0b\u5e8f\u5408\u5e76\u6210\u4e00\u4e2a\u5355\u72ec\u7684\u5e94\u7528\u7a0b\u5e8f\u5305\uff0c\u8fd9\u6837\u53ef\u4ee5\u51cf\u5c11\u7528\u6237\u4e0b\u8f7d\u548c\u5b89\u88c5\u7684\u6b21\u6570\uff0c\u63d0\u9ad8\u7528\u6237\u4f53\u9a8c\u3002\u672c\u6587\u5c06\u4ecb\u7ecd\u5185\u7f6eapk\u7684\u539f\u7406\u548c\u8be6\u7ec6\u5b9e\u73b0\u65b9\u6cd5\u3002<\/p>\n

\u4e00\u3001\u5185\u7f6eapk\u7684\u539f\u7406<\/p>\n

Android\u7cfb\u7edf\u4e2d\u7684\u6bcf\u4e2a\u5e94\u7528\u7a0b\u5e8f\u90fd\u662f\u4e00\u4e2aapk\u6587\u4ef6\uff0c\u5305\u542b\u4e86\u5e94\u7528\u7a0b\u5e8f\u7684\u4ee3\u7801\u3001\u8d44\u6e90\u3001\u914d\u7f6e\u6587\u4ef6\u7b49\u3002\u5f53\u7528\u6237\u5b89\u88c5\u4e00\u4e2a\u5e94\u7528\u7a0b\u5e8f\u65f6\uff0c\u7cfb\u7edf\u4f1a\u5c06apk\u6587\u4ef6\u89e3\u538b\u7f29\u5e76\u5b89\u88c5\u5230\u8bbe\u5907\u4e0a\u3002\u5185\u7f6eapk\u7684\u539f\u7406\u5c31\u662f\u5c06\u4e00\u4e2aapk\u6587\u4ef6\u89e3\u538b\u7f29\u540e\uff0c\u5c06\u5176\u8d44\u6e90\u6587\u4ef6\u590d\u5236\u5230\u53e6\u4e00\u4e2aapk\u6587\u4ef6\u7684\u5bf9\u5e94\u76ee\u5f55\u4e0b\uff0c\u7136\u540e\u91cd\u65b0\u6253\u5305\u6210\u4e00\u4e2a\u65b0\u7684apk\u6587\u4ef6\u3002<\/p>\n

\u4e8c\u3001\u5185\u7f6eapk\u7684\u5b9e\u73b0\u65b9\u6cd5<\/p>\n

1. \u521b\u5efa\u4e3b\u5e94\u7528\u7a0b\u5e8f<\/p>\n

\u9996\u5148\uff0c\u9700\u8981\u521b\u5efa\u4e00\u4e2a\u4e3b\u5e94\u7528\u7a0b\u5e8f\uff0c\u7528\u4e8e\u96c6\u6210\u6240\u6709\u7684\u5b50\u5e94\u7528\u7a0b\u5e8f\u3002\u5728Android Studio\u4e2d\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u5e94\u7528\u7a0b\u5e8f\u9879\u76ee\uff0c\u7136\u540e\u6dfb\u52a0\u591a\u4e2a\u6a21\u5757\uff08\u5b50\u5e94\u7528\u7a0b\u5e8f\uff09\u3002<\/p>\n

2. \u521b\u5efa\u5b50\u5e94\u7528\u7a0b\u5e8f<\/p>\n

\u5728\u4e3b\u5e94\u7528\u7a0b\u5e8f\u9879\u76ee\u4e2d\uff0c\u53ef\u4ee5\u6dfb\u52a0\u591a\u4e2a\u5b50\u5e94\u7528\u7a0b\u5e8f\u6a21\u5757\u3002\u6bcf\u4e2a\u5b50\u5e94\u7528\u7a0b\u5e8f\u6a21\u5757\u90fd\u662f\u4e00\u4e2a\u72ec\u7acb\u7684\u5e94\u7528\u7a0b\u5e8f\uff0c\u4e0e\u4e3b\u5e94\u7528\u7a0b\u5e8f\u6ca1\u6709\u4efb\u4f55\u5173\u8054\u3002\u5728\u521b\u5efa\u5b50\u5e94\u7528\u7a0b\u5e8f\u65f6\uff0c\u9700\u8981\u6ce8\u610f\u4ee5\u4e0b\u51e0\u70b9\uff1a<\/p>\n

\uff081\uff09\u5b50\u5e94\u7528\u7a0b\u5e8f\u7684AndroidManifest.xml\u6587\u4ef6\u4e2d\u9700\u8981\u8bbe\u7f6e\u4e00\u4e2a\u72ec\u7acb\u7684\u5305\u540d\uff0c\u4ee5\u907f\u514d\u4e0e\u4e3b\u5e94\u7528\u7a0b\u5e8f\u51b2\u7a81\uff1b<\/p>\n

\uff082\uff09\u5b50\u5e94\u7528\u7a0b\u5e8f\u7684\u8d44\u6e90\u6587\u4ef6\u9700\u8981\u4e0e\u4e3b\u5e94\u7528\u7a0b\u5e8f\u7684\u8d44\u6e90\u6587\u4ef6\u5206\u5f00\u5b58\u653e\uff0c\u4ee5\u4fbf\u5728\u6253\u5305\u65f6\u80fd\u591f\u6b63\u786e\u5730\u590d\u5236\u5230\u4e3b\u5e94\u7528\u7a0b\u5e8f\u7684\u5bf9\u5e94\u76ee\u5f55\u4e0b\u3002<\/p>\n

3. \u590d\u5236\u5b50\u5e94\u7528\u7a0b\u5e8f\u8d44\u6e90\u6587\u4ef6\u5230\u4e3b\u5e94\u7528\u7a0b\u5e8f<\/p>\n

\u5728\u4e3b\u5e94\u7528\u7a0b\u5e8f\u7684build.gradle\u6587\u4ef6\u4e2d\u6dfb\u52a0\u4ee5\u4e0b\u4ee3\u7801\uff0c\u7528\u4e8e\u590d\u5236\u5b50\u5e94\u7528\u7a0b\u5e8f\u7684\u8d44\u6e90\u6587\u4ef6\u5230\u4e3b\u5e94\u7528\u7a0b\u5e8f\u7684\u5bf9\u5e94\u76ee\u5f55\u4e0b\uff1a<\/p>\n

“`<\/p>\n

android {<\/p>\n

sourceSets {<\/p>\n

main {<\/p>\n

res.srcDirs = [<\/p>\n

‘src\/main\/res’,<\/p>\n

‘..\/subapp1\/src\/main\/res’,<\/p>\n

‘..\/subapp2\/src\/main\/res’,<\/p>\n

‘..\/subapp3\/src\/main\/res’<\/p>\n

]<\/p>\n

}<\/p>\n

}<\/p>\n

}<\/p>\n

“`<\/p>\n

\u5176\u4e2d\uff0c’..\/subapp1\/src\/main\/res’\u8868\u793a\u5b50\u5e94\u7528\u7a0b\u5e8f1\u7684\u8d44\u6e90\u6587\u4ef6\u6240\u5728\u76ee\u5f55\uff0c’..\/subapp2\/src\/main\/res’\u8868\u793a\u5b50\u5e94\u7528\u7a0b\u5e8f2\u7684\u8d44\u6e90\u6587\u4ef6\u6240\u5728\u76ee\u5f55\uff0c\u4ee5\u6b64\u7c7b\u63a8\u3002<\/p>\n

4. \u6253\u5305\u4e3b\u5e94\u7528\u7a0b\u5e8f<\/p>\n

\u5728\u4e3b\u5e94\u7528\u7a0b\u5e8f\u7684build.gradle\u6587\u4ef6\u4e2d\u6dfb\u52a0\u4ee5\u4e0b\u4ee3\u7801\uff0c\u7528\u4e8e\u6253\u5305\u4e3b\u5e94\u7528\u7a0b\u5e8f\uff1a<\/p>\n

“`<\/p>\n

android {<\/p>\n

…<\/p>\n

defaultConfig {<\/p>\n

…<\/p>\n

multiDexEnabled true<\/p>\n

applicationId “com.example.mainapp”<\/p>\n

manifestPlaceholders = [<\/p>\n

subapp1: “com.example.subapp1”,<\/p>\n

subapp2: “com.example.subapp2”,<\/p>\n

subapp3: “com.example.subapp3”<\/p>\n

]<\/p>\n

}<\/p>\n

…<\/p>\n

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

variant.outputs.each { output -><\/p>\n

def apk = output.outputFile<\/p>\n

def newName = apk.name.replace(“.apk”, “-main.apk”)<\/p>\n

output.outputFile = new File(apk.parent, newName)<\/p>\n

}<\/p>\n

}<\/p>\n

}<\/p>\n

dependencies {<\/p>\n

implementation project(‘:subapp1’)<\/p>\n

implementation project(‘:subapp2’)<\/p>\n

implementation project(‘:subapp3’)<\/p>\n

}<\/p>\n

\u5929\u732bapk<\/a>“`<\/p>\n

\u5176\u4e2d\uff0c’applicationId “com.example.mainapp”‘\u8868\u793a\u4e3b\u5e94\u7528\u7a0b\u5e8f\u7684\u5305\u540d\uff0c’manifestPlaceholders’\u7528\u4e8e\u5c06\u5b50\u5e94\u7528\u7a0b\u5e8f\u7684\u5305\u540d\u6620\u5c04\u5230\u4e3b\u5e94\u7528\u7a0b\u5e8f\u7684AndroidManifest.xml\u6587\u4ef6\u4e2d\uff0c’multiDexEnabled true’\u8868\u793a\u542f\u7528\u5206\u5305\uff0c\u4ee5\u652f\u6301\u591a\u4e2a\u5b50\u5e94\u7528\u7a0b\u5e8f\uff0c’implementation project(‘:subapp1’)’\u8868\u793a\u5f15\u7528\u5b50\u5e94\u7528\u7a0b\u5e8f1\u7684\u6a21\u5757\u3002<\/p>\n

5. \u6253\u5305\u5b50\u5e94\u7528\u7a0b\u5e8f<\/p>\n

\u5728\u6bcf\u4e2a\u5b50\u5e94\u7528\u7a0b\u5e8f\u7684build.gradle\u6587\u4ef6\u4e2d\u6dfb\u52a0\u4ee5\u4e0b\u4ee3\u7801\uff0c\u7528\u4e8e\u6253\u5305\u5b50\u5e94\u7528\u7a0b\u5e8f\uff1a<\/p>\n

“`<\/p>\n

android {<\/p>\n

…<\/p>\n

defaultConfig {<\/p>\n

…<\/p>\n

multiDexEnabled true<\/p>\n

applicationId “com.example.subapp1”<\/p>\n

}<\/p>\n

…<\/p>\n

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

variant.outputs.eac<\/p>\n

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

h { output -><\/p>\n

def apk = output.outputFile<\/p>\n

def newName = apk.name.replace(“.apk”, “-subapp1.apk”)<\/p>\n

output.outputFile = new File(apk.parent, newName)<\/p>\n

}<\/p>\n

}<\/p>\n

}<\/p>\n

“`<\/p>\n

\u5176\u4e2d\uff0c’applicationId “com.example.subapp1″‘\u8868\u793a\u5b50\u5e94\u7528\u7a0b\u5e8f1\u7684\u5305\u540d\uff0c’-subapp1.apk’\u8868\u793a\u5b50\u5e94\u7528\u7a0b\u5e8f1\u7684\u540d\u79f0\u3002<\/p>\n

6. \u5b89\u88c5\u4e3b\u5e94\u7528\u7a0b\u5e8f<\/p>\n

\u5c06\u4e3b\u5e94\u7528\u7a0b\u5e8f\u7684apk\u6587\u4ef6\u5b89\u88c5\u5230\u8bbe\u5907\u4e0a\uff0c\u5373\u53ef\u540c\u65f6\u5b89\u88c5\u6240\u6709\u7684\u5b50\u5e94\u7528\u7a0b\u5e8f\u5e94\u7528\u4e0a\u67b6\u540d\u79f0\u76f8\u540c<\/a>\u3002<\/p>\n

\u4e09\u3001\u603b\u7ed3<\/p>\n

\u5185\u7f6eapk\u662f\u4e00\u79cd\u5c06\u591a\u4e2a\u5e94\u7528\u7a0b\u5e8f\u5408\u5e76\u6210\u4e00\u4e2a\u5355\u72ec\u7684\u5e94\u7528\u7a0b\u5e8f\u5305\u7684\u65b9\u6cd5\uff0c\u53ef\u4ee5\u51cf\u5c11\u7528\u6237\u4e0b\u8f7d\u548c\u5b89\u88c5\u7684\u6b21\u6570\uff0c\u63d0\u9ad8\u7528\u6237\u4f53\u9a8c\u3002\u5185\u7f6eapk\u7684\u5b9e\u73b0\u65b9\u6cd5\u662f\u5c06\u591a\u4e2a\u5e94\u7528\u7a0b\u5e8f\u6a21\u5757\u6dfb\u52a0\u5230\u4e00\u4e2a\u4e3b\u5e94\u7528\u7a0b\u5e8f\u9879\u76ee\u4e2d\uff0c\u7136\u540e\u5c06\u5b50\u5e94\u7528\u7a0b\u5e8f\u7684\u8d44\u6e90\u6587\u4ef6\u590d\u5236\u5230\u4e3b\u5e94\u7528\u7a0b\u5e8f\u7684\u5bf9\u5e94\u76ee\u5f55\u4e0b\uff0c\u6700\u540e\u6253\u5305\u4e3b\u5e94\u7528\u7a0b\u5e8f\u5373\u53ef\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

\u5728Android\u7cfb\u7edf\u4e2d\uff0c\u53ef\u4ee5\u5c06\u4e00\u4e2aapk\u6587\u4ef6\u5185\u5d4c\u5230\u53e6\u4e00\u4e2aapk\u6587\u4ef6\u4e2d\uff0c\u8fd9\u88ab\u79f0\u4e3a\u5185\u7f6eapk\u3002\u5185\u7f6eapk\u7684\u4e3b\u8981\u4f5c\u7528\u662f\u5c06\u591a\u4e2a\u5e94\u7528\u7a0b\u5e8f\u5408\u5e76\u6210\u4e00\u4e2a\u5355\u72ec\u7684\u5e94\u7528\u7a0b\u5e8f\u5305\uff0c\u8fd9\u6837\u53ef\u4ee5\u51cf\u5c11\u7528\u6237\u4e0b\u8f7d\u548c\u5b89\u88c5\u7684\u6b21\u6570\uff0c\u63d0\u9ad8\u7528\u6237\u4f53<\/p>\n","protected":false},"author":24,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[12032,32,116,12,1422],"topic":[],"class_list":["post-6673","post","type-post","status-publish","format-standard","hentry","category-kaifaapp","tag-apk","tag-32","tag-116","tag-12","tag-app"],"_links":{"self":[{"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/posts\/6673","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/users\/24"}],"replies":[{"embeddable":true,"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/comments?post=6673"}],"version-history":[{"count":0,"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/posts\/6673\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/media?parent=6673"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/categories?post=6673"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/tags?post=6673"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/topic?post=6673"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}