赞
踩
1.https证书问题,之前请求接口域名证书是dv证书,更换的新域名配置了泛域名证书,导致dio证书验证出错
:DioError [DioErrorType.DEFAULT]: HandshakeException: Handshake error in client (OS Error:
CERTIFICATE_VERIFY_FAILED: unable to get local issuer certificate(handshake.cc:354))
解决办法:dio验证强制返回true:
- (_dio.httpClientAdapter as DefaultHttpClientAdapter).onHttpClientCreate = (client){
- client.badCertificateCallback = (cert, host, port){
- return true;
- };
- };
2.Android 5.0
之前的版本(API level < 21
)使用Dalvik runtime
来执行代码,默认限制每个APK
只能使用一个classes.dex
文件,而DEX
规范又将单个DEX
文件内引用的方法总数限制为65536
个,第三方引入过多函数超限
D8: Cannot fit requested classes in a single dex file (# methods: 75464 > 65536)
com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:
The number of method references in a .dex file cannot exceed 64K. Learn how to resolve this issue at https://developer.android.com/tools/building/multidex.html
解决办法:在android/app/build.gradle配置中添加参数:1.defaultConfig内添加 multiDexEnabled true 2.dependencies内添加 implementation 'com.android.support:multidex:1.0.3'
3.集成高德地图插件安卓运行报错闪退:
E/flutter (14718): [ERROR:flutter/shell/platform/android/platform_view_android_jni_impl.cc(43)] java.lang.NoClassDefFoundError: Failed resolution of: Lcom/amap/api/location/AMapLocationClient;
E/flutter (14718): at com.amap.flutter.location.AMapFlutterLocationPlugin.setApiKey(AMapFlutterLocationPlugin.java:115)
E/flutter (14718): at com.amap.flutter.location.AMapFlutterLocationPlugin.onMethodCall(AMapFlutterLocationPlugin.java:38)
E/flutter (14718): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:230)
E/flutter (14718): at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85)
E/flutter (14718): at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:692)
E/flutter (14718): at android.os.MessageQueue.nativePollOnce(Native Method)
E/flutter (14718): at android.os.MessageQueue.next(MessageQueue.java:336)
E/flutter (14718): at android.os.Looper.loop(Looper.java:174)
E/flutter (14718): at android.app.ActivityThread.main(ActivityThread.java:7356)
E/flutter (14718): at java.lang.reflect.Method.invoke(Native Method)
E/flutter (14718): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
E/flutter (14718): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
解决办法:在app/build.gradle文件的dependencies配置中添加相关sdk依赖,参考下图:
4.集成Firebase推送模拟器运行报错:
E/FirebaseMessaging: Failed to get FIS auth token
java.util.concurrent.ExecutionException: com.google.firebase.installations.FirebaseInstallationsException: Firebase Installations Service is unavailable. Please try again later.
at com.google.android.gms.tasks.Tasks.zza(com.google.android.gms:play-services-tasks@@18.0.1:5)
at com.google.android.gms.tasks.Tasks.await(com.google.android.gms:play-services-tasks@@18.0.1:8)
at com.google.firebase.messaging.GmsRpc.setDefaultAttributesToBundle(GmsRpc.java:260)
at com.google.firebase.messaging.GmsRpc.startRpc(GmsRpc.java:222)
at com.google.firebase.messaging.GmsRpc.getToken(GmsRpc.java:180)
at com.google.firebase.messaging.FirebaseMessaging.lambda$blockingGetToken$10$FirebaseMessaging(FirebaseMessaging.java:610)
at com.google.firebase.messaging.-
5. List赋值问题,有一个map list变量,我用一个新的list变量接收,然后在修改新的list数据的时候发现,旧的list变量的内容也变了:
- List list1 = [{'label': 'first name', 'value': 'Jack'}, {'label': 'last name', 'value': 'Gold'}];
- List list2 = List.from(list1);
- list2.last['valuee'] = 'Gould';
- print('list1: $list1 \n list2: $list2');
-
- // Console
- flutter: list1: [{label: first name, value: Jack}, {label: last name, value: Gold, valuee: Gould}]
- list2: [{label: first name, value: Jack}, {label: last name, value: Gold, valuee: Gould}]
解决方案:
通过for循环方式添加:List list2; for (var item in list1) {list2.add(item);}
通过json decode+encode组合:List list2 = List.from(json.decode(json.encode(list1)));
6. iOS端 Pod Install报错:[!] Invalid `Podfile` file: undefined method `exists?' for File:Class.
原因是ruby3.2删除了对 exists 的支持导致该问题
解决方案:
1)升级Flutter SDK
2)打开flutter目录下的这个文件:/flutter/packages/flutter_tools/bin/podhelper.rb,搜索到这一行内容:return [] unless File.exists? file_path 将其中的 exists 改为 exist
后续问题会持续补充...
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。