我正在尝试将 firebase 添加到我的 flutter 项目中。 我收到此错误:
uses-sdk:minSdkVersion 16 cannot be smaller than version 19 declared in library [com.google.firebase:firebase-analytics-ktx:20.0.1] /home/sonu/.gradle/caches/transforms-2/files-2.1/798243125f1f7594aa48e9bc333d339c/jetified-firebase-analytics-ktx-20.0.1/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="com.google.firebase.analytics.ktx" to force usage (may lead to runtime failures)
我最近将我的 flutter 更新到了 2.8.1 版本, 我尝试更改我的 minSdk 但没有成功。
这是完整的日志:
[enter image description here][1]
请有人帮我解决这个问题。
android->app->build.gradle 文件
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.flutter_calismalari"
minSdkVersion 21
targetSdkVersion 30
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
将 minSdkVersion 从 16 改为 21
您需要更新 ./android/app/build.gradle 中的最低 SDK 示例:
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.projectname"
minSdkVersion 19 //*** This is the part that needs to be changed, previously was 16
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
顺便说一句,如果你确实需要保持你的 minSdkVersion 小(比如 16),你可以使用这个技巧。将其添加到您的清单中:
<uses-sdk tools:overrideLibrary="io.grpc.android, androidx.webkit, com.google.android.gms.measurement_base, com.google.android.gms.measurement.sdk.api, com.google.android.ads.consent, com.google.android.gms.ads_base, com.google.firebase.measurement_impl, com.google.android.gms.measurement.sdk, com.google.firebase.measurement, com.google.firebase.components, com.google.firebase.database, com.google.firebase.auth, com.google.firebase.firebase_ads, com.google.firebase.firebase_core, com.google.firebase.firestore, com.google.firebase.perf, com.google.firebase.sessions, com.google.firebase.firebase_analytics, com.google.android.gms.measurement.api, com.google.firebase.ktx, com.google.firebase, androidx.credentials, com.google.android.gms.ads.impl, com.google.android.gms.ads" />
我也遇到了同样的问题,最后通过这条长线解决了。就我而言,它工作正常,您最好检查它是否可以在您的配置中工作。