flutter 安卓使用高德插件黑屏

地址 https://lbs.amap.com/api/android-sdk/guide/create-project/android-studio-create-project

下面介绍的方式是Native配置 sdk,也就是需要手动下载到本地在引入的方式

1、添加 jar 文件:

将下载的地图 SDK 的 jar包复制到工程(此处截图以官方示例Demo为例子)的 libs 目录下,如果有老版本 jar 包在其中,请删除。如图所示:

复制代码

2、添加 so 库

说明:3D地图才需要添加so库,2D地图无需这一步骤。
保持project查看方式,以下介绍两种导入so文件的方法

通过Gradle集成SDK

Android Studio默认会在Project的build.gradle为所有module自动添加jcenter的仓库地址,如果已存在,则不需要重复添加。Project的build.gradle文件在Project目录中位置如图所示

1、在Project的build.gradle文件中配置repositories,添加maven或jcenter仓库地址

Android Studio默认会在Project的build.gradle为所有module自动添加jcenter的仓库地址,如果已存在,则不需要重复添加。Project的build.gradle文件在Project目录中位置如图所示:

复制代码
allprojects {
    repositories {
        jcenter() // 或者 mavenCentral()
    }
 }

2、在主工程的build.gradle文件配置dependencies

根据项目需求添加SDK依赖。引入各个SDK功能最新版本, dependencies 配置方式如下:

SDK 引入代码
3D地图 compile 'co.amap.api:3dmap:latest.integration'
2D地图 compile 'com.amap.api:map2d:latest.integration'
导航 compile 'com.amap.api:navi-3dmap:latest.integration'
搜索 compile 'com.amap.api:search:latest.integration'
定位 compile 'com.amap.api:location:latest.integration'

以3D的demo工程为例添加3d地图SDK、定位SDK、搜索功能,配置如下:

复制代码
android {
    defaultConfig {
        ndk {
            //设置支持的SO库架构(开发者可以根据需要,选择一个或多个平台的so)
            abiFilters "armeabi", "armeabi-v7a", "arm64-v8a", "x86","x86_64"
        }
    }
}
//这里的引入方式有第一个就不用再单独引入了,不然会报错重复引入
//现在新版本都是implementation 其他不支持了,用其他方法运行会报错
//模拟器报错 可以去真机试下,使用低版本的模拟器,8.0以下,gradle中targetSdkVersion修改为26以下
dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    //3D地图so及jar
    implementation 'com.amap.api:3dmap:latest.integration'
    //定位功能
    implementation 'com.amap.api:location:latest.integration'
    //搜索功能
    implementation 'com.amap.api:search:latest.integration'
}

dependencies 下面的代码只能使用一个比如

使用这个了

implementation fileTree(dir: 'libs', include: ['*.jar'])

其他就不能使用了

//3D地图so及jar

implementation 'com.amap.api:3dmap:latest.integration'

//定位功能

implementation 'com.amap.api:location:latest.integration'

//搜索功能

implementation 'com.amap.api:search:latest.integration'

这里推荐用远程的方式

implementation 'com.amap.api:3dmap:latest.integration'

这里引入后不用再引入定位,因为最新的sdk 包含了定位sdk,在引入会报错说重复了。

通过这种方式就不用下载本地也就是你的libs目录不需要了,还有jniLibs 目录也不需要了

可以参考官网的flutter 高德插件demo

无需积分,直接下载

https://download.csdn.net/download/u010843503/88672741

相关推荐
老衲不服6 小时前
android 三方sdk minSdkVersion 兼容问题处理
android
android_xc10 小时前
Android Studio国内仓库配置
android·ide·android studio
alexhilton10 小时前
runBlocking实践:哪里该使用,哪里不该用
android·kotlin·android jetpack
2501_9151063210 小时前
iOS 使用记录和能耗监控实战,如何查看电池电量消耗、App 使用时长与性能数据(uni-app 开发调试必备指南)
android·ios·小程序·uni-app·cocoa·iphone·webview
雨白10 小时前
深入解析 Android 多点触摸:从原理到实战
android
曾经的三心草12 小时前
Python2-工具安装使用-anaconda-jupyter-PyCharm-Matplotlib
android·java·服务器
蒋星熠12 小时前
Flutter跨平台工程实践与原理透视:从渲染引擎到高质产物
开发语言·python·算法·flutter·设计模式·性能优化·硬件工程
Jerry12 小时前
Compose 设置文字样式
android
飞猿_SIR13 小时前
android定制系统完全解除应用安装限制
android
索迪迈科技13 小时前
影视APP源码 SK影视 安卓+苹果双端APP 反编译详细视频教程+源码
android·影视app源码·sk影视