flutter配置高德地图SDK

在项目目录 android/app目录下build.gradle 文件内添加如下代码

android {  
    defaultConfig {
    
		manifestPlaceholders = [
                LOCATION_APP_KEY : "0e8507757da9b56d5d905edce9ccf2c0", /// 高德地图key
        ]
    }
    dependencies {
            //这里的插件可自行引入,都是云端的
    implementation 'com.amap.api:location:latest.integration'
    }




}

在src/main目录下androidMainfest.xml文件内添加如下权限

 <uses-permission android:name="android.permission.INTERNET"/>

    <!-- io.flutter.app.FlutterApplication is an android.app.Application that
         calls FlutterMain.startInitialization(this); in its onCreate method.
         In most cases you can leave this as-is, but you if you want to provide
         additional functionality it is fine to subclass or reimplement
         FlutterApplication and put your custom class here. -->
     <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="android.permission.CHANGE_CONFIGURATION" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
 

    <uses-permission android:name="android.permission.WRITE_SETTINGS" />

在application结尾处添加如下服务

<service android:name="com.amap.api.location.APSService" >
        </service>

插件开发还需在根目录的android目录中的build.XX文件内android {}添加以下代码

dependencies {
    implementation 'com.amap.api:location:latest.integration'
    }

 

    原文作者:GeekBoyCode
    原文地址: https://blog.csdn.net/a1057962851/article/details/86024154
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞