0
点赞
收藏
分享

微信扫一扫

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


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

  1. App离线SDK下载 我这边给大家放在资料里面了
  2. Android原生工程配置导入uni-app项目-混合开发_h5

  3. 新建Android项目Hello-H5
  4. Android原生工程配置导入uni-app项目-混合开发_h5_02

  5. 注意:Android项目目录不要有中文
  6. 拷贝android-gif-drawable-release@1.2.17.aar、lib.5plus.base-release.aar、miit_mdid_1.0.10.aar、uniapp-release.aar到libs下
  7. Android原生工程配置导入uni-app项目-混合开发_h5_03

  8. 在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'

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


5.uni-app配置时需要在build.gradle中添加aaptOptions配置

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

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


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>

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


7) 添加图片资源

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


8) 新建assets文件夹,添加子文件夹data和apps

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


9) 拷贝资源到data目录下

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


10) 修改dcloud_control.xml的值,这里我填写了helloh5,大家可以随便填写

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


11) 在apps下面新建helloh5\www文件夹,注意helloh5就是刚刚你们填写的appid值。

12) 打包Vue项目,注意修改manifest.json中appid的值,这个值就是Android中dcloud_control.xml的appid的值

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

命令打包:npm run build:app-plus

  1. 把编译出来的项目拷贝到Android中

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


举报

相关推荐

0 条评论