欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

HbuilderX 用android studio 本地打包app

程序员文章站 2024-01-24 18:04:46
...

新建MUI项目
HbuilderX 用android studio 本地打包app
生成本地资源包

android studio新建No acticity项目
HbuilderX 用android studio 本地打包app
切换至project模式
HbuilderX 用android studio 本地打包app
把下载的SDK文件中的libs目录下的 lib.5plus.base-release.aar 文件拷贝到项目下的的libs目录下
HbuilderX 用android studio 本地打包app
修改build.gradle文件,在dependencies 下新增依赖 implementation fileTree(dir: ‘libs’, include: [’*.aar’])

apply plugin: 'com.android.application'

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.2"
    defaultConfig {
        applicationId "com.example.start"
        minSdkVersion 15
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation fileTree(dir: 'libs', include: ['*.aar'])
    implementation 'androidx.appcompat:appcompat:1.1.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}

在AndroidMainfest.xml中的application标签中两个activity标签,内容如下

<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>

在src/main下新建文件夹assets与java文件夹同级,将SDK下的assets下data目录拷贝至src/main/assets目录下
在assets下新建apps目录,然后将HbuilderX生成的打包文件拷贝至apps目录下
assets下的目录结构必须是apps/APPID/www/,并且修改data/dcloud_control.xml的appid的值,保持和包名字一致
HbuilderX 用android studio 本地打包app