我正在编写一个针对 iOS 和 Android 的 flutter 应用程序,并使用 firebase-auth 和 firebase-storage。该应用程序正在 iOS 模拟器中编译并运行良好。
但是,在 Android 上,我遇到了问题。当我实际尝试使用 Google 登录时,它显示“发生未知错误”。我假设发生这种情况是因为我还没有完成 Android 应用程序的 Firebase 中的说明操作。但当我这样做时,我遇到了构建问题。
按照 Firebase 说明,我添加了
dependencies {
implementation platform('com.google.firebase:firebase-bom:32.8.1')
implementation('com.google.firebase:firebase-auth')
}
到我的 build.gradle。但是,一旦我添加
firebase-auth
行,我就会收到以下错误:
➜ putali git:(main) ✗ flutter run -d emulator-5554
Launching lib/main.dart on sdk gphone64 arm64 in debug mode...
e: /Users/pp-personal/.gradle/caches/transforms-3/c0ec700e9714ce9064eef1af0d40a60e/transformed/jetified-recaptcha-18.4.0-api.jar!/META-INF/java.com.google.android.libraries.abuse.recaptcha.common_common_ktx.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.9.0, expected version is 1.7.1.
e: /Users/pp-personal/.gradle/caches/transforms-3/c0ec700e9714ce9064eef1af0d40a60e/transformed/jetified-recaptcha-18.4.0-api.jar!/META-INF/java.com.google.android.libraries.abuse.recaptcha.common_logger.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.9.0, expected version is 1.7.1.
e: /Users/pp-personal/.gradle/caches/transforms-3/c0ec700e9714ce9064eef1af0d40a60e/transformed/jetified-recaptcha-18.4.0-api.jar!/META-INF/java.com.google.android.libraries.abuse.recaptcha.enterprise.android_impl.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.9.0, expected version is 1.7.1.
e: /Users/pp-personal/.gradle/caches/transforms-3/c0ec700e9714ce9064eef1af0d40a60e/transformed/jetified-recaptcha-18.4.0-api.jar!/META-INF/java.com.google.android.libraries.abuse.recaptcha.enterprise.internal.release.com.google.android.recaptcha.internal_release.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.9.0, expected version is 1.7.1.
e: /Users/pp-personal/.gradle/caches/transforms-3/c0ec700e9714ce9064eef1af0d40a60e/transformed/jetified-recaptcha-18.4.0-api.jar!/META-INF/java.com.google.android.libraries.abuse.recaptcha.enterprise.internal_impl.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.9.0, expected version is 1.7.1.
e: /Users/pp-personal/.gradle/caches/transforms-3/c0ec700e9714ce9064eef1af0d40a60e/transformed/jetified-recaptcha-18.4.0-api.jar!/META-INF/java.com.google.android.libraries.abuse.recaptcha.enterprise.internal_internal.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.9.0, expected version is 1.7.1.
e: /Users/pp-personal/.gradle/caches/transforms-3/c0ec700e9714ce9064eef1af0d40a60e/transformed/jetified-recaptcha-18.4.0-api.jar!/META-INF/java.com.google.android.libraries.abuse.recaptcha.enterprise.native_impl.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.9.0, expected version is 1.7.1.
e: /Users/pp-personal/.gradle/caches/transforms-3/c0ec700e9714ce9064eef1af0d40a60e/transformed/jetified-recaptcha-18.4.0-api.jar!/META-INF/java.com.google.android.libraries.abuse.recaptcha.enterprise.public_public.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.9.0, expected version is 1.7.1.
e: /Users/pp-personal/.gradle/caches/transforms-3/c0ec700e9714ce9064eef1af0d40a60e/transformed/jetified-recaptcha-18.4.0-api.jar!/META-INF/java.com.google.android.libraries.abuse.recaptcha.enterprise_enterprise.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.9.0, expected version is 1.7.1.
e: /Users/pp-personal/.gradle/caches/transforms-3/c0ec700e9714ce9064eef1af0d40a60e/transformed/jetified-recaptcha-18.4.0-api.jar!/META-INF/java.com.google.android.libraries.abuse.recaptcha.metricscollection_metricscollection.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.9.0, expected version is 1.7.1.
e: /Users/pp-personal/.gradle/caches/transforms-3/c0ec700e9714ce9064eef1af0d40a60e/transformed/jetified-recaptcha-18.4.0-api.jar!/META-INF/java.com.google.android.libraries.abuse.recaptcha.network_network.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.9.0, expected version is 1.7.1.
e: /Users/pp-personal/.gradle/caches/transforms-3/c0ec700e9714ce9064eef1af0d40a60e/transformed/jetified-recaptcha-18.4.0-api.jar!/META-INF/recaptcha.proto.mobile_allowlist_kt_proto_lite.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.9.0, expected version is 1.7.1.
e: /Users/pp-personal/.gradle/caches/transforms-3/c0ec700e9714ce9064eef1af0d40a60e/transformed/jetified-recaptcha-18.4.0-api.jar!/META-INF/recaptcha.proto.mobile_enterprise_sdk_kt_proto_lite.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.9.0, expected version is 1.7.1.
e: /Users/pp-personal/.gradle/caches/transforms-3/c0ec700e9714ce9064eef1af0d40a60e/transformed/jetified-recaptcha-18.4.0-api.jar!/META-INF/recaptcha.proto.mobile_mobile_reload_kt_proto_lite.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.9.0, expected version is 1.7.1.
e: /Users/pp-personal/.gradle/caches/transforms-3/c0ec700e9714ce9064eef1af0d40a60e/transformed/jetified-recaptcha-18.4.0-api.jar!/META-INF/recaptcha.proto.mobile_webview_sdk_kt_proto_lite.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.9.0, expected version is 1.7.1.
e: /Users/pp-personal/.gradle/caches/transforms-3/c0ec700e9714ce9064eef1af0d40a60e/transformed/jetified-recaptcha-18.4.0-api.jar!/META-INF/third_party.java_src.protobuf.current.java.com.google.protobuf.kotlin_only_for_use_in_proto_generated_code_its_generator_and_tests.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.9.0, expected version is 1.7.1.
e: /Users/pp-personal/.gradle/caches/transforms-3/c0ec700e9714ce9064eef1af0d40a60e/transformed/jetified-recaptcha-18.4.0-api.jar!/META-INF/third_party.java_src.protobuf.current.java.com.google.protobuf.kotlin_shared_runtime.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.9.0, expected version is 1.7.1.
e: /Users/pp-personal/.gradle/caches/transforms-3/fd337f4d568e2ea40aa721a5d11e021a/transformed/jetified-firebase-auth-22.3.1-api.jar!/META-INF/java.com.google.android.gmscore.integ.client.firebase-auth-api_firebase-auth-api.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.9.0, expected version is 1.7.1.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugKotlin'.
> A failure occurred while executing org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction
> Compilation error. See log for more details
* 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 13s
Running Gradle task 'assembleDebug'... 13.7s
┌─ Flutter Fix ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ [!] Your project requires a newer version of the Kotlin Gradle plugin. │
│ Find the latest version on https://kotlinlang.org/docs/releases.html#release-details, then update /Users/pp/myapp/android/build.gradle: │
│ ext.kotlin_version = '<latest-version>' │
└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
Error: Gradle task assembleDebug failed with exit code 1
关于类似问题的建议似乎是升级到最新版本的Kotlin,我已经在使用了。
我也在使用最新的Gradle;每个 gradle-wrapper.properties:
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-all.zip
救命!
我在以下https://stackoverflow.com/users/22646405/ultranmus评论中回答了这个问题。
事实证明,我不需要将这些依赖项添加到我的 build.gradle 中,因为它们已经通过 flutter 添加了。 经过一些额外的谷歌搜索后,发现我的问题是我没有将 Android 应用程序的 sha1 指纹添加到 firebase。添加它为我解决了这个问题。