林子浩 發表於 2024-4-29 09:18:17

分享一个APP的制作教程(教程来自互联网自行研究)

<strong>技术要求</strong><strong><font face="system-ui, -apple-system, BlinkMacSystemFont, &amp;quot"><font style="font-size:16px">你需要达到以下要求以完成对于专属应用的编译以及发布</font></font></font><ul><li>一台支持Android studio的计算机<li><font style="background-color:transparent">Android studio</font></font>(大陆地区可以使用Google.cn开发者网站下载<font style="background-color:transparent">https://developer.android.google.cn/studio</font></font>)<br /></ul></strong><br /><strong>准备</strong><font face="system-ui, -apple-system, BlinkMacSystemFont, &amp;quot"><font style="font-size:16px">首先,你需要下载Discuz Hub源代码。</font></font></font><font face="system-ui, -apple-system, BlinkMacSystemFont, &amp;quot"><font style="font-size:16px">源码地址:https://gitee.com/vez12/DiscuzHub</font></font></font><font face="system-ui, -apple-system, BlinkMacSystemFont, &amp;quot"><font style="font-size:16px"><img title="截图202404290909446609.jpg" id="aimg_29567" aid="29567" src1="static/image/common/none.gif" zoom="https://www.dismall.com/data/attachment/forum/202404/29/090944fz7vpxr64s8z16w4.jpg" src="https://www.dismall.com/data/attachment/forum/202404/29/090944fz7vpxr64s8z16w4.jpg" class="zoom" onclick="zoom(this, this.src, 0, 0, 0)" width="600" inpost="1" onmouseover="showMenu({'ctrlid':this.id,'pos':'12'})" /><br /></font></font></font><font face="system-ui, -apple-system, BlinkMacSystemFont, &amp;quot"><font style="font-size:16px">将下载的源代码(文件名可能是DiscuzHub-master.zip)解压到您存放源代码的文件夹</font></font></font><font face="system-ui, -apple-system, BlinkMacSystemFont, &amp;quot"><font style="font-size:16px">这样你就完成了对于源代码的下载。接着你需要开始使用Android studio这个官方IDE编译此应用。</font></font></font><br /><strong>使用并安装Android studio</strong><font face="system-ui, -apple-system, BlinkMacSystemFont, &amp;quot"><font style="font-size:16px">从<font style="background-color:transparent">Android studio</font></font>(大陆地区<font style="background-color:transparent">https://developer.android.google.cn/studio</font></font>)安装好应用后,你可能需要设置或下载一系列的软件和插件以能够编译Android应用。</font></font></font><font face="system-ui, -apple-system, BlinkMacSystemFont, &amp;quot"><font style="font-size:16px">我们的工程目前是支持Android 11版本的,请选择并下载此版本的SDK以完成编译。</font></font></font><font face="system-ui, -apple-system, BlinkMacSystemFont, &amp;quot"><font style="font-size:16px">使用Android studio打开存放源代码的文件夹。</font></font></font><br /><strong>1. 修改应用名称</strong><font face="system-ui, -apple-system, BlinkMacSystemFont, &amp;quot"><font style="font-size:16px">请在AndroidManifest.xml(路径:<font color="#ff0000">app\src\main\AndroidManifest.xml</font>)文件中,修改application目录下的android:label这个值为您论坛的名称。例如android:label=&quot;QZZN论坛&quot;</font></font><ol><li> &lt;application<br /><li>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;android:allowBackup=&quot;true&quot;<br /><li>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;android:icon=&quot;@mipmap/logo&quot;<br /><li>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;android:label=&quot;QZZN论坛&quot;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;android:networkSecurityConfig=&quot;@xml/network_security_config&quot;<br /><li>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;android:supportsRtl=&quot;true&quot;<br /><li>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;android:theme=&quot;@style/AppTheme.Default&quot;<br /><li>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;tools:ignore=&quot;GoogleAppIndexingWarning&quot;<br /><li>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;tools:targetApi=&quot;n&quot;&gt;</ol><br /><strong>国际化需求</strong><font face="system-ui, -apple-system, BlinkMacSystemFont, &amp;quot"><font style="font-size:16px">我们理解到部分论坛可能具有国际化任务的需求,那么请维持AndroidManifest.xml文件的android:label这个值,转而修改string.xml文件的app_name这个值。我们谨以keylol.com为例子。</font></font></font><font face="system-ui, -apple-system, BlinkMacSystemFont, &amp;quot"><font style="font-size:16px">keylol.com中文名称为其乐,英文名称为keylol。</font></font></font><font face="system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica Neue, sans-serif">在默认英文字符串文件(strings.xml,路径<font color="#ff0000">app\src\main\res\values\strings.xml</font>)中修改app_name为keylol,在中文字符串文件(src\main\res\values-zh-rCN\strings.xml)中修改app_name值为其乐。</font><br /><ol><li> &lt;application<br /><li>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;android:allowBackup=&quot;true&quot;<br /><li>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;android:icon=&quot;@mipmap/logo&quot;<br /><li>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;android:label=&quot;@string/app_name&quot;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;android:networkSecurityConfig=&quot;@xml/network_security_config&quot;<br /><li>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;android:supportsRtl=&quot;true&quot;<br /><li>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;android:theme=&quot;@style/AppTheme.Default&quot;<br /><li>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;tools:ignore=&quot;GoogleAppIndexingWarning&quot;<br /><li>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;tools:targetApi=&quot;n&quot;&gt;</ol><br /><strong>2. 修改应用ID</strong><font face="system-ui, -apple-system, BlinkMacSystemFont, &amp;quot"><font style="font-size:16px">应用ID相当于应用的身份证,一个应用应当只有一个ID。当相同的ID安装时,将会发生覆盖的情况,并且会干扰应用的运行。根据我们的使用条款且为了您的分发便利,您不应当使用我们的应用ID而应当转而使用自己的ID。我们以QZZN为例,其论坛使用的域名为bbs.qzzn.com,那么根据Google开发者指南推荐,你可以使用com.qzzn.bbs为应用ID。</font></font></font><font face="system-ui, -apple-system, BlinkMacSystemFont, &amp;quot"><font style="font-size:16px">在模块的Gradle文件中,修改android选项下的defaultConfig中的applicationId为 &quot;com.qzzn.bbs&quot; ,示例如下:</font></font></font><br /><ol><li>android {<br /><li>&nbsp; &nbsp; compileSdkVersion 30<br /><li>&nbsp; &nbsp; buildToolsVersion &quot;29.0.3&quot;<br /><li>&nbsp; &nbsp; defaultConfig {<br /><li>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;applicationId &quot;com.qzzn.bbs&quot;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;minSdkVersion 23<br /><li>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;targetSdkVersion 30<br /><li>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;versionCode 31<br /><li>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;versionName &quot;3.10&quot;<br /><li>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;testInstrumentationRunner &quot;androidx.test.runner.AndroidJUnitRunner&quot;<br /><li>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;manifestPlaceholders = [<br /><li>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; discuz_title: &quot;NOT_IMPLEMENTED&quot;,<br /><li>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; discuz_base_url: &quot;NOT_IMPLEMENTED&quot;,<br /><li>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;]<br /><li>&nbsp; &nbsp; }<br /><li>&nbsp; &nbsp; ...<br /><li>}</ol><font color="#000"><font face="system-ui, -apple-system, BlinkMacSystemFont, &amp;quot"><font style="font-size:16px">这样你就完成了applicationId的修改。</font></font></font><br /><br /><font color="#000"><font face="system-ui, -apple-system, BlinkMacSystemFont, &amp;quot"><font style="font-size:16px"><br /></font></font></font><br /><strong>修改构建类型的值</strong><br />在项目的gradle文件(相对路径:<font color="#ff0000">app/build.gradle</font>)下,我们提供了不同的构建类型,其对应着不同的分发版本,有着不同的功能<br /><ul><li>single:这个就是专属论坛使用的构建类型,在分发时,您应当选择此构建类型构建自己的应用并分发<li>release: 这个是我们分发Discuz Hub应用时的构建源,其支持多个论坛同时使用,这个不应当用于构建专属论坛。<li>debug:调试内容,这个不应用于生产环境<li>qzzn:一个以qzzn论坛为例的构建类型<br /></ul><br />请修改<font color="#ff0000">single</font>下的discuz_title以及discuz_base_url两个值。<br /><br /><ol><li>single {<br /><li>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;// fill your bbs id<br /><li>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;manifestPlaceholders = [<br /><li>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;discuz_title: &quot;论坛名称(如:西北工业大学三行四方)&quot;,&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;discuz_base_url: &quot;服务网址(如:https://bbs.example.com)&quot;,&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;]<br /><li>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'<br /><li>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;applicationIdSuffix &quot;.bbs&quot;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;}</ol><ul><li>discuz_title是论坛的名称,其将会被显示与开始页面,最终存入数据库的名称将以API为准<li>discuz_base_url是论坛的网址,这个参数非常重要,有的论坛服务在域名上(如bbs.qzzn.com),有的论坛则有一个路径(如一亩三分地: <font style="background-color:transparent">www.1point3acres.com/bbs</font></font>),你应当非常注意此值。同时网址也需要给上协议(如HTTP和HTTPS)。我们的应用虽然支持跳转,但是当你的论坛支持HTTPS协议时,请不要使用HTTP协议。<li>applicationIdSuffix会在最终的applicationId添加一个 .bbs 的后缀,因此最终编译出的applicationId将会是com.qzzn.bbs.bbs<br /></ul><font face="system-ui, -apple-system, BlinkMacSystemFont, &amp;quot"><font style="font-size:16px">这样就完成了应用的修改,接着就可以开始应用的构建了。</font></font></font><br /><strong>更换图标</strong><font face="system-ui, -apple-system, BlinkMacSystemFont, &amp;quot"><font style="font-size:16px">根据我们的使用政策,您不应当使用我们的图标来分发您的应用。因此,您需要使用自己的图标。</font></font></font><strong>准备图标</strong><font face="system-ui, -apple-system, BlinkMacSystemFont, &amp;quot"><font style="font-size:16px">我们推荐您使用SVG位图或者PNG、JPG等像素图像作为应用图标,尺寸大小应当是一个正方形或者类正方形。</font></font></font><font face="system-ui, -apple-system, BlinkMacSystemFont, &amp;quot"><font style="font-size:16px">| | SVG | PNG、JPG | | ---- | ---- | ---- | | 性质 | 位图 | 像素图 | | 分辨率 | 接近于无限,极好 | 较差 | | 兼容性 | 差,尤其是多图层、图形复杂时 | 好 |</font></font></font><font face="system-ui, -apple-system, BlinkMacSystemFont, &amp;quot"><font style="font-size:16px">我们理解到部分应用商店(例如小米应用商店)要求图标是PNG格式,因此请根据您的分发渠道确定图标格式。</font></font></font><strong>使用Android Studio导入</strong><font face="system-ui, -apple-system, BlinkMacSystemFont, &amp;quot"><font style="font-size:16px">在项目框中任一地方点击右键,呼出对话框。如果是位图SVG文件,选择New -&gt; Vector Asset,如果是PNG、JPG资源文件选择New -&gt; Image Asset。</font></font></font><font face="system-ui, -apple-system, BlinkMacSystemFont, &amp;quot"><font style="font-size:16px"><img title="截图202404290914034719.jpg" id="aimg_29568" aid="29568" src1="static/image/common/none.gif" zoom="https://www.dismall.com/data/attachment/forum/202404/29/091403szphmlo4q4qodoqu.jpg" src="https://www.dismall.com/data/attachment/forum/202404/29/091403szphmlo4q4qodoqu.jpg" class="zoom" onclick="zoom(this, this.src, 0, 0, 0)" width="600" inpost="1" onmouseover="showMenu({'ctrlid':this.id,'pos':'12'})" /><br /></font></font></font></font><font style="background-color:rgb(255, 255, 255)"><font face="system-ui, -apple-system, BlinkMacSystemFont, &amp;quot"><font style="font-size:16px">接下来选择你准备好的图片资源,选择好后,选择尺寸(建议100×100)</font></font></font></font><font style="background-color:rgb(255, 255, 255)"><font face="system-ui, -apple-system, BlinkMacSystemFont, &amp;quot"><font style="font-size:16px"><img title="截图202404290914184608.jpg" id="aimg_29569" aid="29569" src1="static/image/common/none.gif" zoom="https://www.dismall.com/data/attachment/forum/202404/29/091418vsi3u13lio7lil71.jpg" src="https://www.dismall.com/data/attachment/forum/202404/29/091418vsi3u13lio7lil71.jpg" class="zoom" onclick="zoom(this, this.src, 0, 0, 0)" width="600" inpost="1" onmouseover="showMenu({'ctrlid':this.id,'pos':'12'})" /><br /></font></font></font></font><font face="system-ui, -apple-system, BlinkMacSystemFont, &amp;quot"><font style="font-size:16px">点击next完成</font></font></font><strong>从Manifest中更改图标</strong><br />请在AndroidManifest.xml(路径:<font color="#ff0000">app\src\main\AndroidManifest.xml</font>)文件中,修改application目录下的android:icon这个值为您论坛的名称。如果是位图则是<font color="#ff0000">@drawable/刚刚生成的名字</font>,如果是像素则是<font color="#ff0000">@mipmap/刚刚生成的名字</font><br /><br /><ol><li> &lt;application<br /><li>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;android:allowBackup=&quot;true&quot;<br /><li>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;android:icon=&quot;@mipmap/logo&quot;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;android:label=&quot;@string/app_name&quot; <br /><li>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;android:networkSecurityConfig=&quot;@xml/network_security_config&quot;<br /><li>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;android:supportsRtl=&quot;true&quot;<br /><li>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;android:theme=&quot;@style/AppTheme.Default&quot;<br /><li>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;tools:ignore=&quot;GoogleAppIndexingWarning&quot;<br /><li>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;tools:targetApi=&quot;n&quot;&gt;</ol>我们建议使用位图图像,如果你想省事的话,直接复制PNG图片,替换mipmap下的logo.png(路径:<font color="#ff0000">/app/src/main/res/mipmap-xxxhdpi/logo.png</font>)文件即可<br /><br /><br /><strong>构建应用</strong><font face="system-ui, -apple-system, BlinkMacSystemFont, &amp;quot"><font style="font-size:16px">和正常的Android程序一样,首先你需要使用gradle构建一下整个项目。在导航栏中选择Build-&gt;Make Project完成项目的构建。</font></font></font><font face="system-ui, -apple-system, BlinkMacSystemFont, &amp;quot"><font style="font-size:16px"><img title="截图202404290915525825.jpg" id="aimg_29570" aid="29570" src1="static/image/common/none.gif" zoom="https://www.dismall.com/data/attachment/forum/202404/29/091552y4dxtxun2am5aukm.jpg" src="https://www.dismall.com/data/attachment/forum/202404/29/091552y4dxtxun2am5aukm.jpg" class="zoom" onclick="zoom(this, this.src, 0, 0, 0)" width="600" inpost="1" onmouseover="showMenu({'ctrlid':this.id,'pos':'12'})" /><br /></font></font></font><br /><strong>生成应用</strong></font><font style="background-color:rgb(255, 255, 255)"><font face="system-ui, -apple-system, BlinkMacSystemFont, &amp;quot"><font style="font-size:16px">在导航栏中选择Build-&gt;Generate Signed Bundle or APK,打开选中的框</font></font></font></font><font style="background-color:rgb(255, 255, 255)"><font face="system-ui, -apple-system, BlinkMacSystemFont, &amp;quot"><font style="font-size:16px"><img title="截图202404290916331473.jpg" id="aimg_29571" aid="29571" src1="static/image/common/none.gif" zoom="https://www.dismall.com/data/attachment/forum/202404/29/091633mjg64gehegexxkkg.jpg" src="https://www.dismall.com/data/attachment/forum/202404/29/091633mjg64gehegexxkkg.jpg" class="zoom" onclick="zoom(this, this.src, 0, 0, 0)" width="549" inpost="1" onmouseover="showMenu({'ctrlid':this.id,'pos':'12'})" /><br /></font></font></font></font><font style="background-color:rgb(255, 255, 255)"><font face="system-ui, -apple-system, BlinkMacSystemFont, &amp;quot"><font style="font-size:16px">选择你需要分发的应用类型,我们以分发APK为例,选择APK,点击Next。<br /></font></font></font></font><font style="background-color:rgb(255, 255, 255)"><font face="system-ui, -apple-system, BlinkMacSystemFont, &amp;quot"><font style="font-size:16px"><br /></font></font></font></font><strong>选择密钥库</strong></font><font style="background-color:rgb(255, 255, 255)"><font face="system-ui, -apple-system, BlinkMacSystemFont, &amp;quot"><font style="font-size:16px">当你首次生成安装文件时,你需要创建一个密钥库(keystore)对安装包进行加密,并验证你的身份。如果你之前有密钥库,你可以选择Choose exisiting以选择密钥库。<br /></font></font></font></font><font style="background-color:rgb(255, 255, 255)"><font face="system-ui, -apple-system, BlinkMacSystemFont, &amp;quot"><font style="font-size:16px"><img title="截图202404290916596756.jpg" id="aimg_29572" aid="29572" src1="static/image/common/none.gif" zoom="https://www.dismall.com/data/attachment/forum/202404/29/091659eun7sgemkh68mkeq.jpg" src="https://www.dismall.com/data/attachment/forum/202404/29/091659eun7sgemkh68mkeq.jpg" class="zoom" onclick="zoom(this, this.src, 0, 0, 0)" width="600" inpost="1" onmouseover="showMenu({'ctrlid':this.id,'pos':'12'})" /><br /></font></font></font></font><font style="background-color:rgb(255, 255, 255)"><font face="system-ui, -apple-system, BlinkMacSystemFont, &amp;quot"><font style="font-size:16px">若你没有密钥库,请选择Create New以创建新的密钥库。<br /></font></font></font></font><font style="background-color:rgb(255, 255, 255)"><font face="system-ui, -apple-system, BlinkMacSystemFont, &amp;quot"><font style="font-size:16px"><img title="截图202404290917131147.jpg" id="aimg_29573" aid="29573" src1="static/image/common/none.gif" zoom="https://www.dismall.com/data/attachment/forum/202404/29/091713yccz7eelyop474ec.jpg" src="https://www.dismall.com/data/attachment/forum/202404/29/091713yccz7eelyop474ec.jpg" class="zoom" onclick="zoom(this, this.src, 0, 0, 0)" width="600" inpost="1" onmouseover="showMenu({'ctrlid':this.id,'pos':'12'})" /><br /></font></font></font></font><font style="background-color:rgb(255, 255, 255)"><font face="system-ui, -apple-system, BlinkMacSystemFont, &amp;quot"><font style="font-size:16px">填上上面的信息后,相应路径下就会生成密钥库文件。<br /></font></font></font></font><font style="background-color:rgb(255, 255, 255)"><font face="system-ui, -apple-system, BlinkMacSystemFont, &amp;quot"><font style="font-size:16px">选择密钥库并填上密钥和密码,点击Next。<br /></font></font></font></font><strong><br /></strong><strong>选择构建类型</strong><font face="system-ui, -apple-system, BlinkMacSystemFont, &amp;quot"><font style="font-size:16px">请选择single,构建专属于您论坛的应用。建议同时选择上签名版本v1和v2。点击finish开始生成安装包apk。</font></font></font><font face="system-ui, -apple-system, BlinkMacSystemFont, &amp;quot"><font style="font-size:16px"><img title="截图202404290917473539.jpg" id="aimg_29574" aid="29574" src1="static/image/common/none.gif" zoom="https://www.dismall.com/data/attachment/forum/202404/29/091747ozc6y66ql8mqa8qa.jpg" src="https://www.dismall.com/data/attachment/forum/202404/29/091747ozc6y66ql8mqa8qa.jpg" class="zoom" onclick="zoom(this, this.src, 0, 0, 0)" width="600" inpost="1" onmouseover="showMenu({'ctrlid':this.id,'pos':'12'})" /><br /></font></font></font><font face="system-ui, -apple-system, BlinkMacSystemFont, &amp;quot"><font style="font-size:16px">等待生成完毕后,生成的APK文件就可以用于分发以及安装。</font></font></font><font face="system-ui, -apple-system, BlinkMacSystemFont, &amp;quot"><font style="font-size:16px">这样,你就完成了应用的构建</font></font></font><br /><br />var<em>, </em>left

湖中沉 發表於 2024-8-31 11:42:55

感谢分享……虽然应该是转载的

bug八阿哥 發表於 2024-9-1 14:41:29

感谢分享……虽然应该是转载的

CMS7 發表於 2024-12-7 00:35:47

正在尝试编译中
頁: [1]
查看完整版本: 分享一个APP的制作教程(教程来自互联网自行研究)