android studio怎样运行uniapp打包项目_uni app系列002:离线打包apk(2)

一、用AS新建空项目

新建项目后删除如图说明的文件

4dd85222c882762bd491c623081d1858.png

二、AndroidManifest.xml 替换如下的application内容

  

三、导入uni app本地资源文件

assets, apps需要自己创建目录

62a7b604937a08a961af9b8f52cf593c.pngfa8935a231e7bd5e148f6efbea1669ad.png

四、下载最新SDK

在 Dcloud里下载最新的SDK

下载解压后目录如下

828b09e5eac6464f5316e7f5f8ac9d0c.png
HBuilder-Hello:是HelloH5打包App的示例,可以用AS打包成APKHBuilder-Integrate-AS:是HBuilder 5+ SDK 集成AS的示例SDK:是HBuilder SDK库文件UniPlugin-Hello-AS:是开发插件并集成到Vue的示例

五、复制HBuilder-Hello项目的data到自己项目对应目录中

43614021ea7252e05106bc032d0e672c.pngc9aefd64b46e6b255fe06c5d59e45b9b.png

六、复制HBuilder-Hello项目的libs下的三个文件到自己项目对应目录中

14031b110dc0e39b1ba351c010992770.png

六、修改配置文件

1)dcloud_control.xml

febcd75184d6f7793ecd5b848acf4d38.png

七、开始打包

1)错误1

AndroidManifest.xml:13:9-26:20: AAPT: error: resource style/TranslucentTheme (aka com.ntc.test.uniapp:style/TranslucentTheme) not found.

这个错误,需要在build.gradle(Moudle app)中增加implementation fileTree(include: ['*.aar'], dir: 'libs'),以便在打包时将libs目录下的aar文件打包入apk

521ceae43361904945e823ab6f8fadf8.png

2)错误2

Manifest merger failed : uses-sdk:minSdkVersion 15 cannot be smaller than version 17 declared in library [android-gif-drawable-release@1.2.17.aar] C:甥敳獲Administrator.gradlecachesransforms-2files-2.1092de47bbd5688ebca77a3b9b43742bbandroid-gif-drawable-release@1.2.17AndroidManifest.xml as the library might be using APIs not available in 15

Suggestion: use a compatible library with a minSdk of at most 15,

or increase this project's minSdk version to at least 17,

or use tools:overrideLibrary="pl.droidsonroids.gif" to force usage (may lead to runtime failures)

这个错误,需要在build.gradle(Moudle app)中minSdkVersion改为 19

3)白屏

需要将build.gradle(Moudle app)中dependencies 换为如下

dependencies { implementation fileTree(include: ['*.jar'], dir: 'libs') implementation fileTree(include: ['*.aar'], dir: 'libs') /*uniapp所需库-----------------------开始*/ implementation 'com.android.support:recyclerview-v7:26.1.0' implementation 'com.alibaba.android:bindingx-core:1.0.3' implementation 'com.alibaba.android:bindingx_weex_plugin:1.0.3' implementation 'com.squareup.okhttp:okhttp:2.3.0' implementation 'com.squareup.okhttp:okhttp-ws:2.3.0' implementation 'com.alibaba:fastjson:1.1.46.android' implementation 'com.facebook.fresco:fresco:1.13.0' implementation "com.facebook.fresco:animated-gif:1.13.0" /*uniapp所需库-----------------------结束*/}

4)打出的包有20多M

需要在build.gradle(Moudle app)中defaultConfig下增加

ndk { abiFilters 'x86','armeabi-v7a'}
57bfe215d1361bbacf8fb1c413d644d7.png

增加后打出的包有16多M

八、完整的build.gradle(Moudle app)

apply plugin: 'com.android.application'android { compileSdkVersion 29 defaultConfig { applicationId "com.ntc.test.myapplication" minSdkVersion 19 targetSdkVersion 29 versionCode 1 versionName "1.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" ndk { abiFilters 'x86','armeabi-v7a' } } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } }}dependencies { implementation fileTree(include: ['*.jar'], dir: 'libs') implementation fileTree(include: ['*.aar'], dir: 'libs') /*uniapp所需库-----------------------开始*/ implementation 'com.android.support:recyclerview-v7:26.1.0' implementation 'com.alibaba.android:bindingx-core:1.0.3' implementation 'com.alibaba.android:bindingx_weex_plugin:1.0.3' implementation 'com.squareup.okhttp:okhttp:2.3.0' implementation 'com.squareup.okhttp:okhttp-ws:2.3.0' implementation 'com.alibaba:fastjson:1.1.46.android' implementation 'com.facebook.fresco:fresco:1.13.0' implementation "com.facebook.fresco:animated-gif:1.13.0" /*uniapp所需库-----------------------结束*/}


本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!

相关文章

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部