{"id":24511,"date":"2024-05-29T15:31:03","date_gmt":"2024-05-29T07:31:03","guid":{"rendered":"https:\/\/www.yimenyun.cn\/emen\/?p=24511"},"modified":"2024-05-29T15:31:03","modified_gmt":"2024-05-29T07:31:03","slug":"%e7%bd%91%e9%a1%b5%e7%9b%b4%e6%8e%a5%e6%89%93%e5%8c%85apk%e8%a6%81%e5%a6%82%e4%bd%95%e5%ae%9e%e7%8e%b0%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/www.yimenyun.cn\/emen\/24511\/","title":{"rendered":"\u7f51\u9875\u76f4\u63a5\u6253\u5305apk\u8981\u5982\u4f55\u5b9e\u73b0\uff1f"},"content":{"rendered":"

\u7f51\u9875\u76f4\u63a5\u6253\u5305\u6210 APK\uff08\u5b89\u5353\u5e94\u7528\u6587\u4ef6\uff09<\/p>\n

\u968f\u7740\u4e92\u8054\u7f51\u7684\u666e\u53ca\u548c\u79fb\u52a8\u8bbe\u5907\u7684\u8fc5\u901f\u53d1\u5c55\uff0c\u8d8a\u6765\u8d8a\u591a\u7684\u7f51\u7ad9\u5f00\u59cb\u5c1d\u8bd5\u5c06\u81ea\u5df1\u7684\u7f51\u7ad9\u5185\u5bb9\u8f6c\u5316\u4e3a\u5b89\u5353\u5e94\u7528\uff0c\u4ee5\u6ee1\u8db3\u4e0d\u540c\u7528\u6237\u7684\u9700\u6c42\u3002\u5728\u8fd9\u7bc7\u6587\u7ae0\u4e2d\uff0c\u6211\u4eec\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u7f51\u9875\u76f4\u63a5\u6253\u5305\u6210 APK \u7684\u539f\u7406\u4e0e\u65b9\u6cd5\u3002\u8fd9\u7bc7\u6587\u7ae0\u9002\u5408\u5bf9\u7f51\u9875\u8f6c\u6362\u4e3a\u5b89\u5353\u5e94\u7528\u6709\u5174\u8da3\u7684\u8bfb\u8005\uff0c\u4e0d\u9700\u8981\u638c\u63e1\u4e30\u5bcc\u7684\u5f00\u53d1\u7ecf\u9a8c\uff0c\u53ea\u9700\u8981\u8ddf\u7740\u672c\u7bc7\u6587\u7ae0\u7684\u6b65\u9aa4\u64cd\u4f5c\u5373\u53ef\u8f6c\u5316\u4e3a\u4e00\u4e2a\u5b89\u5353\u5e94\u7528\u3002<\/p>\n

\u4e00\u3001\u539f\u7406\u4ecb\u7ecd<\/p>\n

\u7f51\u9875\u76f4\u63a5\u6253\u5305\u6210 APK \u7684\u539f\u7406\u662f\u5c06\u73b0\u6709\u7684\u7f51\u9875\u5185\u5bb9\u5d4c\u5165\u5230\u4e00\u4e2a\u5b89\u5353\u5e94\u7528\u6846\u67b6\u91cc\uff0c\u901a\u8fc7 WebView \u7684\u5f62\u5f0f\u5c55\u793a\u7f51\u9875\u3002WebView \u662f\u5b89\u5353\u4e2d\u4e00\u4e2a\u7528\u4e8e\u5c55\u793a\u7f51\u9875\u7684\u63a7\u4ef6\uff0c\u53ef\u4ee5\u5c06\u7f51\u5740\u52a0\u8f7d\u8fdb\u6765\uff0c\u4ece\u800c\u5b9e\u73b0\u5c06\u7f51\u9875\u8f6c\u6362\u4e3a\u5b89\u5353\u5e94\u7528\u7684\u9700\u6c42\u3002<\/p>\n

\u7b80\u5355\u6765\u8bf4\uff0c\u5c31\u662f\u5229\u7528 WebView \u5728\u7528\u6237\u5b89\u88c5\u7684 APK \u5e94\u7528\u4e2d\u76f4\u63a5\u6253\u5f00\u7f51\u9875\uff0c\u4f7f\u5176\u770b\u8d77\u6765\u50cf\u4e00\u4e2a\u5e94\u7528\u3002\u8fd9\u79cd\u65b9\u5f0f\u76f8\u5bf9\u4e8e\u539f\u751f\u5f00\u53d1\uff0c\u8282\u7701\u4e86\u5927\u91cf\u7684\u65f6\u95f4\u548c\u6210\u672c\uff0c\u9002\u7528\u4e8e\u5df2\u7ecf\u62e5\u6709\u73b0\u6709\u7f51\u9875\u7684\u7f51\u7ad9\u6216\u8005\u6709\u4e00\u5b9a\u7684\u7f51\u7ad9\u5efa\u8bbe\u7ecf\u9a8c\u7684\u5f00\u53d1\u8005\u3002<\/p>\n

\u4e8c\u3001\u64cd\u4f5c\u6b65\u9aa4<\/p>\n

1.\u5b89\u88c5 Android Studio<\/p>\n

\u9996\u5148\uff0c\u4f60\u9700\u8981\u4e0b\u8f7d\u5e76\u5b89\u88c5 Android Studio\uff0c\u8fd9\u662f\u4e00\u4e2a\u975e\u5e38\u4f18\u79c0\u7684\u5b89\u5353\u5f00\u53d1\u5de5\u5177\uff0c\u53ef\u4ee5\u5e2e\u52a9\u4f60\u5feb\u901f\u6784\u5efa\u4e00\u4e2a\u5b89\u5353\u5e94\u7528\u3002\u8bbf\u95ee Android Studio \u5b98\u7f51(https:\/\/developer.android.com\/studio)\u4e0b\u8f7d\u5e76\u5b89\u88c5\u6700\u65b0\u7248\u672c\u3002<\/p>\n

2.\u521b\u5efa\u9879\u76ee<\/p>\n

\u6253\u5f00 Android Studio\uff0c\u5728\u6b22\u8fce\u754c\u9762\u9009\u62e9\u201cCreate New Project\u201d\u3002\u5728\u65b0\u5efa\u9879\u76ee\u5411\u5bfc\u4e2d\uff0c\u4e3a\u9879\u76ee\u9009\u62e9\u4e00\u4e2a\u540d\u79f0\u3001\u5b58\u653e\u7684\u4f4d\u7f6e\u548c\u5305\u540d\uff0c\u70b9\u51fb\u4e0b\u4e00\u6b65\u3002\u5728\u63a5\u4e0b\u6765\u7684\u754c\u9762\u4e2d\uff0c\u9009\u62e9\u8bbe\u5907\u7c7b\u578b\u548cAPI\u7ea7\u522b\uff0c\u5efa\u8bae\u9009\u62e9 API 21 \u6216\u4ee5\u4e0a\uff0c\u4ee5\u652f\u6301\u66f4\u591a\u8bbe\u5907\u3002<\/p>\n

3. \u6dfb\u52a0\u6743\u9650<\/p>\n

\u5728 AndroidManifest.xml \u6587\u4ef6\u4e2d\uff0c\u9700\u8981\u6dfb\u52a0\u4ee5\u4e0b\u51e0\u4e2a\u6743\u9650\uff0c\u7528\u4e8e\u8bbf\u95ee\u7f51\u7edc\u548c\u7f51\u7edc\u72b6\u6001\uff1a<\/p>\n

“`java<\/p>\n<\/p>\n

“`<\/p>\n

4. \u6dfb\u52a0 WebView<\/p>\n

\u5728\u4e3b\u754c\u9762\u7684\u5e03\u5c40\u6587\u4ef6\uff08activity_main.xml\uff09\u4e2d\uff0c\u6dfb\u52a0\u4e00\u4e2a WebView \u5982\u4e0b\uff1a<\/p>\n

“`xml<\/p>\n<\/p>\n

android:id=”@+id\/webView”<\/p>\n

app\u8df3\u8f6c\u94fe\u63a5<\/a> android:layout_width=”match_parent”<\/p>\n

android:layout_height=”match_parent” \/><\/p>\n

“`<\/p>\n

5.\u52a0\u8f7d\u7f51\u9875<\/p>\n

\u5728 MainActivity.java \u6587\u4ef6\u4e2d\uff0c\u83b7\u53d6 WebView \u63a7\u4ef6\uff0c\u5e76\u52a0\u8f7d\u4f60\u60f3\u8981\u5c55\u793a\u7684\u7f51\u9875\uff1a<\/p>\n

“`java<\/p>\n

@Override<\/p>\n

protected void onCreate(B\u7f51\u9875\u5b89\u5353app\u5c01\u88c5<\/a>undle savedInstanceState) {<\/p>\n

super.onCreate(savedInstanceState);<\/p>\n

setContentView(R.layout.activity_main);<\/p>\n

WebView webView = findViewById(R.id.webView);<\/p>\n

webView.setWebViewClient(new WebViewClient());<\/p>\n

WebSettings webSettings = webView.getSettings();<\/p>\n

webSettings.setJavaScriptEnabled(true);<\/p>\n

webSettings.setDomStorageEnabled(true);<\/p>\n

webView.loadUrl(“https:\/\/example.com”); \/\/\u66ff\u6362\u6210\u4f60\u7684\u7f51\u5740<\/p>\n

}<\/p>\n

“`<\/p>\n

6.\u751f\u6210\u5e76\u7b7e\u540d APK \u6587\u4ef6<\/p>\n

\u70b9\u51fb\u83dc\u5355\u680f\u201cBuild\u201d> “Generate Signed Bundle \/ APK…”\uff0c\u6309\u7167\u63d0\u793a\u521b\u5efa\u4e00\u4e2a\u7b7e\u540d\u6587\u4ef6\u5e76\u7b7e<\/p>\n

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

\u540d\u3002\u6700\u540e\u751f\u6210\u7684 APK \u5c31\u662f\u4f60\u7684\u7f51\u9875\u8f6c\u6362\u6210\u7684\u5b89\u5353\u5e94\u7528\u3002<\/p>\n

\u4e09\u3001\u4f18\u7f3a\u70b9<\/p>\n

\u4f18\u70b9\uff1a<\/p>\n

1.\u5feb\u901f\u5c06\u73b0\u6709\u7684\u7f51\u9875\u8f6c\u6362\u6210<\/p>\n","protected":false},"excerpt":{"rendered":"

\u7f51\u9875\u76f4\u63a5\u6253\u5305\u6210 APK\uff08\u5b89\u5353\u5e94\u7528\u6587\u4ef6\uff09\u968f\u7740\u4e92\u8054\u7f51\u7684\u666e\u53ca\u548c\u79fb\u52a8\u8bbe\u5907\u7684\u8fc5\u901f\u53d1\u5c55\uff0c\u8d8a\u6765\u8d8a\u591a\u7684\u7f51\u7ad9\u5f00\u59cb\u5c1d\u8bd5\u5c06\u81ea\u5df1\u7684\u7f51\u7ad9\u5185\u5bb9\u8f6c\u5316\u4e3a\u5b89\u5353\u5e94\u7528\uff0c\u4ee5\u6ee1\u8db3\u4e0d\u540c\u7528\u6237\u7684\u9700\u6c42\u3002\u5728\u8fd9\u7bc7\u6587\u7ae0\u4e2d\uff0c\u6211\u4eec\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u7f51\u9875\u76f4\u63a5\u6253\u5305\u6210 A<\/p>\n","protected":false},"author":9,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[7379,160,16,18240,149],"topic":[],"class_list":["post-24511","post","type-post","status-publish","format-standard","hentry","category-appkf","tag-webapp","tag-160","tag-16","tag-18240","tag-149"],"_links":{"self":[{"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/posts\/24511","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\/9"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/comments?post=24511"}],"version-history":[{"count":1,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/posts\/24511\/revisions"}],"predecessor-version":[{"id":24574,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/posts\/24511\/revisions\/24574"}],"wp:attachment":[{"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/media?parent=24511"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/categories?post=24511"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/tags?post=24511"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/topic?post=24511"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}