第一步、在Hbuilder中先打包资源。点击菜单 发行—原生App-本地打包—生成本地App打包资源
第二步、在AndroidStudio项目,src/main/ 目录下新建assets目录,并且在assets目录下面新建apps目录和data目录,并且在apps目录下面新建以Hbuilder资源文件appid同名的目录,如H56753390,然后在H56753390目录下面新建www目录,再把生成的App打包资源文件复制到www目录。
第三步、在AndroidStudio配置文件AndroidManifest.xml插入下面的入口代码
<!--Hbuilder项目入口-->
<activity
android:name="io.dcloud.PandoraEntry"
android:configChanges="orientation|keyboardHidden|keyboard|navigation"
android:hardwareAccelerated="true"
android:label="@string/app_name"
android:launchMode="singleTask"
android:screenOrientation="user"
android:theme="@style/TranslucentTheme"
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:configChanges="orientation|keyboardHidden|screenSize|mcc|mnc|fontScale|keyboard"
android:hardwareAccelerated="true"
android:launchMode="singleTask"
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>
第四步、在app目录下新建libs目录,然后拷贝Hbuilder资源SDK到里面,文件名称如下图。
第五步、重构项目,根据错误提示进行配置修改,如下图。最后运行成功。加粗样式
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.testtest.testtest"
minSdkVersion 17
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}