{"id":16048,"date":"2023-12-06T11:06:43","date_gmt":"2023-12-06T03:06:43","guid":{"rendered":"https:\/\/www.zhidianwl.com\/zhidian\/?p=16048"},"modified":"2023-12-06T11:06:43","modified_gmt":"2023-12-06T03:06:43","slug":"pb%e5%bc%80%e5%8f%91%e5%ae%89%e5%8d%93app%e7%bb%86%e8%8a%82%e4%bb%8b%e7%bb%8d","status":"publish","type":"post","link":"https:\/\/www.zhidianwl.com\/zhidian\/2023\/16048\/","title":{"rendered":"pb\u5f00\u53d1\u5b89\u5353app\u7ec6\u8282\u4ecb\u7ecd"},"content":{"rendered":"

Title: \u4f7f\u7528PhoneGap (Apache Cordova) \u5f00\u53d1Android\u5e94\u7528\u7a0b\u5e8f\uff1a\u539f\u7406\u548c\u8be6\u7ec6\u4ecb\u7ecd<\/p>\n

\u7b80\u4ecb\uff1a<\/p>\n

PhoneGap\uff0c\u4e5f\u79f0\u4e3aApache Cordova\uff0c\u662f\u4e00\u4e2a\u5f00\u53d1\u8de8\u5e73\u53f0\u79fb\u52a8\u5e94\u7528\u7a0b\u5e8f\u7684\u6846\u67b6\u3002\u5b83\u5141\u8bb8\u5f00\u53d1\u8005\u4f7f\u7528HTML\u3001CSS\u548cJavaScript\u521b\u5efa\u539f\u751f\u5e94\u7528\uff0c\u800c\u65e0\u9700\u638c\u63e1\u7279\u5b9a\u4e8e\u5e73\u53f0\u7684\u7f16\u7a0b\u8bed\u8a00\u3002\u5728\u672c\u6559\u7a0b\u4e2d\uff0c\u6211\u4eec\u5c06\u4ecb\u7ecdPhoneGap\u7684\u80cc\u540e\u539f\u7406\uff0c\u4ee5\u53ca\u5982\u4f55\u4f7f\u7528\u5b83\u5f00\u53d1Android\u5e94\u7528\u7a0b\u5e8f\u3002<\/p>\n

1. PhoneGap\uff08Apache Cordova\uff09\u539f\u7406<\/p>\n

PhoneGap\uff08Apache Cordova\uff09\u662f\u4e00\u4e2a\u5f00\u6e90\u7684\u5e94\u7528\u7a0b\u5e8f\u5bb9\u5668\uff0c\u5b83\u4f9d\u8d56\u4e8eWebView\u8fdb\u884c\u6e32\u67d3\u3002WebView\u662fAndroid\u548ciOS\u4e2d\u7684\u4e00\u4e2a\u5143\u7d20\uff0c\u5b83\u5141\u8bb8\u5f00\u53d1\u8005\u5728\u5b89\u5353APP\u5f00\u53d1<\/a>\u79fb\u52a8\u5e94\u7528\u7a0b\u5e8f\u4e2d\u5d4c\u5165\u4e00\u4e2a\u7b80\u5316\u7248\u7684Web\u6d4f\u89c8\u5668\u3002PhoneGap\u901a\u8fc7\u5c06\u5e94\u7528\u7a0b\u5e8f\u4ee3\u7801\u7528WebView\u5305\u88f9\uff0c\u5c06\u5176\u8f6c\u6362\u4e3a\u4e00\u4e2a\u539f\u751f\u7684\u79fb\u52a8\u5e94\u7528\u7a0b\u5e8f\u3002\u5b83\u8fd8\u63d0\u4f9b\u4e86\u6570\u5341\u4e2a\u63d2\u4ef6\uff0c\u5141\u8bb8\u4f60\u65e0\u9700\u7f16\u5199\u7279\u5b9a\u4e8e\u5e73\u53f0\u7684\u4ee3\u7801\u5c31\u80fd\u8bbf\u95ee\u8bbe\u5907\u7684\u539f\u751f\u529f\u80fd\uff0c\u5982\u6444\u50cf\u5934\u3001\u6570\u636e\u5e93\u7b49\u3002<\/p>\n

2. \u5f00\u53d1\u73af\u5883\u7684\u642d\u5efa<\/p>\n

\u8981\u4f7f\u7528PhoneGap\u5f00\u53d1Android\u5e94\u7528\u7a0b\u5e8f\uff0c\u9700\u8981\u9996\u5148\u5b89\u88c5Node.js\u3002\u5b89\u88c5Node.js\u540e\uff0c\u6253\u5f00\u547d\u4ee4\u884c\u5de5\u5177\uff08\u5982Windows\u7684\u547d\u4ee4\u63d0\u793a\u7b26\u6216Mac\u7684Terminal\uff09\uff0c\u5e76\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5PhoneGap\uff1a<\/p>\n

“`<\/p>\n

$ npm install -g phonegap<\/p>\n

“`<\/p>\n

\u540c\u65f6\uff0c\u9700\u8981\u5b89\u88c5Android Studio\u4ee5\u53ca\u76f8\u5e94\u7684SDK\u3002<\/p>\n

3. \u521b\u5efaPhoneGap\u9879\u76ee<\/p>\n

\u5728\u547d\u4ee4\u884c\u4e2d\u8fdb\u5165\u4f60\u60f3\u8981\u521b\u5efa\u9879\u76ee\u7684\u76ee\u5f55\uff0c\u7136\u540e\u952e\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n

“`<\/p>\n

$ phonegap create myApp —<\/p>\n

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

name “\u6211\u7684\u5e94\u7528” –id “com.example.myapp”<\/p>\n

“`<\/p>\n

\u8fd9\u5c06\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a\u201cmyApp\u201d\u7684\u6587\u4ef6\u5939\u3002\u5728\u8fd9\u91cc\uff0c\u201c\u6211\u7684\u5e94\u7528\u201d\u4e3a\u5e94\u7528\u7a0b\u5e8f\u7684\u663e\u793a\u540d\u79f0\uff0c\u201ccom.exa\u5b89\u5353app\u5236\u4f5c<\/a>mple.myapp\u201d\u4e3a\u5e94\u7528\u7a0b\u5e8f\u7684\u552f\u4e00\u6807\u8bc6\u7b26\u3002<\/p>\n

4. \u7f16\u5199\u5e94\u7528\u7a0b\u5e8f\u4ee3\u7801<\/p>\n

\u8fdb\u5165\u521a\u521a\u521b\u5efa\u7684\u201cmyApp\u201d\u6587\u4ef6\u5939\uff0c\u627e\u5230\u201cwww\u201d\u76ee\u5f55\u3002\u8fd9\u91cc\u5305\u542b\u4e00\u4e2a\u57fa\u672c\u7684PhoneGap\u5e94\u7528\u7a0b\u5e8f\u6846\u67b6\uff0c\u5305\u62ec\u4ee5\u4e0b\u51e0\u4e2a\u4e3b\u8981\u6587\u4ef6\uff1a<\/p>\n

– index.html\uff1a\u5e94\u7528\u7a0b\u5e8f\u7684\u4e3b\u9875<\/p>\n

– css\/index.css\uff1a\u5e94\u7528\u7a0b\u5e8f\u7684\u6837\u5f0f\u8868<\/p>\n

– js\/index.js\uff1a\u5e94\u7528\u7a0b\u5e8f\u7684JavaScript\u6587\u4ef6<\/p>\n

\u4f60\u53ef\u4ee5\u4f7f\u7528\u81ea\u5df1\u559c\u6b22\u7684\u6587\u672c\u7f16\u8f91\u5668\u6253\u5f00\u8fd9\u4e9b\u6587\u4ef6\uff0c\u5e76\u5f00\u59cb\u7f16\u8f91\u5e94\u7528\u7a0b\u5e8f\u7684\u4ee3\u7801\u3002<\/p>\n

5. \u7f16\u8bd1\u548c\u8fd0\u884c\u5e94\u7528\u7a0b\u5e8f<\/p>\n

\u4f7f\u7528\u547d\u4ee4\u884c\u5de5\u5177\u8fdb\u5165\u201cmyApp\u201d\u6587\u4ef6\u5939\uff0c\u5e76\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n

“`<\/p>\n

$ phonegap build android<\/p>\n

“`<\/p>\n

\u8fd9\u5c06\u4f7f\u7528Apache Cordova\u4e3aAndroid\u5e73\u53f0\u7f16\u8bd1\u5e94\u7528\u7a0b\u5e8f\u3002\u7f16\u8bd1\u5b8c\u6210\u540e\uff0c\u4f60\u53ef\u4ee5\u627e\u5230\u4e00\u4e2a\u540d\u4e3a\u201cplatforms\u201d\u7684\u6587\u4ef6\u5939\uff0c\u5176\u4e2d\u5305\u542b\u4e00\u4e2a\u540d\u4e3a\u201candroid\u201d\u7684\u5b50\u6587\u4ef6\u5939\u3002\u8fdb\u5165\u8be5\u6587\u4ef6\u5939\uff0c\u53ef\u4ee5\u627e\u5230\u4e00\u4e2a\u540d\u4e3a\u201capp-debug.apk\u201d\u7684\u6587\u4ef6\u3002\u8fd9\u4fbf\u662f\u7f16\u8bd1\u597d\u7684Android\u5e94\u7528\u7a0b\u5e8f\u3002<\/p>\n

\u60f3\u8981\u6d4b\u8bd5\u5e94\u7528\u7a0b\u5e8f\uff0c\u4f60\u53ef\u4ee5\u5c06\u201capp-debug.apk\u201d\u6587\u4ef6\u4f20\u8f93\u5230Android\u8bbe\u5907\u4e0a\u5e76\u5b89\u88c5\u3002\u53e6\u5916\uff0c\u4f60\u8fd8\u53ef\u4ee5\u4f7f\u7528Android Studio\u7684\u6a21\u62df\u5668\u6d4b\u8bd5\u5e94\u7528\u7a0b\u5e8f\u3002<\/p>\n

6. \u6253\u5305\u548c\u53d1\u5e03\u5e94\u7528\u7a0b\u5e8f<\/p>\n

\u5f53\u4f60\u51c6\u5907\u597d\u53d1\u5e03\u5e94\u7528\u7a0b\u5e8f\u65f6\uff0c\u9996\u5148\u9700\u8981\u4e3a\u5176\u7b7e\u540d\u3002\u6839\u636eAndroid\u5f00\u53d1\u8005\u7f51\u7ad9\u7684\u6307\u5357\u751f\u6210\u4e00\u4e2a\u7b7e\u540d\u5bc6\u94a5\uff0c\u5e76\u4f7f\u7528Android Studio\u6216\u547d\u4ee4\u884c\u4e3a\u5e94\u7528\u7a0b\u5e8f\u7b7e\u540d\u3002\u7b7e\u540d\u5b8c\u6210\u540e\uff0c\u5c06\u751f\u6210\u4e00\u4e2a\u540d\u4e3a\u201capp-release.apk\u201d\u7684\u6587\u4ef6\u3002<\/p>\n

\u968f\u540e\uff0c\u4f60\u53ef\u4ee5\u63d0\u4ea4\u8fd9\u4e2a\u6587\u4ef6\u5230Google Play\u5546\u5e97\uff0c\u4ee5\u4fbf\u5176\u4ed6\u4eba\u53ef\u4ee5\u4e0b\u8f7d\u548c\u5b89\u88c5\u4f60\u7684\u5e94\u7528\u7a0b\u5e8f\u3002<\/p>\n

\u603b\u7ed3\uff1a<\/p>\n

\u4f7f\u7528PhoneGap\uff08Apache Cordova\uff09\uff0c\u4f60\u53ef\u4ee5\u65b9\u4fbf\u5730\u4f7f\u7528HTML\u3001CSS\u548cJavaScript\u5f00\u53d1Android\u79fb\u52a8\u5e94\u7528\u7a0b\u5e8f\uff0c\u5145\u5206\u5229\u7528Web\u6280\u672f\u7684\u4f18\u52bf\u3002\u8ddf\u968f\u4e0a\u8ff0\u6b65\u9aa4\uff0c\u4f60\u5c06\u5b66\u4f1a\u521b\u5efa\u3001\u7f16\u5199\u3001\u7f16\u8bd1\u3001\u6d4b\u8bd5\u3001\u7b7e\u540d\u548c\u53d1\u5e03\u81ea\u5df1\u7684Android\u5e94\u7528\u7a0b\u5e8f\u3002\u795d\u4f60\u5f00\u53d1\u987a\u5229\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"

Title: \u4f7f\u7528PhoneGap (Apache Cordova) \u5f00\u53d1Android\u5e94\u7528\u7a0b\u5e8f\uff1a\u539f\u7406\u548c\u8be6\u7ec6\u4ecb\u7ecd\u7b80\u4ecb\uff1aPhoneGap\uff0c\u4e5f\u79f0\u4e3aApache Cordova\uff0c\u662f\u4e00\u4e2a\u5f00\u53d1\u8de8\u5e73\u53f0\u79fb\u52a8\u5e94\u7528\u7a0b<\/p>\n","protected":false},"author":14,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[10413,65,22854,14,314],"class_list":["post-16048","post","type-post","status-publish","format-standard","hentry","category-zuoapp","tag-perlapp","tag-65","tag-app","tag-14","tag-314"],"_links":{"self":[{"href":"https:\/\/www.zhidianwl.com\/zhidian\/wp-json\/wp\/v2\/posts\/16048","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\/14"}],"replies":[{"embeddable":true,"href":"https:\/\/www.zhidianwl.com\/zhidian\/wp-json\/wp\/v2\/comments?post=16048"}],"version-history":[{"count":1,"href":"https:\/\/www.zhidianwl.com\/zhidian\/wp-json\/wp\/v2\/posts\/16048\/revisions"}],"predecessor-version":[{"id":16086,"href":"https:\/\/www.zhidianwl.com\/zhidian\/wp-json\/wp\/v2\/posts\/16048\/revisions\/16086"}],"wp:attachment":[{"href":"https:\/\/www.zhidianwl.com\/zhidian\/wp-json\/wp\/v2\/media?parent=16048"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.zhidianwl.com\/zhidian\/wp-json\/wp\/v2\/categories?post=16048"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.zhidianwl.com\/zhidian\/wp-json\/wp\/v2\/tags?post=16048"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}