Android原生工程配置导入uni-app项目-混合开发

Android原生工程配置 官网配网地址:
https://nativesupport.dcloud.net.cn/AppDocs/usesdk/android

  1. App离线SDK下载 我这边给大家放在资料里面了
    在这里插入图片描述

  2. 新建Android项目Hello-H5
    在这里插入图片描述
    注意:Android项目目录不要有中文

  3. 拷贝android-gif-drawable-release@1.2.17.aar、lib.5plus.base-release.aar、miit_mdid_1.0.10.aar、uniapp-release.aar到libs下
    在这里插入图片描述

  4. 在build.gradle中添加资源引用

implementation fileTree(dir: 'libs', include: ['*.aar', '*.jar'], exclude: [])
implementation "com.android.support:support-v4:28.0.0"
implementation "com.android.support:appcompat-v7:28.0.0"
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.facebook.fresco:fresco:1.13.0'
implementation "com.facebook.fresco:animated-gif:1.13.0"
implementation 'com.github.bumptech.glide:glide:4.9.0'
implementation 'com.alibaba:fastjson:1.1.46.android'

在这里插入图片描述
5.uni-app配置时需要在build.gradle中添加aaptOptions配置

aaptOptions {  
  additionalParameters '--auto-add-overlay'  
  ignoreAssetsPattern "!.svn:!.git:.*:!CVS:!thumbs.db:!picasa.ini:!*.scc:*~"  
}

在这里插入图片描述
6. 在Androidmanifest.xml配置应用启动页

 <activity
      android:name="io.dcloud.PandoraEntry"
      android:configChanges="orientation|keyboardHidden|keyboard|navigation"
      android:label="@string/app_name"
      android:launchMode="singleTask"
      android:hardwareAccelerated="true"
      android:theme="@style/TranslucentTheme"
      android:screenOrientation="user"
      android:windowSoftInputMode="adjustResize" >
      <intent-filter>
          <action android:name="android.intent.action.MAIN" />
          <category android:name="android.intent.category.LAUNCHER" />
      </intent-filter>
  </activity>
  <activity
      android:name="io.dcloud.PandoraEntryActivity"
      android:launchMode="singleTask"
      android:configChanges="orientation|keyboardHidden|screenSize|mcc|mnc|fontScale|keyboard"
      android:hardwareAccelerated="true"
      android:permission="com.miui.securitycenter.permission.AppPermissionsEditor"
      android:screenOrientation="user"
      android:theme="@style/DCloudTheme"
      android:windowSoftInputMode="adjustResize">
      <intent-filter>
          <category android:name="android.intent.category.DEFAULT" />
          <category android:name="android.intent.category.BROWSABLE" />
          <action android:name="android.intent.action.VIEW" />
          <data android:scheme="h56131bcf" />
      </intent-filter>
  </activity>

在这里插入图片描述
7) 添加图片资源
在这里插入图片描述
8) 新建assets文件夹,添加子文件夹data和apps
在这里插入图片描述
9) 拷贝资源到data目录下
在这里插入图片描述
10) 修改dcloud_control.xml的值,这里我填写了helloh5,大家可以随便填写
在这里插入图片描述
11) 在apps下面新建helloh5\www文件夹,注意helloh5就是刚刚你们填写的appid值。
12) 打包Vue项目,注意修改manifest.json中appid的值,这个值就是Android中dcloud_control.xml的appid的值
在这里插入图片描述

命令打包:npm run build:app-plus
  1. 把编译出来的项目拷贝到Android中
    在这里插入图片描述

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值