我嘗試在我的 flutter 應用程式中使用 google-maps 但是,每次嘗試除錯我的代碼時都會收到此錯誤。
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:checkDebugAarMetadata'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
> Could not find play-services-maps-17.0.0.aar (com.google.android.gms:play-services-maps:17.0.0).
Searched in the following locations:
https://dl.google.com/dl/android/maven2/com/google/android/gms/play-services-maps/17.0.0/play-services-maps-17.0.0.aar
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 39s
Exception: Gradle task assembleDebug failed with exit code 1
uj5u.com熱心網友回復:
請轉到檔案 -> android/app/build.gradle
并將 minSdkVersion 從 16 編輯為 21
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.google_maps"
minSdkVersion 21
targetSdkVersion 30
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
uj5u.com熱心網友回復:
根據它的檔案,您應該在 android/app/build.gradle 中設定 minSdkVersion:
android {
defaultConfig {
minSdkVersion 20
}
}
還要在主檔案中添加此代碼:
void main() {
if (defaultTargetPlatform == TargetPlatform.android) {
AndroidGoogleMapsFlutter.useAndroidViewSurface = true;
}
runApp(MyApp());
}
配置鏈接:https ://pub.dev/packages/google_maps_flutter#android
注意:請檢查您的 Internet 連接并嘗試使用 VPN!
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/358047.html
