吞脚 发表于 2025-10-1 19:05:57

Uni-App 使用android studio打包最新教程

 
字数 530,阅读大约需 3 分钟
Uni-App 使用android studio打包最新教程

1、下载uniapp离线sdk

Dcloud 官方平台地址Android 离线SDK - 正式版 | uni小程序SDK
2、找个自己的文件夹解压

注意文件夹不要带中文,android studio 不支持中文路径
3、生成App-Android 资源文件



4、将生成的app资源 放到第一步下载的sdk的HBuilder-Integrate-AS/simpleDemo 下将原有的文件删掉


复制整个文件夹到HBuilder-Integrate-AS/simpleDemo
<img alt="" >将原有的文件删掉,将文件复制到上图位置
5、使用android studio打开文件夹HBuilder-Integrate-AS

6、修改文件

1、manifests/AndroidManifest.xml
   <meta-data
<hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder>android:name="dcloud_appkey"
<hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder>android:value="dcloud的离线key" />离线key的地址是
应用列表
在列表里找到你的应用点进去
找到各平台信息复制整个android的值 覆盖原本的android:value="这里面的值"
7、修改Gradle Scripts下的Build.gradle

namespace 、和 applicationId的值修改成你使用云端证书的名字
名字在这里android {   <meta-data
<hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder>android:name="dcloud_appkey"
<hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder>android:value="dcloud的离线key" /> compileSdkVersion 35   <meta-data
<hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder>android:name="dcloud_appkey"
<hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder>android:value="dcloud的离线key" /> buildToolsVersion '35.0.0'   <meta-data
<hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder>android:name="dcloud_appkey"
<hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder>android:value="dcloud的离线key" /> namespace 'xds.tv'   <meta-data
<hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder>android:name="dcloud_appkey"
<hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder>android:value="dcloud的离线key" /> defaultConfig {   <meta-data
<hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder>android:name="dcloud_appkey"
<hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder>android:value="dcloud的离线key" />   <meta-data
<hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder>android:name="dcloud_appkey"
<hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder>android:value="dcloud的离线key" />  applicationId "xds.tv"   <meta-data
<hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder>android:name="dcloud_appkey"
<hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder>android:value="dcloud的离线key" />   <meta-data
<hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder>android:name="dcloud_appkey"
<hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder>android:value="dcloud的离线key" />  minSdkVersion 21   <meta-data
<hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder>android:name="dcloud_appkey"
<hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder>android:value="dcloud的离线key" />   <meta-data
<hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder>android:name="dcloud_appkey"
<hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder>android:value="dcloud的离线key" />  targetSdkVersion 33   <meta-data
<hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder>android:name="dcloud_appkey"
<hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder>android:value="dcloud的离线key" />   <meta-data
<hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder>android:name="dcloud_appkey"
<hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder>android:value="dcloud的离线key" />  versionCode 1   <meta-data
<hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder>android:name="dcloud_appkey"
<hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder>android:value="dcloud的离线key" />   <meta-data
<hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder>android:name="dcloud_appkey"
<hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder>android:value="dcloud的离线key" />  versionName "1.0"   <meta-data
<hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder>android:name="dcloud_appkey"
<hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder>android:value="dcloud的离线key" />   <meta-data
<hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder>android:name="dcloud_appkey"
<hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder>android:value="dcloud的离线key" />  multiDexEnabled true   <meta-data
<hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder>android:name="dcloud_appkey"
<hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder>android:value="dcloud的离线key" />   <meta-data
<hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder>android:name="dcloud_appkey"
<hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder>android:value="dcloud的离线key" />  compileOptions {   <meta-data
<hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder>android:name="dcloud_appkey"
<hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder>android:value="dcloud的离线key" />   <meta-data
<hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder>android:name="dcloud_appkey"
<hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder>android:value="dcloud的离线key" />   <meta-data
<hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder>android:name="dcloud_appkey"
<hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder>android:value="dcloud的离线key" />   <meta-data
<hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder>android:name="dcloud_appkey"
<hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder>android:value="dcloud的离线key" />sourceCompatibility JavaVersion.VERSION_1_8   <meta-data
<hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder>android:name="dcloud_appkey"
<hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder>android:value="dcloud的离线key" />   <meta-data
<hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder>android:name="dcloud_appkey"
<hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder>android:value="dcloud的离线key" />   <meta-data
<hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder>android:name="dcloud_appkey"
<hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder>android:value="dcloud的离线key" />   <meta-data
<hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder>android:name="dcloud_appkey"
<hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder>android:value="dcloud的离线key" />targetCompatibility JavaVersion.VERSION_1_8   <meta-data
<hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder>android:name="dcloud_appkey"
<hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder>android:value="dcloud的离线key" />   <meta-data
<hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder>android:name="dcloud_appkey"
<hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder>android:value="dcloud的离线key" />  }   <meta-data
<hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder>android:name="dcloud_appkey"
<hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder>android:value="dcloud的离线key" />   <meta-data
<hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder>android:name="dcloud_appkey"
<hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder>android:value="dcloud的离线key" />  ndk {   <meta-data
<hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder>android:name="dcloud_appkey"
<hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder>android:value="dcloud的离线key" />   <meta-data
<hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder>android:name="dcloud_appkey"
<hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder>android:value="dcloud的离线key" />   <meta-data
<hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder>android:name="dcloud_appkey"
<hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder>android:value="dcloud的离线key" />   <meta-data
<hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder>android:name="dcloud_appkey"
<hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder>android:value="dcloud的离线key" />abiFilters 'armeabi-v7a' // 配置的越少包的的体积越小   <meta-data
<hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder>android:name="dcloud_appkey"
<hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder>android:value="dcloud的离线key" />   <meta-data
<hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder>android:name="dcloud_appkey"
<hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder>android:value="dcloud的离线key" />   <meta-data
<hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder>android:name="dcloud_appkey"
<hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder>android:value="dcloud的离线key" />}   <meta-data
<hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder>android:name="dcloud_appkey"
<hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder>android:value="dcloud的离线key" /> }8、修改assets 文件的dcloud_control.xml 文件的appid

修改成你自己的appid
   <meta-data
<hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder>android:name="dcloud_appkey"
<hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder>android:value="dcloud的离线key" /> 9、打包




key store path 是从dcloud下载下来的证书

key store password 和key password 是证书的密钥 获取方式如下

key alias 就是你的appid
点击create 就开始构建app了 构建完成就可以安装

其他问题

1、打开apk提示appkey 未配置或者配置错误
一般是第七步或者是下载错证书导致的
2、如何修改app的名字和logo
app的名字在res/values/strings.xml内
   <meta-data
<hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder>android:name="dcloud_appkey"
<hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder><hbuilder>

    
</apps>
</hbuilder>android:value="dcloud的离线key" /> 你的appnamelogo 在res/drawable 将文件夹下的icon 和push替换掉就行了,其他的可以选择删除

3、修改打包的包名
右键你的simpleDemo点击rename 选择rename module 即可

引用链接

Android 离线SDK - 正式版 | uni小程序SDK: https://nativesupport.dcloud.net.cn/AppDocs/download/android.html
应用列表: https://dev.dcloud.net.cn/pages/app/list
 

来源:程序园用户自行投稿发布,如果侵权,请联系站长删除
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!

杭环 发表于 2025-10-19 21:59:17

谢谢分享,试用一下

晌集涟 发表于 2025-11-26 19:28:19

感谢发布原创作品,程序园因你更精彩

毋献仪 发表于 2025-11-30 01:16:26

不错,里面软件多更新就更好了

讣丢 发表于 2025-12-7 12:40:43

分享、互助 让互联网精神温暖你我

睿哝 发表于 2026-1-7 04:30:16

感谢,下载保存了

劳欣笑 发表于 2026-1-18 14:01:57

谢谢楼主提供!

迎脾 发表于 2026-1-18 18:34:21

yyds。多谢分享

后彼 发表于 2026-1-20 16:21:55

感谢分享,学习下。

谧怏弦 发表于 2026-1-21 18:28:48

不错,里面软件多更新就更好了

跑两獗 发表于 2026-1-22 11:08:15

这个好,看起来很实用

劳暄美 发表于 2026-1-22 13:33:35

这个好,看起来很实用

蓬庄静 发表于 2026-2-1 05:57:33

懂技术并乐意极积无私分享的人越来越少。珍惜

寂傧 发表于 2026-2-4 04:45:20

yyds。多谢分享

佟棠华 发表于 2026-2-5 05:55:50

前排留名,哈哈哈

赀倦 发表于 2026-2-6 05:58:51

分享、互助 让互联网精神温暖你我

国语诗 发表于 2026-2-7 04:36:58

鼓励转贴优秀软件安全工具和文档!

艾曼语 发表于 2026-2-7 10:10:02

谢谢楼主提供!

季卓然 发表于 2026-2-8 03:47:59

收藏一下   不知道什么时候能用到

梳踟希 发表于 2026-2-8 04:52:27

这个好,看起来很实用
页: [1] 2
查看完整版本: Uni-App 使用android studio打包最新教程