{"id":23269,"date":"2024-03-18T11:58:27","date_gmt":"2024-03-18T03:58:27","guid":{"rendered":"https:\/\/h5app.yimenapp.cn\/h5app\/?p=23269"},"modified":"2024-03-18T11:58:27","modified_gmt":"2024-03-18T03:58:27","slug":"py%e6%96%87%e4%bb%b6%e6%89%93%e5%8c%85%e6%88%90apk%e5%a6%82%e4%bd%95%e5%ae%9e%e7%8e%b0%e7%9a%84","status":"publish","type":"post","link":"https:\/\/h5app.yimenapp.cn\/h5app\/2024\/appkfa\/23269\/","title":{"rendered":"py\u6587\u4ef6\u6253\u5305\u6210apk\u5982\u4f55\u5b9e\u73b0\u7684?"},"content":{"rendered":"<p>\u5c06Python\u6587\u4ef6\u6253\u5305\u6210APK\u662f\u4e00\u79cd\u5c06Python\u4ee3\u7801\u8f6c\u6362\u4e3aAndroid\u5e94\u7528\u7a0b\u5e8f\u7684\u65b9\u6cd5\u3002Python\u662f\u4e00\u79cd\u9ad8\u7ea7\u7f16\u7a0b\u8bed\u8a00\uff0c\u800cAndroid\u5e94\u7528\u7a0b\u5e8f\u662f\u4f7f\u7528Java\u7f16\u5199\u7684\u3002\u56e0\u6b64\uff0c\u5c06Python\u4ee3\u7801\u8f6c\u6362\u4e3aJava\u4ee3\u7801\uff0c\u7136\u540e\u5c06\u5176\u7f16\u8bd1\u4e3aAndroid\u5e94\u7528\u7a0b\u5e8f\u662f\u4e00\u79cd\u5c06Python\u6587\u4ef6\u6253\u5305\u6210APK\u7684\u65b9\u6cd5\u3002<\/p>\n<p>\u4e0b\u9762\u662f\u5c06Python\u6587\u4ef6\u6253\u5305\u6210APK\u7684\u8be6\u7ec6\u6b65\u9aa4\uff1a<\/p>\n<p>1. \u5b89\u88c5Kivy\u548cBuildozer<\/p>\n<p>Kivy\u662f\u4e00\u4e2a\u7528\u4e8e\u521b\u5efa\u8de8\u5e73\u53f0\u5e94\u7528\u7a0b\u5e8f\u7684Python\u5e93\uff0c\u800cBuildozer\u662f\u4e00\u4e2a\u7528\u4e8e\u6253\u5305Python\u5e94\u7528\u7a0b\u5e8f\u7684\u547d\u4ee4\u884c\u5de5\u5177\u3002\u56e0\u6b64\uff0c\u9700\u8981\u5148\u5b89\u88c5\u8fd9\u4e24\u4e2a\u5de5\u5177\u3002<\/p>\n<p>2. \u7f16\u5199Python\u4ee3\u7801<\/p>\n<p>\u7f16\u5199Python\u4ee3\u7801\uff0c\u786e\u4fdd\u5b83\u80fd\u591f\u5728Kivy\u4e2d\u8fd0\u884c\u3002\u53ef\u4ee5\u5728Kivy\u7684\u5b98\u65b9\u6587\u6863\u4e2d\u627e\u5230\u793a\u4f8b\u4ee3\u7801\u3002\u8fd9\u91cc\u4ee5\u4e00\u4e2a\u7b80\u5355\u7684\u201cHello World\u201d\u5e94\u7528\u7a0b\u5e8f\u4e3a\u4f8b\uff1a<\/p>\n<p>&#8220;`<\/p>\n<p>from kivy.app import App<\/p>\n<p>from kivy.uix.label import Label<\/p>\n<p>class HelloWorldApp(App):<\/p>\n<p>    def build(self):<\/p>\n<p>        return Label(text=&#8221;Hello World&#8221;)<\/p>\n<p>if __name__ == &#8216;__main__&#8217;:<\/p>\n<p>    HelloWorldApp().run()<\/p>\n<p>&#8220;`<\/p>\n<p>3. \u521b\u5efaBuildozer.spec\u6587\u4ef6<\/p>\n<p>Buildozer.spec\u6587\u4ef6\u662f\u4e00\u4e2a\u7528\u4e8e\u914d\u7f6e\u6253\u5305\u5e94\u7528\u7a0b\u5e8f\u7684\u6587\u4ef6\u3002\u53ef\u4ee5\u4f7f\u7528buildozer init\u547d\u4ee4\u521b\u5efa\u4e00\u4e2a\u65b0\u7684Buildozer.spec\u6587\u4ef6\u3002\u5728\u6587\u4ef6\u4e2d\u6dfb\u52a0\u4ee5\u4e0b\u4fe1\u606f\uff1a<\/p>\n<p>&#8220;`<\/p>\n<p>[app]<\/p>\n<p># (str) Title of your application<\/p>\n<p>title = HelloWorld<\/p>\n<p># (str) Package name<\/p>\n<p>package.name = helloworld<\/p>\n<p># (str) Package domain (needed for android\/ios packaging)<\/p>\n<p>package.domain = org.example<\/p>\n<p># (str) Source code where the main.py live<\/p>\n<p>source.dir<a href=\"https:\/\/www.yimenapp.net\/dabao-1968.html\">\u8f6f\u4ef6\u4e00\u952e\u8f6cios<\/a> = .<\/p>\n<p># (list) Source files to include (let empty to include all the files)<\/p>\n<p>source.include_exts = py,png,jpg,kv,atlas<\/p>\n<p># (list) Application requirements<\/p>\n<p># comma separated e.g. requirements = sqlite3,kivy<\/p>\n<p>requirement<\/p>\n<p><figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/i.cdn.yimenapp.com\/2023-03\/31\/15\/07792804256.jpg\" \/><\/figure>\n<\/p>\n<p>s = kivy<\/p>\n<p>[buildozer]<\/p>\n<p># (int) Log level (0 = error only, 1 = info, 2 = d<a href=\"https:\/\/www.yimenapp.net\/dabao-3878.html\">flutter ios \u6253\u5305\u53d1\u5e03<\/a>ebug (with command output))<\/p>\n<p>log_level = 2<\/p>\n<p># (str) Path to the android ndk<\/p>\n<p>android.ndk_path = \/path\/to\/android\/ndk<\/p>\n<p># (str) Path to the android sdk<\/p>\n<p>android.sdk_path = \/path\/to\/android\/sdk<\/p>\n<p># (str) Android API to use<\/p>\n<p>android.api = 19<\/p>\n<p># (str) Minimum API required<\/p>\n<p>android.minapi = 9<\/p>\n<p># (str) Android NDK version to use<\/p>\n<p>android.ndk = 8c<\/p>\n<p># (str) Python for android distribution to use<\/p>\n<p>android.python = 2.7<\/p>\n<p># (list) List of inclusions using pattern matching<\/p>\n<p>include_patterns = assets\/*,images\/*.png<\/p>\n<p># (list) List of exclusions using pattern matching<\/p>\n<p>exclude_patterns = license,README.md<\/p>\n<p># (str) Application versioning (method 1)<\/p>\n<p>version = 0.1<\/p>\n<p># (str) Application versioning (method 2)<\/p>\n<p>version.regex = __version__ = [&#8216;&#8221;](.*)[&#8216;&#8221;]<\/p>\n<p>version.filename = %(source.dir)s\/main.py<\/p>\n<p># (list) Application requirements for optional SDK modules (comma separated)<\/p>\n<p>android.arch = x86<\/p>\n<p># (str) OUYA Console category<\/p>\n<p>ouya.category = GAME<\/p>\n<p># (str) Filename of OUYA Console icon<\/p>\n<p>ouya.icon.filename = %(source.dir)s\/data\/icon.png<\/p>\n<p># (str) XML file to include as an intent filters in  tag<\/p>\n<p><p>android.manifest.intent_filters = intent_filters.xml<\/p>\n<p>&#8220;`<\/p>\n<p>4. \u6253\u5305\u5e94\u7528\u7a0b\u5e8f<\/p>\n<p>\u5728\u7ec8\u7aef\u4e2d\uff0c\u4f7f\u7528buildozer android debug\u547d\u4ee4\u6765\u6253\u5305\u5e94\u7528\u7a0b\u5e8f\u3002\u8fd9\u5c06\u4f7f\u7528Buildozer.spec\u6587\u4ef6\u4e2d\u7684\u914d\u7f6e\u4fe1\u606f\u6765\u7f16\u8bd1\u5e94\u7528\u7a0b\u5e8f\u3002<\/p>\n<p>&#8220;`<\/p>\n<p>buildozer android debug<\/p>\n<p>&#8220;`<\/p>\n<p>5. \u5b89\u88c5\u5e94\u7528\u7a0b\u5e8f<\/p>\n<p>\u5c06\u751f\u6210\u7684APK\u6587\u4ef6\u590d\u5236\u5230Android\u8bbe\u5907\u4e0a\uff0c\u5e76\u5728\u8bbe\u5907\u4e0a\u5b89\u88c5\u5b83\u3002\u53ef\u4ee5\u4f7f\u7528adb install\u547d\u4ee4\u6765\u5b89\u88c5\u5e94\u7528\u7a0b\u5e8f\u3002<\/p>\n<p>&#8220;`<\/p>\n<p>adb install HelloWorld-0.1-debug.apk<\/p>\n<p>&#8220;`<\/p>\n<p>\u603b\u7ed3\uff1a<\/p>\n<p>\u5c06Python\u6587\u4ef6\u6253\u5305\u6210APK\u9700\u8981\u4f7f\u7528Kivy\u548cBuildozer\u8fd9\u4e24\u4e2a\u5de5\u5177\u3002\u4f7f\u7528Buildozer.spec\u6587\u4ef6\u6765\u914d\u7f6e\u6253\u5305\u5e94\u7528\u7a0b\u5e8f\u7684\u8bbe\u7f6e\uff0c\u7136\u540e\u4f7f\u7528buildozer android debug\u547d\u4ee4\u6765\u6253\u5305\u5e94\u7528\u7a0b\u5e8f\u3002\u6700\u540e\uff0c\u5c06\u751f\u6210\u7684APK\u6587\u4ef6\u590d\u5236\u5230Android\u8bbe\u5907\u4e0a\u5e76\u5b89\u88c5\u5373\u53ef\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5c06Python\u6587\u4ef6\u6253\u5305\u6210APK\u662f\u4e00\u79cd\u5c06Python\u4ee3\u7801\u8f6c\u6362\u4e3aAndroid\u5e94\u7528\u7a0b\u5e8f\u7684\u65b9\u6cd5\u3002Python\u662f\u4e00\u79cd\u9ad8\u7ea7\u7f16\u7a0b\u8bed\u8a00\uff0c\u800cAndroid\u5e94\u7528\u7a0b\u5e8f\u662f\u4f7f\u7528Java\u7f16\u5199\u7684\u3002\u56e0\u6b64\uff0c\u5c06Python\u4ee3\u7801\u8f6c\u6362\u4e3a<\/p>\n","protected":false},"author":13,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[25530,11,81,195,25470],"topic":[],"class_list":["post-23269","post","type-post","status-publish","format-standard","hentry","category-appkfa","tag-ipa","tag-11","tag-81","tag-195","tag-25470"],"_links":{"self":[{"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/posts\/23269","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/users\/13"}],"replies":[{"embeddable":true,"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/comments?post=23269"}],"version-history":[{"count":1,"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/posts\/23269\/revisions"}],"predecessor-version":[{"id":23306,"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/posts\/23269\/revisions\/23306"}],"wp:attachment":[{"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/media?parent=23269"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/categories?post=23269"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/tags?post=23269"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/topic?post=23269"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}