{"id":27097,"date":"2024-04-16T17:49:24","date_gmt":"2024-04-16T09:49:24","guid":{"rendered":"https:\/\/h5app.yimenapp.cn\/h5app\/?p=27097"},"modified":"2024-04-16T17:49:24","modified_gmt":"2024-04-16T09:49:24","slug":"kotlin%e6%89%93%e5%8c%85apk%e6%93%8d%e4%bd%9c%e6%b5%81%e7%a8%8b%e4%bb%8b%e7%bb%8d","status":"publish","type":"post","link":"https:\/\/h5app.yimenapp.cn\/h5app\/2024\/sjapp\/27097\/","title":{"rendered":"kotlin\u6253\u5305apk\u64cd\u4f5c\u6d41\u7a0b\u4ecb\u7ecd"},"content":{"rendered":"<p>Kotlin\u662f\u4e00\u79cd\u57fa\u4e8eJVM\u7684\u9759\u6001\u7c7b\u578b\u7f16\u7a0b\u8bed\u8a00\uff0c\u5b83\u4e0eJava\u5177\u6709\u5f88\u9ad8\u7684\u4e92\u64cd\u4f5c\u6027\u3002Kotlin\u7684\u51fa\u73b0\uff0c\u4f7f\u5f97Android\u5f00\u53d1\u53d8\u5f97\u66f4\u52a0\u7b80\u5355\u3001\u9ad8\u6548\u3001\u5b89\u5168\uff0c\u56e0\u6b64\u8d8a\u6765\u8d8a\u591a\u7684\u5f00\u53d1\u8005\u5f00\u59cb\u91c7\u7528Kotlin\u8fdb\u884cAndroid\u5f00\u53d1\u3002\u672c\u6587\u5c06\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528Kotlin\u6253\u5305APK\u3002<\/p>\n<p>\u4e00\u3001Kotlin\u6253\u5305APK\u7684\u539f\u7406<\/p>\n<p>Kotlin\u6253\u5305APK\u7684\u539f\u7406\u4e0eJava\u6253\u5305APK\u7684\u539f\u7406\u57fa\u672c\u76f8\u540c\uff0c\u5373\u5c06\u6240\u6709\u4ee3\u7801\u4e0e\u8d44\u6e90\u6587\u4ef6\u6253\u5305\u6210\u4e00\u4e2aAPK\u6587\u4ef6\uff0c\u7136\u540e\u5c06\u8be5\u6587\u4ef6\u5b89\u88c5\u5230Android\u8bbe\u5907\u4e0a\u3002Kotlin\u4ee3\u7801\u4e0eJava\u4ee3\u7801\u5728\u7f16\u8bd1\u540e\u90fd\u4f1a\u751f\u6210.dex\u6587\u4ef6\uff0c\u8fd9\u4e9b.dex\u6587\u4ef6\u5c06\u88ab\u6253\u5305\u5230APK\u6587\u4ef6\u4e2d\u3002<\/p>\n<p>\u4e8c\u3001Kotlin\u6253\u5305APK\u7684\u6b65\u9aa4<\/p>\n<p>1.\u521b\u5efaAndroid\u9879\u76ee<\/p>\n<p>\u9996\u5148\uff0c\u9700\u8981\u521b\u5efa\u4e00\u4e2aAndroid\u9879\u76ee\u3002\u5728\u521b\u5efa\u9879\u76ee\u7684\u8fc7\u7a0b\u4e2d\uff0c\u53ef\u4ee5\u9009\u62e9\u4f7f\u7528Kotlin\u4f5c\u4e3a\u4e3b\u8981\u7684\u7f16\u7a0b\u8bed\u8a00\u3002<\/p>\n<p>2.\u7f16\u5199Kotlin\u4ee3\u7801<\/p>\n<p>\u5728\u521b\u5efa\u5b8cAndroid\u9879\u76ee\u540e\uff0c\u5c31\u53ef\u4ee5\u5f00\u59cb\u7f16\u5199Kotlin\u4ee3\u7801\u4e86\u3002Kotlin\u4ee3\u7801\u4e0eJava\u4ee3\u7801\u7684\u7ed3\u6784\u7c7b\u4f3c\uff0c\u4f46\u662f\u8bed\u6cd5\u4e0a\u6709\u6240\u4e0d\u540c\u3002\u4e0b\u9762\u662f\u4e00\u4e2a\u7b80\u5355\u7684Kotlin\u4ee3\u7801\u793a\u4f8b\uff1a<\/p>\n<p>&#8220;`<\/p>\n<p>class MainActivity : AppCompatActivity() {<\/p>\n<p>    override fun onCreate(savedInstanceState: Bundle?) {<\/p>\n<p>        super.onCreate(savedInstanceState)<\/p>\n<p>        setContentView(R.layout.activity_main)<\/p>\n<p>    }<\/p>\n<p>}<\/p>\n<p>&#8220;`<\/p>\n<p>3.\u7f16\u8bd1Kotlin\u4ee3\u7801<\/p>\n<p>\u5b8c\u6210Kotlin\u4ee3\u7801\u7684\u7f16\u5199\u540e\uff0c\u9700\u8981\u5c06\u5176\u7f16\u8bd1\u6210.dex\u6587\u4ef6\u3002Kotlin\u4ee3\u7801\u53ef\u4ee5\u4f7f\u7528Kotlin\u7f16\u8bd1\u5668\u8fdb\u884c\u7f16\u8bd1\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528Android Studio\u81ea\u5e26\u7684Kotlin\u63d2\u4ef6\u8fdb\u884c\u7f16\u8bd1\u3002\u4f7f\u7528Kotlin\u7f16\u8bd1\u5668\u8fdb\u884c\u7f16\u8bd1\u7684\u65b9\u5f0f\u5982\u4e0b\uff1a<\/p>\n<p>&#8220;`<\/p>\n<p>kotlinc -include-runtime -d ap<\/p>\n<p><figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/i.yimenyun.net\/2023-03\/24\/10\/01894135785.jpg\" \/><\/figure>\n<\/p>\n<p>p.jar MainActivity.kt<\/p>\n<p>&#8220;`<\/p>\n<p>\u5176\u4e2d\uff0c-include-runtime\u53c2\u6570\u8868\u793a\u5c06Kotlin\u8fd0\u884c\u65f6\u5e93\u6253\u5305\u5230\u751f\u6210\u7684.jar\u6587\u4ef6\u4e2d\uff0c-d\u53c2\u6570\u8868\u793a\u6307\u5b9a\u751f\u6210\u7684.jar\u6587\u4ef6\u7684\u540d\u79f0\uff0cMainActivity.kt\u8868\u793a\u8981\u7f16\u8bd1\u7684Kotlin\u6587\u4ef6\u3002<\/p>\n<p>4.\u5c06.dex\u6587\u4ef6\u6253\u5305\u6210APK\u6587\u4ef6<\/p>\n<p>\u5b8c\u6210Kotlin\u4ee3\u7801\u7684\u7f16\u8bd1\u540e\uff0c\u5c31\u53ef\u4ee5\u5c06\u751f\u6210\u7684.dex\u6587\u4ef6\u6253\u5305\u6210APK\u6587\u4ef6\u4e86\u3002\u5c06.dex\u6587\u4ef6\u6253\u5305\u6210APK\u6587\u4ef6\u7684\u65b9\u5f0f\u4e0e\u5c06Java\u4ee3\u7801\u6253\u5305\u6210APK\u6587\u4ef6\u7684\u65b9\u5f0f\u57fa\u672c\u76f8\u540c\uff0c\u53ef\u4ee5\u4f7f\u7528Android Studio\u7684Gradle\u63d2\u4ef6\u8fdb\u884c\u6253\u5305\u3002\u5728\u9879\u76ee\u7684build.gradle\u6587\u4ef6\u4e2d\uff0c\u6dfb\u52a0\u4ee5\u4e0b\u4ee3\u7801\uff1a<\/p>\n<p>&#8220;`<\/p>\n<p>android {<\/p>\n<p>    &#8230;<\/p>\n<p>    defaultConfig {<\/p>\n<p>        &#8230;<\/p>\n<p>        multiDexEnable<a href=\"https:\/\/appdabao.yimenapp.com\/jiage-1619.html\">ios\u6253\u5305\u6d4b\u8bd5<\/a>d true<\/p>\n<p>    }<\/p>\n<p>    &#8230;<\/p>\n<p>}<\/p>\n<p>dependencies {<\/p>\n<p>    &#8230;<\/p>\n<p>    implementation &#8220;androidx.multidex:multidex:2.0.1&#8221;<\/p>\n<p>    &#8230;<\/p>\n<p>}<\/p>\n<p>&#8220;`<\/p>\n<p>\u5176\u4e2d\uff0cmultiDexEnabled\u53c2\u6570\u8868\u793a\u5f00\u542f\u591aDex\u652f\u6301\uff0cimplementation &#8220;androidx.multidex:multidex:2.0.1&#8243;\u8868\u793a\u5f15\u5165multidex\u5e93\u3002\u7136\u540e\uff0c\u5728\u9879\u76ee\u7684app\u6587\u4ef6\u5939\u4e0b\u521b\u5efa\u4e00\u4e2a\u540d\u4e3aproguard-rules.pro\u7684\u6587\u4ef6\uff0c\u5e76\u6dfb\u52a0\u4ee5\u4e0b\u4ee3\u7801\uff1a<\/p>\n<p>&#8220;`<\/p>\n<p>-keep class com.example.app.MainActivity{*;}<\/p>\n<p>&#8220;`<\/p>\n<p>\u8fd9\u91cc\u7684com.example.app.MainActivity\u8868\u793a\u8981\u4fdd\u7559\u7684\u7c7b\u540d\uff0c*\u8868\u793a\u4fdd\u7559\u8be5\u7c7b\u4e2d\u7684\u6240\u6709\u65b9\u6cd5\u548c\u5c5e\u6027\u3002\u6700\u540e\uff0c\u5728Android Studio\u7684Terminal\u4e2d\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<p>&#8220;`<\/p>\n<p>.\/gradle<a href=\"https:\/\/appdabao.yimenapp.com\/jiage-598.html\">\u82f9\u679c\u6253\u5305\u5c01\u88c5<\/a>w assembleDebug<\/p>\n<p>&#8220;`<\/p>\n<p>\u8fd9\u4e2a\u547d\u4ee4\u5c06\u4f1a\u6253\u5305\u51fa\u4e00\u4e2a\u540d\u4e3aapp-debug.apk\u7684\u6587\u4ef6\u3002<\/p>\n<p>5.\u5b89\u88c5APK\u6587\u4ef6<\/p>\n<p>\u5b8c\u6210APK\u6587\u4ef6\u7684\u6253\u5305\u540e\uff0c\u5c31\u53ef\u4ee5\u5c06\u5176\u5b89\u88c5\u5230Android\u8bbe\u5907\u4e0a\u4e86\u3002\u53ef\u4ee5\u4f7f\u7528Android Studio\u7684ADB\u5de5\u5177\u8fdb\u884c\u5b89\u88c5\uff0c\u4e5f\u53ef\u4ee5\u5c06APK\u6587\u4ef6\u62f7\u8d1d\u5230Android\u8bbe\u5907\u4e0a\u8fdb\u884c\u5b89\u88c5\u3002<\/p>\n<p>\u4e09\u3001\u603b\u7ed3<\/p>\n<p>\u672c\u6587\u4ecb\u7ecd\u4e86\u5982\u4f55\u4f7f\u7528Kotlin\u6253\u5305APK\u3002Kotlin\u662f\u4e00\u79cd\u975e\u5e38\u4f18\u79c0\u7684\u7f16\u7a0b\u8bed\u8a00\uff0c\u5b83\u5177\u6709\u5f88\u9ad8\u7684\u4e92\u64cd\u4f5c\u6027\uff0c\u53ef\u4ee5\u4e0eJava\u4ee3\u7801\u8fdb\u884c\u65e0\u7f1d\u8854\u63a5\u3002\u901a\u8fc7\u5b66\u4e60Kotlin\u6253\u5305APK\u7684\u8fc7\u7a0b\uff0c\u53ef\u4ee5\u66f4\u597d\u5730\u638c\u63e1Kotlin\u7684\u5f00\u53d1\u6280\u5de7\uff0c\u63d0\u9ad8Android\u5e94\u7528\u7684\u5f00\u53d1\u6548\u7387\u548c\u8d28\u91cf\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Kotlin\u662f\u4e00\u79cd\u57fa\u4e8eJVM\u7684\u9759\u6001\u7c7b\u578b\u7f16\u7a0b\u8bed\u8a00\uff0c\u5b83\u4e0eJava\u5177\u6709\u5f88\u9ad8\u7684\u4e92\u64cd\u4f5c\u6027\u3002Kotlin\u7684\u51fa\u73b0\uff0c\u4f7f\u5f97Android\u5f00\u53d1\u53d8\u5f97\u66f4\u52a0\u7b80\u5355\u3001\u9ad8\u6548\u3001\u5b89\u5168\uff0c\u56e0\u6b64\u8d8a\u6765\u8d8a\u591a\u7684\u5f00\u53d1\u8005\u5f00\u59cb\u91c7\u7528Kotlin\u8fdb\u884cAnd<\/p>\n","protected":false},"author":15,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[27530,27531,193,929,81],"topic":[],"class_list":["post-27097","post","type-post","status-publish","format-standard","hentry","category-sjapp","tag-html5ios","tag-vue3app","tag-193","tag-929","tag-81"],"_links":{"self":[{"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/posts\/27097","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\/15"}],"replies":[{"embeddable":true,"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/comments?post=27097"}],"version-history":[{"count":1,"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/posts\/27097\/revisions"}],"predecessor-version":[{"id":27262,"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/posts\/27097\/revisions\/27262"}],"wp:attachment":[{"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/media?parent=27097"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/categories?post=27097"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/tags?post=27097"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/topic?post=27097"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}