关于flutter使用高德地图search api

pub搜了下amap_base_flutter属于评分比较高的了

参考https://github.com/flutter/flutter/pull/34369

编译的时候报错

e: C:flutter.pub-cachehostedpub.flutter-io.cnamap_base_search-0.4.1androidsrcmainkotlinmeyohomamapbasesearchsearchSearchHandlers.kt: (326, 1): Object 'DistanceSearchHandler' is not abstract and does not implement abstract member @UiThread public abstract fun onMethodCall(@NonNull p0: MethodCall, @NonNull p1: MethodChannel.Result): Unit defined in me.yohom.amapbasesearch.SearchMethodHandler
e: C:flutter.pub-cachehostedpub.flutter-io.cnamap_base_search-0.4.1androidsrcmainkotlinmeyohomamapbasesearchsearchSearchHandlers.kt: (327, 5): 'onMethodCall' overrides nothing

插件的源码有问题需要改下,这个因为作者比较忙一直没修,问了下说这周会出版本

amap_base_flutter-mastersearchandroidsrcmainkotlinmeyohomamapbasesearchsearchSearchHandlers.kt line 327

object DistanceSearchHandler : SearchMethodHandler {
    override fun onMethodCall(call: MethodCall, result: MethodChannel.Result?) {//去掉问号

改完后编译通过安装后闪退,查了下应该是32位64位的问题,--target-platform参数已经弃用了 unused flag `--target-platform` from `flutter run`直接改配置文件C:flutterpackagesflutter_toolslibsrcandroidgradle.dart line 461

 command.add('-Ptarget-platform=android-arm');

原有项目增加amap_base_search时编译报错,单个dex file文件过大,解决方案参考https://www.jianshu.com/p/f68b0b070c31

D8: Cannot fit requested classes in a single dex file (# methods: 67205 > 65536)

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: 
  The number of method references in a .dex file cannot exceed 64K.

 源码还有个问题C:/flutter/.pub-cache/hosted/pub.flutter-io.cn/amap_base_search-0.4.1/lib/src/search/amap_search.dart 文件里的L.p方法不存在,都替换为print方式

原文地址:https://www.cnblogs.com/nightfallsad/p/11416761.html