• uniapp离线打包SDK


    1. 使用Android studio新建工程,选择Empty Activity,点击下一步

     2.配置基础参数,uniapp中不支持Kotlin,选择Java点击完成。

    3.将文件目录调整到Project下,默认是APP

     4.下载uniapp提供的工程文件,最新版本下载如下:

    Android离线SDK下载icon-default.png?t=M5H6https://nativesupport.dcloud.net.cn/AppDocs/download/android

    5.将latest\3.4.14\Android-SDK@3.4.14.81352_20220608\HBuilder-Integrate-AS\simpleDemo\libs中的内容放到test项目的libs文件夹下。

     6.配置打包资源 

            6.1. 在src/main文件夹下创建assets文件夹,在assets文件夹下创建apps和data文件夹

            6.2.将data下面的文件导入

            6.3.生成uniapp本地打包资源并放到apps文件夹下面

            6.4. 配置app图标和启动页,不仅要把默认的drawable文件夹配置了,圈中的不同尺寸也要配置不然打包时会报错找不到图标。

             6.5. 将mipmap-anydpi-v26文件夹下面的文件删掉。

    7. 配置参数

            7.1. 配置dcloud_control.xml文件中的 appid

             7.2. 配置app打包后显示在手机上的名称 

             7.3.配置AndroidManifest.xml文件中的参数,直接复制我下面的代码将原有文件覆盖,去修改 ,这里需要去申请Appkey

    uniapp申请Appkeyhttps://blog.csdn.net/weixin_44871749/article/details/125482403

    1. <?xml version="1.0" encoding="utf-8"?>
    2. <manifest xmlns:android="http://schemas.android.com/apk/res/android"
    3. xmlns:tools="http://schemas.android.com/tools"
    4. package="io.cloud.test">
    5. <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE"/>
    6. <uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"
    7. tools:ignore="ProtectedPermissions" />
    8. <uses-permission android:name="android.permission.VIBRATE"/>
    9. <uses-permission android:name="android.permission.READ_LOGS"
    10. tools:ignore="ProtectedPermissions" />
    11. <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
    12. <uses-feature android:name="android.hardware.camera.autofocus"/>
    13. <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    14. <uses-permission android:name="android.permission.CAMERA"/>
    15. <uses-permission android:name="android.permission.GET_ACCOUNTS"/>
    16. <uses-permission android:name="android.permission.READ_PHONE_STATE"/>
    17. <uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>
    18. <uses-permission android:name="android.permission.WAKE_LOCK"/>
    19. <uses-permission android:name="android.permission.FLASHLIGHT"/>
    20. <uses-feature android:name="android.hardware.camera"/>
    21. <uses-permission android:name="android.permission.WRITE_SETTINGS"
    22. tools:ignore="ProtectedPermissions" />
    23. <application
    24. android:allowBackup="true"
    25. android:icon="@mipmap/icon"
    26. android:label="@string/app_name"
    27. android:supportsRtl="true"
    28. android:theme="@style/Theme.Test">
    29. <!-- app的aookey在开发者中心申请的-->
    30. <meta-data
    31. android:name="dcloud_appkey"
    32. android:value="f486ba7ce87a8f2c1b0ac448e6f58d43" />
    33. <activity
    34. android:exported = "true"
    35. android:name="io.dcloud.PandoraEntry"
    36. android:configChanges="orientation|keyboardHidden|keyboard|navigation"
    37. android:launchMode="singleTask"
    38. android:hardwareAccelerated="true"
    39. android:theme="@style/TranslucentTheme"
    40. android:screenOrientation="user"
    41. android:windowSoftInputMode="adjustResize" >
    42. <intent-filter>
    43. <action android:name="android.intent.action.MAIN" />
    44. <category android:name="android.intent.category.LAUNCHER" />
    45. </intent-filter>
    46. </activity>
    47. <activity
    48. android:exported = "true"
    49. android:name="io.dcloud.PandoraEntryActivity"
    50. android:launchMode="singleTask"
    51. android:configChanges="orientation|keyboardHidden|screenSize|mcc|mnc|fontScale|keyboard|smallestScreenSize|screenLayout|screenSize"
    52. android:hardwareAccelerated="true"
    53. android:permission="com.miui.securitycenter.permission.AppPermissionsEditor"
    54. android:screenOrientation="user"
    55. android:theme="@style/DCloudTheme"
    56. android:windowSoftInputMode="adjustResize">
    57. <intent-filter>
    58. <category android:name="android.intent.category.DEFAULT" />
    59. <category android:name="android.intent.category.BROWSABLE" />
    60. <action android:name="android.intent.action.VIEW" />
    61. <data android:scheme="h56131bcf" />
    62. </intent-filter>
    63. </activity>
    64. </application>
    65. </manifest>

            7.4. 配置app下面的build.gradle文件,直接复制我下面的代码将原有文件覆盖,去修改 

    1. plugins {
    2. id 'com.android.application'
    3. }
    4. android {
    5. compileSdk 32
    6. defaultConfig {
    7. applicationId "io.cloud.test" 包名
    8. minSdk 21
    9. targetSdk 32
    10. versionCode 100 ///版本号
    11. versionName "1.0.0" //版本名称
    12. testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    13. }
    14. signingConfigs {
    15. config {
    16. keyAlias 'testalias' //别名
    17. keyPassword '123456' ///证书密码
    18. storeFile file('D:\\test.keystore') ///证书路径
    19. storePassword '123456' ///证书密码
    20. v1SigningEnabled true
    21. v2SigningEnabled true
    22. }
    23. }
    24. buildTypes {
    25. debug {
    26. signingConfig signingConfigs.config
    27. }
    28. release {
    29. minifyEnabled false
    30. proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    31. signingConfig signingConfigs.config
    32. }
    33. }
    34. aaptOptions {
    35. additionalParameters '--auto-add-overlay'
    36. ignoreAssetsPattern "!.svn:!.git:.*:!CVS:!thumbs.db:!picasa.ini:!*.scc:*~"
    37. }
    38. compileOptions {
    39. sourceCompatibility JavaVersion.VERSION_1_8
    40. targetCompatibility JavaVersion.VERSION_1_8
    41. }
    42. }
    43. dependencies {
    44. implementation 'androidx.appcompat:appcompat:1.4.2'
    45. implementation 'com.google.android.material:material:1.6.1'
    46. implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
    47. testImplementation 'junit:junit:4.13.2'
    48. androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    49. androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
    50. implementation fileTree(include: ['*.jar'], dir: 'libs')
    51. implementation fileTree(include: ['*.aar'], dir: 'libs')
    52. implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    53. /*uniapp所需库-----------------------开始*/
    54. implementation 'androidx.recyclerview:recyclerview:1.2.1'
    55. implementation 'com.facebook.fresco:fresco:2.5.0'
    56. implementation "com.facebook.fresco:animated-gif:2.5.0"
    57. /*uniapp所需库-----------------------结束*/
    58. // 基座需要,必须添加
    59. implementation 'com.github.bumptech.glide:glide:4.9.0'
    60. implementation 'com.alibaba:fastjson:1.1.46.android'
    61. }

            7.5. 配置test下面的gradle.properties文件

    1. # Project-wide Gradle settings.
    2. # IDE (e.g. Android Studio) users:
    3. # Gradle settings configured through the IDE *will override*
    4. # any settings specified in this file.
    5. # For more details on how to configure your build environment visit
    6. # http://www.gradle.org/docs/current/userguide/build_environment.html
    7. # Specifies the JVM arguments used for the daemon process.
    8. # The setting is particularly useful for tweaking memory settings.
    9. org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
    10. # When configured, Gradle will run in incubating parallel mode.
    11. # This option should only be used with decoupled projects. More details, visit
    12. # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
    13. # org.gradle.parallel=true
    14. # AndroidX package structure to make it clearer which packages are bundled with the
    15. # Android operating system, and which are packaged with your app"s APK
    16. # https://developer.android.com/topic/libraries/support-library/androidx-rn
    17. android.useAndroidX=true
    18. android.enableJetifier=true ///加入这个用于打包
    19. # Enables namespacing of each library's R class so that its R class includes only the
    20. # resources declared in the library itself and none from the library's dependencies,
    21. # thereby reducing the size of the R class for that library
    22. android.nonTransitiveRClass=true

    8.打包apk

      9. 查看打包文件

     

    10.大功告成,下面附上模块配置和本地原生插件的打包教程

    uniapp离线打包-模块配置https://blog.csdn.net/weixin_44871749/article/details/125482899 uniapp离线打包SDK-极光推送本地插件https://blog.csdn.net/weixin_44871749/article/details/125486741

  • 相关阅读:
    NC200369 四舍五入(枚举)
    计算分组后组内最大值
    3万字操作系统常用知识总结
    通过mxGraph在ARMxy边缘计算网关上实现工业物联网
    Spring Boot中使用JSR-303实现请求参数校验
    Qt5开发从入门到精通——第十一篇二节(Qt5 事件处理及实例——键盘事件及实例)
    vmware16安装macOS
    记一次 .NET 某医保平台 CPU 爆高分析
    lammps输出模拟结果的4种方法
    正则表达式提取器
  • 原文地址:https://blog.csdn.net/weixin_44871749/article/details/125478857