做网站要多少,湖南监理建设协会网站,php网站挂到linux服务器上应该这么做,免费咨询律师在线一对一问答一 AndroidStudio创建项目
1.1#xff0c;上一节演示了uni-app云打包#xff0c;下面演示怎样androidStudio离线打包。在AndroidStudio里面新建空项目 1.2#xff0c;下载uni-app离线SDK#xff0c;离线SDK主要用于App本地离线打包及扩展原生能力#xff0c;SDK下载链接h…一 AndroidStudio创建项目
1.1上一节演示了uni-app云打包下面演示怎样androidStudio离线打包。在AndroidStudio里面新建空项目 1.2下载uni-app离线SDK离线SDK主要用于App本地离线打包及扩展原生能力SDK下载链接https://nativesupport.dcloud.net.cn/AppDocs/download/android.html# 1.3SDK目录说明 |-- HBuilder-Hello App离线打包演示应用 |-- HBuilder-Integrate-AS 集成uni-app的最简示例 |-- SDK SDK库文件目录 |-- Feature-Android.xls Android平台各扩展Feature API对应的详细配置 |-- Readme.txt 版本说明文件及注意事项 |-- UniPlugin-Hello-AS uni原生插件开发示例 1.4SDK目录后面androidStudio需要用到SDK里面资源 1.5 AndroidStudio配置uni-sdk将uni-sdk基础arr包复制到AndroidStudio的libs目录下 lib.5plus.base-release.aar android-gif-drawable-release1.2.23.aar uniapp-v8-release.aar oaid_sdk_1.0.25.aar install-apk-release.aar breakpad-build-release.aar 1.6拷贝assets里面的data目录到androidStudio里面的assets里面 1.7app目录的build.gradle配置项目依赖dependenciesAndroidX版本需添加如下资源 implementation fileTree(include: [*.jar], dir: libs) implementation fileTree(include: [*.aar], dir: libs) implementation androidx.appcompat:appcompat:1.0.0 implementation androidx.legacy:legacy-support-v4:1.0.0 implementation androidx.recyclerview:recyclerview:1.0.0 implementation com.facebook.fresco:fresco:2.5.0 implementation com.facebook.fresco:animated-gif:2.5.0 implementation com.github.bumptech.glide:glide:4.9.0 implementation com.alibaba:fastjson:1.2.83 implementation androidx.webkit:webkit:1.3.0 1.8 uni-app配置时需要在build.gradle中添加aaptOptions配置 aaptOptions { additionalParameters --auto-add-overlay ignoreAssetsPattern !.svn:!.git:.*:!CVS:!thumbs.db:!picasa.ini:!*.scc:*~ } 1.9 androidStudio配置支持aar加载新老gradle构建工具aar配置有所变化
老版本在app的build.gradle中配置 新版本在仓库级别里面配置项目根目录里面的build.gradle或者settings.gradle 1.10在app的build.gradle中引用aar 二uni-app项目打包app资源
2.1 获取appkey登录开发者平台注册为开发者https://dev.dcloud.net.cn/ 2.2 找到刚创建的uni-app项目 2.3 创建证书 2.3 查看证书并复制sha1值离线打包key会用到 2.4 点击离线打包key管理会跳到各平台信息配置配置sha1MD5SHA256和包名 appid就是androidStudio项目里面的applicationId 2.5 平台信息提交之后就可以创建key了 创建之后进行查看AppKey不区分debug和release模式Andorid如需要调试需要使用申请AppKey时的证书 2.6 打包uni-app资源包发行-原生app本地打包-生成app资源 控制台打包进度成功后打开目录将ID级的整个目录复制 2.7 androidStudio的assets创建一个apps的目录将app资源包拷贝到androidStudio项目的assets目录里面注意dcloud_control.xml里面的appid要改为对应的id。 2.8 androidStudio项目的app-build.gradle 里面也改为对应的版本 三androidStudio配置key
3.1 主APP的build.gradle文件的android节点下配置应用的签名信息先下载证书 3.2 配置正式签名和调试签名 signingConfigs { config { keyAlias __uni__ee84bbf keyPassword slvjh2d2 storeFile file(slvjh2d2.keystore) // 路径为相对路径或绝对路径 storePassword slvjh2d2 v1SigningEnabled true //兼容v1 v2SigningEnabled true //兼容v2 } } buildTypes { release { signingConfig signingConfigs.config minifyEnabled false proguardFiles getDefaultProguardFile(proguard-android-optimize.txt), proguard-rules.pro } debug { signingConfig signingConfigs.config minifyEnabled false proguardFiles getDefaultProguardFile(proguard-android-optimize.txt), proguard-rules.pro } } 3.3 Androidmanifest.xml配置key ?xml version1.0 encodingutf-8? manifest xmlns:androidhttp://schemas.android.com/apk/res/android xmlns:toolshttp://schemas.android.com/tools application ... meta-data android:namedcloud_appkey android:value替换为自己申请的Appkey / /manifest 3.4 配置清单的application和应用入口直接用unisdk的资源就行 整个清单文件如下
?xml version1.0 encodingutf-8?
manifest xmlns:androidhttp://schemas.android.com/apk/res/androidxmlns:toolshttp://schemas.android.com/toolsapplicationandroid:nameio.dcloud.application.DCloudApplicationandroid:allowBackuptrueandroid:dataExtractionRulesxml/data_extraction_rulesandroid:fullBackupContentxml/backup_rulesandroid:iconmipmap/ic_launcherandroid:labelstring/app_nameandroid:supportsRtltrueandroid:themestyle/Theme.UniApptools:targetApi31!-- 应用入口 --activityandroid:nameio.dcloud.PandoraEntryandroid:configChangesorientation|keyboardHidden|screenSize|mcc|mnc|fontScaleandroid:exportedtrueandroid:hardwareAcceleratedtrueandroid:themestyle/TranslucentThemeandroid:windowSoftInputModeadjustResizetools:ignoreWrongManifestParentintent-filterdata android:schemehbuilder /action android:nameandroid.intent.action.VIEW /category android:nameandroid.intent.category.DEFAULT /category android:nameandroid.intent.category.BROWSABLE //intent-filterintent-filterdata android:mimeTypeimage/* /action android:nameandroid.intent.action.SEND /category android:nameandroid.intent.category.DEFAULT //intent-filterintent-filteraction android:nameandroid.intent.action.MAIN /category android:nameandroid.intent.category.LAUNCHER //intent-filter/activitymeta-dataandroid:namedcloud_appkeyandroid:value221fedc4b1f1f2087f96c7120ca8d3b9 //application
/manifest
四 调试运行和打包
4.1 出现主题冲突错误 那就删掉项目中的style.xml ,同时清单文件里面的application的主题也更换为透明主题
修改前 修改后 再次运行可以安装成功了
4.2 安装后但运行失败报找不到activity类错误 然后对比了下SDK的清单发现确实少注册了一个类那就注册上
activityandroid:nameio.dcloud.PandoraEntryActivityandroid:launchModesingleTaskandroid:configChangesorientation|keyboardHidden|screenSize|mcc|mnc|fontScale|keyboard|smallestScreenSize|screenLayout|screenSize|uiModeandroid:hardwareAcceleratedtrueandroid:permissioncom.miui.securitycenter.permission.AppPermissionsEditorandroid:screenOrientationuserandroid:themestyle/DCloudThemeandroid:windowSoftInputModeadjustResizeandroid:exportedtrueintent-filtercategoryandroid:nameandroid.intent.category.DEFAULT /categoryandroid:nameandroid.intent.category.BROWSABLE /actionandroid:nameandroid.intent.action.VIEW /dataandroid:scheme //intent-filter
/activity
4.3 再次运行发现可以成功了跑起来了 4.4 androidStudio选择build-generate signed bundle//Apk打包apk 4.5 选择证书密钥 4.6 填写签名信息 4.7 选择创建正式包 4.8 OK打包成功 4.9 正式apk安装到手机也可以运行成功离线打包就完成了 4.10 主要步骤 新建uni项目生成uni-appid开发者平台生成密钥证书并生成appkey导出uni项目的app资源新建androidStudio项目拷贝aar新建assets的data拷贝app资源到androidStudio的apps目录androidStudio项目清单文件配置入口和appkey并统一appid和版本调试打包生成正式apk