android之uniapp原生打包

需求:实现uniapp本地离线打包

参考:

https://blog.csdn.net/u011320682/article/details/88243562

https://blog.csdn.net/u012551928/article/details/84331339

https://ask.dcloud.net.cn/article/508

https://blog.csdn.net/similing/article/details/101770348?depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromBaidu-1&utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromBaidu-1

步骤:

第一步:新建一个简单的uniapp demo 如下图:

 第二步:生成本地打包资源

第三步:使用android studio 导入HBuilder-Hello工程

第四步:配置相关权限,把不用的删除掉,精简后如下图:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="io.dcloud.HelloH5">


    <application
        android:name="io.dcloud.application.DCloudApplication"
        android:allowClearUserData="true"
        android:icon="@drawable/icon"
        android:label="@string/app_name"
        android:largeHeap="true"
        android:debuggable="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>
        <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>
    </application>

</manifest>

第五步:精简libs库下面的包,删除不需要的包文件

 第六步:删除assets-》app--》下面的文件,拷贝Uniapp编译后的数据进来如下图:

 

 第七步:修改dcloud_control.xml的appid为uniapp的id,注意看这个id,和前面文件夹的id一样

 第八步:精简dcloud_properties.xml的内容,删除不必要的权限,精简后的如下图:

<properties>
	<features>
		<feature name="Barcode" value="io.dcloud.feature.barcode2.BarcodeFeatureImpl"/>
        <feature name="Speech" value="io.dcloud.feature.speech.SpeechFeatureImpl">
            <module name="iFly" value="io.dcloud.feature.speech.IflySpeechEngine"/>
            <module name="baidu" value="io.dcloud.feature.speech.BaiduSpeechEngine"/>
        </feature>
		<feature name="Maps" value="io.dcloud.js.map.amap.JsMapPluginImpl"/>
        <!--<feature name="Maps" value="io.dcloud.js.map.JsMapPluginImpl"/>-->
		<feature name="Contacts" value="io.dcloud.feature.contacts.ContactsFeatureImpl"/>
		<feature name="Messaging" value="io.dcloud.adapter.messaging.MessagingPluginImpl"/>
		<feature name="Camera" value="io.dcloud.js.camera.CameraFeatureImpl"/>
		<feature name="Console" value="io.dcloud.feature.pdr.LoggerFeatureImpl"/>
		<feature name="Device" value="io.dcloud.feature.device.DeviceFeatureImpl"/>
		<feature name="File" value="io.dcloud.js.file.FileFeatureImpl"/>
		<feature name="Proximity" value="io.dcloud.feature.sensor.ProximityFeatureImpl"/>
		<feature name="Storage" value="io.dcloud.feature.pdr.NStorageFeatureImpl"/>
		<feature name="Cache" value="io.dcloud.feature.pdr.CoreCacheFeatureImpl"/>
		<feature name="Invocation" value="io.dcloud.invocation.Invocation"/>
		<feature name="Navigator" value="io.dcloud.feature.ui.navigator.NavigatorUIFeatureImpl"/>
		<feature name="NativeUI" value="io.dcloud.feature.ui.nativeui.NativeUIFeatureImpl"/>
		<feature name="UI" value="io.dcloud.feature.ui.UIFeatureImpl">
			<module name="Navigator" value="io.dcloud.feature.ui.NavView"/>
		</feature>
		<feature name="Gallery" value="io.dcloud.js.gallery.GalleryFeatureImpl"/>
		<feature name="Downloader" value="io.dcloud.net.DownloaderFeatureImpl"/>
		<feature name="Uploader" value="io.dcloud.net.UploadFeature"/>
		<feature name="Push" value="io.dcloud.feature.aps.APSFeatureImpl">
			<module name="igexin" value="io.dcloud.feature.apsGt.GTPushService"/>
			<!-- mkeypush -->
		</feature>
		<feature name="Zip" value="io.dcloud.feature.pdr.ZipFeature"/>
		<feature name="Audio" value="io.dcloud.feature.audio.AudioFeatureImpl"/>
		<feature name="Runtime" value="io.dcloud.feature.pdr.RuntimeFeatureImpl"/>
        <feature name="VideoPlayer" value="io.dcloud.media.MediaFeatureImpl"/>
        <feature name="LivePusher" value="io.dcloud.media.live.LiveMediaFeatureImpl"/>
		<feature name="XMLHttpRequest" value="io.dcloud.net.XMLHttpRequestFeature"/>
		<feature name="Statistic" value="io.dcloud.feature.statistics.StatisticsFeatureImpl"/>
		<feature name="Accelerometer" value="io.dcloud.feature.sensor.AccelerometerFeatureImpl"/>
		<feature name="Orientation" value="io.dcloud.feature.sensor.OrientationFeatureImpl"/>
		<feature name="NativeObj" value="io.dcloud.feature.nativeObj.FeatureImpl"/>
	</features>

</properties>

第九步:修改app的名称在下图中修改

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值