
If you have made any changes in the development, such as changing the data processing location, or enabling or disabling APIs, download the latest agconnect-services.json file and replace the existing file in the app directory.

buildscript {
repositories {
google()
jcenter()
maven { url 'https://developer.huawei.com/repo/' }
}
dependencies {
/*
* <Other dependencies>
*/
classpath 'com.huawei.agconnect:agcp:1.4.2.301'
}
}allprojects {
repositories {
google()
jcenter()
maven { url 'https://developer.huawei.com/repo/' }
}
}apply plugin: 'com.android.application' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" apply plugin: 'com.huawei.agconnect'
defaultConfig {
applicationId "<package_name>"
minSdkVersion 19
/*
* <Other configurations>
*/
}
applicationId must match the package_name entry in the agconnect-services.json file.
android {
/*
* <Other configurations>
*/
signingConfigs {
config {
storeFile file('<keystore_file>')
storePassword '<keystore_password>'
keyAlias '<key_alias>'
keyPassword '<key_password>'
}
}
buildTypes {
debug {
signingConfig signingConfigs.config
}
release {
signingConfig signingConfigs.config
}
}
}
Replace <keystore_file>, <keystore_password>, <key_alias>, and <key_password> with matching entries in your signature file. For details about app signing in Flutter, please refer to Signing the app.
Before building the APK, configure the obfuscation scripts to prevent the HMS Core SDK from being obfuscated.
The obfuscation configuration file in Android Studio is proguard-rules.pro.
-ignorewarnings
-keepattributes *Annotation*
-keepattributes Exceptions
-keepattributes InnerClasses
-keepattributes Signature
-keep class com.hianalytics.android.**{*;}
-keep class com.huawei.updatesdk.**{*;}
-keep class com.huawei.hms.**{*;}
## Flutter wrapper
-keep class io.flutter.app.** { *; }
-keep class io.flutter.plugin.** { *; }
-keep class io.flutter.util.** { *; }
-keep class io.flutter.view.** { *; }
-keep class io.flutter.** { *; }
-keep class io.flutter.plugins.** { *; }
-dontwarn io.flutter.embedding.**
-keep class com.huawei.hms.flutter.** { *; }
-repackageclasses buildTypes {
debug {
signingConfig signingConfigs.config
}
release {
signingConfig signingConfigs.config
// Enables code shrinking, obfuscation and optimization for release builds
minifyEnabled true
// Unused resources will be removed.
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
Make sure that you have installed the Flutter and Dart plugins for your editor. For more information about setting up an editor, please refer to Flutter Documentation.
flutter doctor

dependencies:
huawei_map:
path: {library path}
Replace {library path} with the actual library path of the Map Kit plugin for Flutter.
# Relative path example
path: ../huawei_map # Absolute path example
path: D:\Projects\Libraries\huawei_map For details, please refer to Using packages.
dependencies:
huawei_map: {library version}[project_path]> flutter pub get
[project_path]> flutter run

If there are no errors, the following screen will be displayed when you run your app. For details about the sample code, please refer to Flutter Sample Code.

If an error occurs, check the network connection and the configurations in the build.gradle file, and delete the android/gradle/wrapper directory.