备注:uni-app各环节版本兼容性说明。
1. HBuilderX2.0.1.20190614
升级到 HBuilderX2.2.2.20190816
- 问题:原生扫码插件扫码黑屏无法使用
- 原因:原生扫码插件源代码未对只有一个前置摄像头的情况进行合适的处理
- 解决:修改插件源码
2. HBuilderX2.2.2.20190816—>HBuilderX2.3.6.20191020
—>HBuilderX2.3.7.20191024
升级程序无问题
3. HBuilderX2.3.7.20191024 升级到 HBuilderX2.4.2.20191115
-
问题:真机运行无法成功编译,云打包也出错
- 原因:未知
- 解决:暂时从HBuilderX2.4.2.20191115回退到
HBuilderX2.3.7.20191024
4. HBuilderX2.3.7.20191024 版本年前云打包正常,年后云打包报错
-
打包警告提醒
警告:当前编译器版本HBuilderX2.3.7(HBuilderX版本即编译器版本)与云服务器端的编译器版本2.5.1不一致,可能导致兼容性问题。
- 忽略警告后继续进行云打包时报错信息如下
Appid: __UNI__E1651CC
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':transformClassesWithMultidexlistForRelease'.
> com.android.build.api.transform.TransformException: Error while generating the main dex list.
* Try:
Run with --debug option to get more log output. Run with --scan to get full insights.
* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':transformClassesWithMultidexlistForRelease'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:110)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:77)
at org.gradle.api.internal.tasks.execution.OutputDirectoryCreatingTaskExecuter.execute(OutputDirectoryCreatingTaskExecuter.java:51)
at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:59)
at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:59)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:101)
at org.gradle.api.internal.tasks.execution.FinalizeInputFilePropertiesTaskExecuter.execute(FinalizeInputFilePropertiesTaskExecuter.java:44)
at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:91)
at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:62)
at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:59)
at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.run(EventFiringTaskExecuter.java:51)
at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:300)
at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:292)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:174)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90)
at org.gradle.internal.operations.DelegatingBuildOperationExecutor.run(DelegatingBuildOperationExecutor.java:31)
at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter.execute(EventFiringTaskExecuter.java:46)
at org.gradle.execution.taskgraph.LocalTaskInfoExecutor.execute(LocalTaskInfoExecutor.java:42)
at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareWorkItemExecutor.execute(DefaultTaskExecutionGraph.java:277)
at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareWorkItemExecutor.execute(DefaultTaskExecutionGraph.java:262)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$ExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:135)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$ExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:130)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$ExecutorWorker.execute(DefaultTaskPlanExecutor.java:200)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$ExecutorWorker.executeWithWork(DefaultTaskPlanExecutor.java:191)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$ExecutorWorker.run(DefaultTaskPlanExecutor.java:130)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
Caused by: java.lang.RuntimeException: com.android.build.api.transform.TransformException: Error while generating the main dex list.
at com.android.builder.profile.Recorder$Block.handleException(Recorder.java:55)
at com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:104)
at com.android.build.gradle.internal.pipeline.TransformTask.transform(TransformTask.java:230)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
at org.gradle.api.internal.project.taskfactory.IncrementalTaskAction.doExecute(IncrementalTaskAction.java:50)
at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:39)
at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:26)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:131)
at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:300)
at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:292)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:174)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90)
at org.gradle.internal.operations.DelegatingBuildOperationExecutor.run(DelegatingBuildOperationExecutor.java:31)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:120)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:99)
... 31 more
Caused by: com.android.build.api.transform.TransformException: Error while generating the main dex list.
at com.android.build.gradle.internal.transforms.D8MainDexListTransform.transform(D8MainDexListTransform.kt:144)
at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:239)
at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:235)
at com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:102)
... 44 more
Caused by: com.android.builder.multidex.D8MainDexList$MainDexListException: com.android.tools.r8.errors.CompilationError: Program type already present: com.alibaba.android.bindingx.core.BindingXCore$JavaScriptCallback
at com.android.builder.multidex.D8MainDexList.generate(D8MainDexList.java:87)
at com.android.build.gradle.internal.transforms.D8MainDexListTransform.transform(D8MainDexListTransform.kt:131)
... 47 more
Caused by: com.android.tools.r8.errors.CompilationError: Program type already present: com.alibaba.android.bindingx.core.BindingXCore$JavaScriptCallback
at com.android.tools.r8.utils.ProgramClassCollection.resolveClassConflictImpl(ProgramClassCollection.java:64)
at com.android.tools.r8.utils.ProgramClassCollection.lambda$create$0(ProgramClassCollection.java:25)
at com.android.tools.r8.utils.ProgramClassCollection.create(ProgramClassCollection.java:24)
at com.android.tools.r8.graph.LazyLoadedDexApplication$Builder.build(LazyLoadedDexApplication.java:124)
at com.android.tools.r8.dex.ApplicationReader.read(ApplicationReader.java:123)
at com.android.tools.r8.dex.ApplicationReader.read(ApplicationReader.java:86)
at com.android.tools.r8.GenerateMainDexList.run(GenerateMainDexList.java:40)
at com.android.tools.r8.GenerateMainDexList.run(GenerateMainDexList.java:110)
at com.android.builder.multidex.D8MainDexList.generate(D8MainDexList.java:83)
... 48 more* Get more help at https://help.gradle.org
BUILD FAILED in 20s
开始根据警告信息以为是当前编译器版本(HBuilderX版本即编译器版本)与云服务器端的编译器版本不一致导致打包失败,所以点击“升级HBuilderX” 将HBuilderX2.3.7.20191024(编译器版本:2.3.7)升级到了最新的
HBuilderX2.6.1.20200226
(编译器版本:2.6.1),此时云打包仍报错;根据警告信息表明云服务器端的编译器版本为2.5.1,所以又降级到和云端服务器一致的版本HBuilderX2.5.1.20190103
(编译器版本:2.5.1),但是云打包仍报错。
- 分析:云打包报错信息
Caused by: com.android.tools.r8.errors.CompilationError: Program type already present: com.alibaba.android.bindingx.core.BindingXCore$JavaScriptCallback
- 可能原因:使用的原生插件(Android第三方aar文件)与和uni-app原生打包环境(云端打包环境)冲突。
- 解决:注释依赖库
bindingx-core
和bindingx_weex_plugin
,即
原生插件的builde.gradle文件中注释掉依赖库bindingx-core
和bindingx_weex_plugin
,并重新生成aar包
apply plugin: 'com.android.library'
android {
compileSdkVersion 28
buildToolsVersion "28.0.3"
defaultConfig {
minSdkVersion 19
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
// 消除警告并定位到警告位置:使用或覆盖了已过时的 API,有关详细信息, 请使用 -Xlint:deprecation 重新编译。
allprojects {
gradle.projectsEvaluated {
tasks.withType(JavaCompile){
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
}
}
}
}
repositories {
flatDir {
dirs 'libs'
}
}
dependencies {
compileOnly fileTree(dir: 'libs', include: ['*.jar'])
compileOnly fileTree(dir: '../app/libs', include: ['dc_weexsdk-release.aar', 'uniapp-release.aar'])
// 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'
implementation "com.android.support:recyclerview-v7:27.0.0"
implementation 'com.android.support:support-v4:27.0.0'
implementation 'com.android.support:appcompat-v7:27.0.0'
// implementation 'com.alibaba.android:bindingx-core:1.0.3'
// implementation 'com.alibaba.android:bindingx_weex_plugin:1.0.3'
implementation 'com.journeyapps:zxing-android-embedded:3.6.0'
implementation 'com.alibaba:fastjson:1.1.46'
}
替换uniapp项目中原生插件的aar包,并在package.json文件中注释掉依赖库bindingx-core
和bindingx_weex_plugin
{
"name": "MyScanCode",
"id": "My-ScanCode",
"version": "0.0.1",
"description": "扫码",
"_dp_type":"nativeplugin",
"_dp_nativeplugin":{
"android": {
"plugins": [
{
"type": "module",
"name": "My-ScanCode",
"class": "com.osmium.myscancode.ScanCodeWXModule"
}
],
"integrateType": "aar",
"minSdkVersion" : 16,
"dependencies": [
// "com.alibaba.android:bindingx-core:1.0.3",
// "com.alibaba.android:bindingx_weex_plugin:1.0.3",
"com.journeyapps:zxing-android-embedded:3.6.0"
]
}
}
}
5. 年后使用 HBuilderX2.5.1.20190103
运行编译年前创建的测试demo报错
分析:原因尚未可知。
解决:删除项目的node_modeles文件件并重新运行项目即可。
备注:删除后若出现如下报错信息,在菜单栏->工具->插件安装,安装对应插件即可。
6. HBuilderX2.5.1.20190103 升级到 HBuilderX2.6.11.20200409
云打包无问题,但是安装到真机后界面样式出现问题,原因未知,暂时回退到
HBuilderX2.5.1.20190103
版本。
7. 重装系统后安装 HBuilderX2.3.7.20191024
-
打包警告提醒
警告:当前编译器版本HBuilderX2.3.7(HBuilderX版本即编译器版本)与云服务器端的编译器版本2.6.11不一致,可能导致兼容性问题。
-
忽略警告后继续进行云打包虽然打包成功了,但是安装到真机运行时提醒如下
此时运行程序可能会发生一些问题,而且每次运行都会弹出提醒,不管是出于程序稳定性考虑还是交互友好性考虑,最好还是将本地编译器版本升级到和云服务器端一致的版本。
注意:若在打包时直接点击“HBuilderX”即可,此时下载的最新版本是HBuilderX2.6.16
,云打包(此时云打包引擎版本2.6.11)和真机安装运行都未弹出提醒,但是真机界面适配出问题。应该还是版本不匹配导致的应用异常(界面适配问题),所以去DCloud官网下载HBuilderX2.6.11
,使本地版本和云服务器端编译器版本一致,从而避免各种不可控的问题。但是HBuilderX2.6.11也会造成之前已适配的界面现在又不能适配的问题(字体和布局变大,有些样式不起效等问题),只能先降级到重装系统前正常的版本HBuilderX2.5.1.20200103
。
8. HBuilderX2.5.1.20200103 升级到 HBuilderX2.7.9.20200527
升级后打包文件变小了,由原来的17.1M变成10.2M。
-
重新制作自定义基座(可能存在缓存,删除unpackage下的debug文件),重新制作基座后又重启HbuilderX,但真机调试仍然无法安装自定义基座
解决:再次删除unpackage下的debug文件,重新制作后再重启HbuilderX,然后就可以真机安装自定义调试基座进行调试了。。。我也是无奈了
真机运行出现兼容问题
① 之前的js不兼容,cutAll字段返回{}时界面显示有问题
② 界面不适配(尝试从HBuilderX2.5.1.20200103升级到HBuilderX2.6.11.20200409时问题已出现)
9. HBuilderX2.7.9.20200527
降级到 HBuilderX2.7.5.20200519
拓展:从 uni-app 2.5.3 起,Android端支持引入腾讯x5浏览器内核,可以抹平低端Android的浏览器兼容性问题。参考:H5正常但App异常的可能性、DCloud App集成 X5 内核(腾讯浏览服务TBS)说明。
(1) UI不适配且有些样式不起效:重新适配并修改样式
- 整体样式变大:调字体大小和各种控件的大小
- checkbox点击无效果:在App.vue中加入下面的样式
/* 重定义checkbox系统样式解决checkbox点击无效果的问题:需定义在全局样式中,定义在页面中不起作用 */
uni-checkbox .uni-checkbox-input.uni-checkbox-input-checked{
background-color: #00a9e2;
}
uni-checkbox[disabled] .uni-checkbox-input{
background-color: #d7dee3;
}
(2) JS报错:添加变量未定义的处理
10:04:50.853 cid unmatched at view.umd.min.js:1
10:04:50.884 TypeError: Invalid attempt to destructure non-iterable instance.
10:04:50.916 In order to be iterable, non-array objects must have a [Symbol.iterator]() method. at view.umd.min.js:1
- 代码片段1
裁剪数量
颜色/尺码
{{item}}
{{color}}
{{cutAll[color][size]}}
优化为:
裁剪数量
颜色/尺码
{{item}}
{{color}}
{{cutAll[color] ? cutAll[color][size] : ''}}
- 代码片段2
合格 数量
颜色/尺码
{{item}}
{{color}}
优化为:
合格 数量
颜色/尺码
{{item}}
{{color}}
- 备注:变量定义、服务器返回数据和数据处理
data() {
return {
sizeArr:[],
colorArr: [],
cutAll: {}
}
},
{
"code": "0",
"msg": "success",
"data": {
"production": {
"production_id": "231",
"production_no": "SCD00113",
"origin": "1",
"order_id": "202",
"style_id": "149",
"bg_time": "1589904000",
"end_time": "1589904000",
"num": "500",
"cut_num": "500",
"ticket_num": "300",
"qualified_num": "2",
"clothes0_num": "1100",
"clothes1_num": "20",
"clothes2_num": "10",
"remark": "",
"add_time": "1589950217",
"user_id": "6",
"del_time": "0",
"mat_state": null,
"material_state": "0",
"cut_state": "1",
"ticket_state": "1",
"qualified_state": "1",
"clothes_state": "0",
"production_state": "1",
"center_id": "1",
"start_time": null,
"over_time": null
},
"style": {
"style_id": "149",
"style_no": "JK00048",
"customer_no": "Armani",
"title": "Armani2020",
"images": {
"url": [
"http://jack-mes.oss-cn-hangzhou.aliyuncs.com/image/b50603584fd0e7cca75b79963fe305c5.jpg"
],
"title": [
"Amazon.jpg"
]
},
"size": "XS,S,M,L,XL",
"color": "黑色,蓝色,白色",
"order_num": "1",
"process": "1650,1651",
"key_process": null,
"size_data": "",
"mark_main": "",
"mark_size": "",
"mark_wash": "",
"note": "",
"note_base": "",
"cut_bed": "",
"sew": "",
"after": "",
"tech": "",
"origin": "1",
"tech_req": "",
"add_time": "1589262744",
"user_id": "6",
"del_time": "0",
"center_id": "1",
"color_arr": [
"黑色",
"蓝色",
"白色"
],
"size_arr": [
"XS",
"S",
"M",
"L",
"XL"
]
},
"company": {
"company_id": "1",
"name": "杰克优产"
},
"productionDetail": {
"黑色": {
"F": "100",
"XS": "100"
},
"蓝色": {
"S": "100",
"M": "100"
},
"白色": {
"XS": "100"
}
},
"order": {
"order_id": "202",
"style_id": "149",
"style_no": "JK00048",
"origin": "1",
"priority": "0",
"company_id": "1",
"order_no": "JK00048-7",
"price": "1.00",
"num": "600",
"end_time": "1589904000",
"production_num": "1800",
"cut_num": "1600",
"clothes0_num": "4020",
"clothes1_num": "20",
"clothes2_num": "110",
"goods_num": "1100",
"return_num": "30",
"remark": "",
"add_time": "1589945496",
"user_id": "6",
"del_time": "0",
"center_id": "1",
"state": "0",
"mat_state": "-1",
"cut_rest": "-1",
"production_rest": "-1",
"clothes_rest": "-1",
"goods_rest": "-1",
"send_state": "-1",
"create_date": "1589904000"
},
"clothes0": {
"黑色": {
"F": 300,
"XS": 200
},
"蓝色": {
"S": 200,
"M": 200
},
"白色": {
"XS": 200
}
},
"cutAll": {
"黑色": {
"F": 100,
"XS": 100
},
"蓝色": {
"S": 100,
"M": 100
},
"白色": {
"XS": 100
}
}
}
}
success:function(res){
_self.sizeArr = res.data.style.size_arr;
_self.colorArr = res.data.style.color_arr;
_self.cutAll = res.data.cutAll;
},
-
最终效果