Android原生工程配置 官网配网地址:
https://nativesupport.dcloud.net.cn/AppDocs/usesdk/android
- App离线SDK下载 我这边给大家放在资料里面了
- 新建Android项目Hello-H5
- 注意:Android项目目录不要有中文
- 拷贝android-gif-drawable-release@1.2.17.aar、lib.5plus.base-release.aar、miit_mdid_1.0.10.aar、uniapp-release.aar到libs下
- 在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
- 把编译出来的项目拷贝到Android中