flutter项目报错及解决办法

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依赖,参考下图:




后续问题会持续补充...

————————————————

版权声明:本文为CSDN博主「CocoaJerry」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。

原文链接:https://blog.csdn.net/u010623954/article/details/111717851

你可能感兴趣的:(flutter项目报错及解决办法)