1、使用 Android Studio 创建一个 工程



2、删除 原生工程中 JAVA 目录下系统默认创建的源代码

3、复制SDK->libs->lib.5plus.base-release.aar文件到原生工程工程的app->libs目录下


4、打开工程的build.gradle文件
- 4.1 添加aar文件引用到dependenciesr如下代码
compile(name: 'lib.5plus.base-release', ext: 'aar')
- 4.2 添加aar文件搜索路径添到gradle文件,与dependencies同级, 代码如下
flatDir{
dirs 'libs'
}
build.gradle 文件
apply plugin: 'com.android.application'
android {
lintOptions {
checkReleaseBuilds false
abortOnError false
}
compileSdkVersion 26
defaultConfig {
applicationId "com.example.rh.test"
minSdkVersion 16
// targetSdkVersion 26
targetSdkVersion 21
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
// 添加 的代码
repositories {
flatDir {
dirs 'libs'
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
compile(name: 'lib.5plus.base-release', ext: 'aar') // 添加的代码
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
// 注释掉 这三个 测试 的 包
//testImplementation 'junit:junit:4.12'
//androidTestImplementation 'com.android.support.test:runner:1.0.2'
//androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

- 4.3 修改工程的
targetSdkVersion
为21

- 4.4
multiDexEnabled
设置成 false (我这里 创建的工程 默认为 false)

5、打开工程的Androidmanifest.xml
文件,复制以下内容替换该文件中原有application
节点下的内容
<application
android:name="io.dcloud.application.DCloudApplication"
android:allowClearUserData="true"
android:icon="@drawable/icon"
android:label="@string/app_name"
android:largeHeap="true"
>
<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>
</application>
替换后的 Androidmanifest.xml
文件
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.rh.test">
<!--<application-->
<!--android:allowBackup="true"-->
<!--android:icon="@mipmap/ic_launcher"-->
<!--android:label="@string/app_name"-->
<!--android:roundIcon="@mipmap/ic_launcher_round"-->
<!--android:supportsRtl="true"-->
<!--android:theme="@style/AppTheme">-->
<!--<activity android:name=".MainActivity">-->
<!--<intent-filter>-->
<!--<action android:name="android.intent.action.MAIN" />-->
<!--<category android:name="android.intent.category.LAUNCHER" />-->
<!--</intent-filter>-->
<!--</activity>-->
<!--</application>-->
<application
android:name="io.dcloud.application.DCloudApplication"
android:allowClearUserData="true"
android:icon="@drawable/icon"
android:label="@string/app_name"
android:largeHeap="true"
>
<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>
</application>
</manifest>
6 在app->src->res->drable目录下放应用的图标文件文件命名为 icon.png


7、 复制SDK->assets->data目录和目录下的文件到工程的src->main->assets目录下,新创建的工程默认没有assets目录,可在与java同级目录下创建assets目录


8、 Assets目录下创建apps目录,复制应用资源到apps目录下。 注意: 应用资源的路径为[appid]->www, appid为应用资源manifest.json文件中id节点的值
- 8.1 HBuilder X 创建项目 生成本地打包资源

- 8.2 将生成的打包资源 拷贝到 工程的 assets/apps 目录下

网友评论