1.安装Androidstudio
2.安装相关版本sdk
3.下载dcloud官方提供的sdk并解压.
4.androidstudio中导入HBuilder-Integrate-AS作为参考.
5.在andrioidstudio新建一个空项目,项目路径要建好,在后面配置中会使用,例如:com.zhuye.h5bank
6.在libs中导入所需jar包,可以从导入的demo中复制
[email protected] fastjson-1.2.78.jar lib.5plus.base-release.aar oaid_sdk_1.0.25.aar
7.在项目中main目录下创建apps文件夹:
H5Bank\app\src\main\assets\apps\项目appid(可以从dcloud官网控制台获取或mui项目的manifest.json中获取)\www\ (把mui项目粘进来除了unpackage目录)
8.在项目中main目录下创建data文件夹:
H5Bank\app\src\main\assets\data 并放入文件(可以从导入的demo中复制)
dcloud_control.xml dcloud_error.html dcloud_properties.xml
dcloud_control.xml中增加如下代码,appid根据实际项目获取
9.AndroidManifest.xml 配置权限
10.AndroidManifest.xml配置dcloud_appkey,该key需要去官网控制台申请.
key生成参考: Android平台签名证书(.keystore)生成指南 - DCloud问答
key申请参考:
原生开发者支持
生成命令: keytool -genkey -alias testalias -keyalg RSA -keysize 2048 -validity 36500 -keystore test.keystore 查看命令: keytool -list -v -keystore test.keystore key存储位置: C:\Program Files\Java\jre1.8.0_65\bin
key名称尽量与项目名称保持一致.
生成的key文件放到app目录下
在AndroidManifest.xml中application标签内增加key配置到码如下:
name:dcloud_appkey保持不变value从控制台生成后粘贴
11.签名信息配置
在build.gradle中配置签名信息如下:
signingConfigs { config { keyAlias 'testalias' keyPassword '666666' storeFile file('hello_login.keystore') storePassword '666666' v1SigningEnabled true v2SigningEnabled true } } buildTypes { debug { signingConfig signingConfigs.config minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } release { signingConfig signingConfigs.config minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } }
12.导入的jar包如果读取不到在build.gradle中导入如下代码
dependencies { implementation fileTree(dir: 'libs', include: ['*.aar', '*.jar'], exclude: []) implementation 'androidx.appcompat:appcompat:1.1.0' implementation 'com.google.android.material:material:1.1.0' implementation 'com.android.support:support-v4:30.4.1' testImplementation 'junit:junit:4.+' androidTestImplementation 'androidx.test.ext:junit:1.1.1' androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' compile 'com.nineoldandroids:library:2.4.0' compile 'com.github.bumptech.glide:glide:3.7.0' }
13.build.gradle代码整体参考:
plugins { id 'com.android.application' } android { compileSdkVersion 30 buildToolsVersion "30.0.2" defaultConfig { applicationId "com.zhuye.h5bank" minSdkVersion 21 targetSdkVersion 30 versionCode 1 versionName "1.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } signingConfigs { config { keyAlias 'testalias' keyPassword '666666' storeFile file('hello_login.keystore') storePassword '666666' v1SigningEnabled true v2SigningEnabled true } } buildTypes { debug { signingConfig signingConfigs.config minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } release { signingConfig signingConfigs.config minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } } repositories { flatDir { dirs 'libs' } } dependencies { implementation fileTree(dir: 'libs', include: ['*.aar', '*.jar'], exclude: []) implementation 'androidx.appcompat:appcompat:1.1.0' implementation 'com.google.android.material:material:1.1.0' implementation 'com.android.support:support-v4:30.4.1' testImplementation 'junit:junit:4.+' androidTestImplementation 'androidx.test.ext:junit:1.1.1' androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' compile 'com.nineoldandroids:library:2.4.0' compile 'com.github.bumptech.glide:glide:3.7.0' }
14.AndroidManifest.xml整体代码参考:
", ", ", ", ", ", ", ", ", ", ", ", ", "