吞脚 发表于 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
 

来源:程序园用户自行投稿发布,如果侵权,请联系站长删除
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!
页: [1]
查看完整版本: Uni-App 使用android studio打包最新教程