{"id":20145,"date":"2023-02-26T15:59:06","date_gmt":"2023-02-26T07:59:06","guid":{"rendered":"https:\/\/h5app.yimenapp.cn\/h5app\/2023\/appkfa\/20145\/"},"modified":"2023-02-26T15:59:06","modified_gmt":"2023-02-26T07:59:06","slug":"springboot%e6%89%93%e5%8c%85%e6%88%90apk%e6%96%b9%e6%b3%95%e4%bb%8b%e7%bb%8d","status":"publish","type":"post","link":"https:\/\/h5app.yimenapp.cn\/h5app\/2023\/appkfa\/20145\/","title":{"rendered":"springboot\u6253\u5305\u6210apk\u65b9\u6cd5\u4ecb\u7ecd"},"content":{"rendered":"<p>Spring Boot\u662f\u4e00\u4e2a\u5f00\u6e90\u7684Java\u6846\u67b6\uff0c\u7528\u4e8e\u6784\u5efa\u5fae\u670d\u52a1\u548cWeb\u5e94\u7528\u7a0b\u5e8f\u3002\u5b83\u4f7f\u7528\u7ea6\u5b9a\u4f18\u4e8e\u914d\u7f6e\u7684\u65b9\u5f0f\uff0c\u63d0\u4f9b\u4e86\u5feb\u901f\u5f00\u53d1\u548c\u8f7b\u91cf\u7ea7\u7684\u5e94\u7528\u7a0b\u5e8f\u6784\u5efa\u3002\u5728\u8fd9\u91cc\uff0c\u6211\u4eec\u5c06\u63a2\u8ba8\u5982\u4f55\u5c06Spring Boot\u5e94\u7528\u7a0b\u5e8f\u6253\u5305\u6210APK\u3002<\/p>\n<p>\u9996\u5148\uff0c\u6211\u4eec\u9700\u8981\u660e\u786e\u7684\u662f\uff0cAPK\uff08Android Package Kit\uff09\u662f\u4e00\u79cdAndroid\u5e94\u7528\u7a0b\u5e8f\u6587\u4ef6\u683c\u5f0f\uff0c\u5176\u6269\u5c55\u540d\u4e3a.apk\u3002\u56e0\u6b64\uff0c\u5c06Sprin<a href=\"https:\/\/www.yimenapp.net\/dabao-738.html\">WordPress\u5f00\u53d1app<\/a>g Boot\u5e94\u7528\u7a0b\u5e8f\u6253\u5305\u6210APK\uff0c\u5b9e\u9645\u4e0a\u662f\u5c06J<\/p>\n<p><figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/i.cdn.yimenapp.com\/2023-03\/31\/16\/29731292916.jpg\" \/><\/figure>\n<\/p>\n<p>ava\u5e94\u7528\u7a0b\u5e8f\u8f6c\u6362\u4e3aAndroid\u5e94\u7528\u7a0b\u5e8f\u3002\u8fd9\u662f\u901a\u8fc7\u4f7f\u7528Android SDK\u548cGradle\u63d2\u4ef6\u5b9e\u73b0\u7684\u3002<\/p>\n<p>\u4ee5\u4e0b\u662f\u5c06Spring Boot\u5e94\u7528\u7a0b\u5e8f\u6253\u5305\u6210APK\u7684\u6b65\u9aa4\uff1a<\/p>\n<p>1. \u5b89\u88c5Android SDK\u548cGradle\u63d2\u4ef6<\/p>\n<p>\u5728\u5f00\u59cb\u4e4b\u524d\uff0c\u60a8\u9700\u8981\u5b89\u88c5Android SDK\u548cGradle\u63d2\u4ef6\u3002Android SDK\u662f\u4e00\u4e2a\u5f00\u53d1\u5de5\u5177\u5305\uff0c\u5176\u4e2d\u5305\u542b\u7528\u4e8e\u6784\u5efaAndroid\u5e94\u7528\u7a0b\u5e8f\u7684\u5404\u79cd\u5de5\u5177\u548c\u5e93\u3002Gradle\u63d2\u4ef6\u662f\u4e00\u4e2a\u6784\u5efa\u5de5\u5177\uff0c\u7528\u4e8e\u5c06Java\u5e94\u7528\u7a0b\u5e8f\u8f6c\u6362\u4e3aAndroid\u5e94\u7528\u7a0b\u5e8f\u3002\u60a8\u53ef\u4ee5\u4eceAndroid\u5b98\u65b9\u7f51\u7ad9\u4e0b\u8f7d\u548c\u5b89\u88c5\u8fd9\u4e9b\u5de5\u5177\u3002<\/p>\n<p>2. \u521b\u5efaAndroid\u9879\u76ee<\/p>\n<p>\u4f7f\u7528Android Studio\u521b\u5efa\u4e00\u4e2a\u65b0\u7684Android\u9879\u76ee\u3002\u4e3a\u6b64\uff0c\u8bf7\u6253\u5f00Android Studio\uff0c\u5e76\u9009\u62e9\u201cFile\u201d &gt; \u201cNew\u201d &gt; \u201cNew Project\u201d\u3002\u5728\u201cCreate New Project\u201d\u5bf9\u8bdd\u6846\u4e2d\uff0c\u8f93\u5165\u5e94\u7528\u7a0b\u5e8f\u7684\u540d\u79f0\u548c\u5305\u540d\u79f0\uff0c\u5e76\u9009\u62e9\u201cEmpty Activity\u201d\u3002\u5355\u51fb\u201cFinish\u201d\u6309\u94ae\u521b\u5efa\u9879\u76ee\u3002<\/p>\n<p>3. \u6dfb\u52a0Gradle\u63d2\u4ef6<\/p>\n<p>\u5728\u9879\u76ee\u7684build.gradle\u6587\u4ef6\u4e2d\u6dfb\u52a0Gradle\u63d2\u4ef6\u3002\u4e3a\u6b64\uff0c\u8bf7\u6253\u5f00build.gradle\u6587\u4ef6\uff0c\u5e76\u6dfb\u52a0\u4ee5\u4e0b\u4ee3\u7801\uff1a<\/p>\n<p>&#8220;`<\/p>\n<p>apply plugin: &#8216;com.android.application&#8217;<\/p>\n<p>apply plugin: &#8216;com.github.dcendents.android-maven&#8217;<\/p>\n<p>apply plugin: &#8216;org.springframewo<a href=\"https:\/\/www.yimenapp.net\/dabao-2083.html\">\u5c01\u88c5ipa<\/a>rk.boot&#8217;<\/p>\n<p>&#8220;`<\/p>\n<p>\u8fd9\u4e9b\u63d2\u4ef6\u5c06\u5141\u8bb8\u60a8\u5c06Spring Boot\u5e94\u7528\u7a0b\u5e8f\u6253\u5305\u6210APK\u3002<\/p>\n<p>4. \u914d\u7f6eGradle\u63d2\u4ef6<\/p>\n<p>\u5728build.gradle\u6587\u4ef6\u4e2d\uff0c\u60a8\u9700\u8981\u914d\u7f6eGradle\u63d2\u4ef6\u4ee5\u5c06Spring Boot\u5e94\u7528\u7a0b\u5e8f\u6253\u5305\u6210APK\u3002\u4e3a\u6b64\uff0c\u8bf7\u6dfb\u52a0\u4ee5\u4e0b\u4ee3\u7801\uff1a<\/p>\n<p>&#8220;`<\/p>\n<p>android {<\/p>\n<p>    compileSdkVersion 29<\/p>\n<p>    buildToolsVersion &#8220;29.0.3&#8221;<\/p>\n<p>    defaultConfig {<\/p>\n<p>        applicationId &#8220;com.example.myapplication&#8221;<\/p>\n<p>        minSdkVersion 21<\/p>\n<p>        targetSdkVersion 29<\/p>\n<p>        versionCode 1<\/p>\n<p>        versionName &#8220;1.0&#8221;<\/p>\n<p>        testInstrumentationRunner &#8220;androidx.test.runner.AndroidJUnitRunner&#8221;<\/p>\n<p>    }<\/p>\n<p>    buildTypes {<\/p>\n<p>        release {<\/p>\n<p>            minifyEnabled false<\/p>\n<p>            proguardFiles getDefaultProguardFile(&#8216;proguard-android-optimize.txt&#8217;), &#8216;proguard-rules.pro&#8217;<\/p>\n<p>        }<\/p>\n<p>    }<\/p>\n<p>}<\/p>\n<p>springBoot {<\/p>\n<p>    mainClass = &#8216;com.example.myapplication.Application&#8217;<\/p>\n<p>    executable = true<\/p>\n<p>}<\/p>\n<p>dependencies {<\/p>\n<p>    implementation &#8216;org.springframework.boot:spring-boot-starter-web:2.2.6.RELEASE&#8217;<\/p>\n<p>    implementation &#8216;com.fasterxml.jackson.core:jackson-databind:2.10.3&#8217;<\/p>\n<p>    testImplementation &#8216;junit:junit:4.12&#8217;<\/p>\n<p>    androidTestImplementation &#8216;androidx.test.ext:junit:1.1.1&#8217;<\/p>\n<p>    androidTestImplementation &#8216;androidx.test.espresso:espresso-core:3.2.0&#8217;<\/p>\n<p>}<\/p>\n<p>&#8220;`<\/p>\n<p>\u5728\u8fd9\u91cc\uff0c\u60a8\u9700\u8981\u6307\u5b9a\u5e94\u7528\u7a0b\u5e8f\u7684\u540d\u79f0\u3001\u7248\u672c\u3001\u76ee\u6807SDK\u7248\u672c\u7b49\u3002\u60a8\u8fd8\u9700\u8981\u6307\u5b9aSpring Boot\u5e94\u7528\u7a0b\u5e8f\u7684\u4e3b\u7c7b\u548c\u53ef\u6267\u884c\u6587\u4ef6\u3002<\/p>\n<p>5. \u6253\u5305\u5e94\u7528\u7a0b\u5e8f<\/p>\n<p>\u73b0\u5728\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528Gradle\u547d\u4ee4\u5c06Spring Boot\u5e94\u7528\u7a0b\u5e8f\u6253\u5305\u6210APK\u3002\u4e3a\u6b64\uff0c\u8bf7\u6253\u5f00\u7ec8\u7aef\uff0c\u5e76\u5bfc\u822a\u5230\u9879\u76ee\u7684\u6839\u76ee\u5f55\u3002\u5728\u7ec8\u7aef\u4e2d\uff0c\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<p>&#8220;`<\/p>\n<p>.\/gradlew clean assembleDebug<\/p>\n<p>&#8220;`<\/p>\n<p>\u8fd9\u5c06\u7f16\u8bd1\u548c\u6253\u5305\u5e94\u7528\u7a0b\u5e8f\uff0c\u5e76\u5c06\u5176\u8f93\u51fa\u5230\u9879\u76ee\u7684build\/outputs\/apk\u76ee\u5f55\u4e2d\u3002<\/p>\n<p>6. \u8fd0\u884c\u5e94\u7528\u7a0b\u5e8f<\/p>\n<p>\u6700\u540e\uff0c\u60a8\u53ef\u4ee5\u5728Android\u6a21\u62df\u5668\u6216\u8bbe\u5907\u4e0a\u8fd0\u884c\u6253\u5305\u540e\u7684\u5e94\u7528\u7a0b\u5e8f\u3002\u4e3a\u6b64\uff0c\u8bf7\u6253\u5f00Android Studio\uff0c\u5e76\u9009\u62e9\u201cRun\u201d &gt; \u201cRun app\u201d\u3002\u8fd9\u5c06\u542f\u52a8\u6a21\u62df\u5668\u6216\u8fde\u63a5\u5230\u8bbe\u5907\uff0c\u5e76\u5728\u5176\u4e0a\u5b89\u88c5\u548c\u8fd0\u884c\u5e94\u7528\u7a0b\u5e8f\u3002<\/p>\n<p>\u603b\u7ed3<\/p>\n<p>\u5c06Spring Boot\u5e94\u7528\u7a0b\u5e8f\u6253\u5305\u6210APK\u9700\u8981\u4f7f\u7528Android SDK\u548cGradle\u63d2\u4ef6\u3002\u901a\u8fc7\u914d\u7f6eGradle\u63d2\u4ef6\uff0c\u60a8\u53ef\u4ee5\u5c06Spring Boot\u5e94\u7528\u7a0b\u5e8f\u8f6c\u6362\u4e3aAndroid\u5e94\u7528\u7a0b\u5e8f\uff0c\u5e76\u4f7f\u7528Gradle\u547d\u4ee4\u5c06\u5176\u6253\u5305\u3002\u6700\u540e\uff0c\u60a8\u53ef\u4ee5\u5728Android\u6a21\u62df\u5668\u6216\u8bbe\u5907\u4e0a\u8fd0\u884c\u6253\u5305\u540e\u7684\u5e94\u7528\u7a0b\u5e8f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Spring Boot\u662f\u4e00\u4e2a\u5f00\u6e90\u7684Java\u6846\u67b6\uff0c\u7528\u4e8e\u6784\u5efa\u5fae\u670d\u52a1\u548cWeb\u5e94\u7528\u7a0b\u5e8f\u3002\u5b83\u4f7f\u7528\u7ea6\u5b9a\u4f18\u4e8e\u914d\u7f6e\u7684\u65b9\u5f0f\uff0c\u63d0\u4f9b\u4e86\u5feb\u901f\u5f00\u53d1\u548c\u8f7b\u91cf\u7ea7\u7684\u5e94\u7528\u7a0b\u5e8f\u6784\u5efa\u3002\u5728\u8fd9\u91cc\uff0c\u6211\u4eec\u5c06\u63a2\u8ba8\u5982\u4f55\u5c06Spring Boot\u5e94\u7528\u7a0b\u5e8f<\/p>\n","protected":false},"author":16,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[15359,11,43,226,17484],"topic":[],"class_list":["post-20145","post","type-post","status-publish","format-standard","hentry","category-appkfa","tag-ios-","tag-11","tag-43","tag-226","tag-app"],"_links":{"self":[{"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/posts\/20145","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\/16"}],"replies":[{"embeddable":true,"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/comments?post=20145"}],"version-history":[{"count":0,"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/posts\/20145\/revisions"}],"wp:attachment":[{"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/media?parent=20145"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/categories?post=20145"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/tags?post=20145"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/topic?post=20145"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}