Flutterでfirebase_analytics
を導入したところ、Androidでビルドエラーになった。
***/android/app/src/debug/AndroidManifest.xml Error: uses-sdk:minSdkVersion 16 cannot be smaller than version 19 declared in library [:firebase_analytics] ***/build/firebase_analytics/intermediates/merged_manifest/debug/AndroidManifest.xml as the library might be using APIs not available in 16 Suggestion: use a compatible library with a minSdk of at most 16, or increase this project's minSdk version to at least 19, or use tools:overrideLibrary="io.flutter.plugins.firebase.analytics" to force usage (may lead to runtime failures) FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':app:processDebugMainManifest'. > Manifest merger failed : uses-sdk:minSdkVersion 16 cannot be smaller than version 19 declared in library [:firebase_analytics] ***/build/firebase_analytics/intermediates/merged_manifest/debug/AndroidManifest.xml as the library might be using APIs not available in 16 Suggestion: use a compatible library with a minSdk of at most 16, or increase this project's minSdk version to at least 19, or use tools:overrideLibrary="io.flutter.plugins.firebase.analytics" to force usage (may lead to runtime failures) ┌─ Flutter Fix ─────────────────────────────────────────────────────────────────────────────────┐ │ The plugin firebase_analytics requires a higher Android SDK version. │ │ Fix this issue by adding the following to the file │ │ ***/android/app/build.gradle: │ │ android { │ │ defaultConfig { │ │ minSdkVersion 19 │ │ } │ │ } │ │ │ │ Note that your app won't be available to users running Android SDKs below 19. │ │ Alternatively, try to find a version of this plugin that supports these lower versions of the │ │ Android SDK. │ │ For more information, see: │ │ https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration │ └───────────────────────────────────────────────────────────────────────────────────────────────┘ Exception: Gradle task assembleDebug failed with exit code 1
記載の通り、minSdkVersion
の記述を変えたところ解決した。flutter的には16だがfirebase_analytics的には19以上が必須で、個人的にもっとサポートOSを減らしたいので22に設定した。
android { defaultConfig { minSdkVersion 22 // もともとは flutter.minSdkVersionだった。 } }