'Execution failed for task ':google_api_headers:compileDebugKotlin'

After updating to Dart 3.0 I have this error when I launch the app on Android simulator. For iOS physical device its building ok. Unfortunately can't try with Android physical device. Any ideas?

e: /Users/amarchuk/.pub-cache/hosted/pub.dartlang.org/google_api_headers-1.2.0+1/android/src/main/kotlin/io/github/zeshuaro/google_api_headers/GoogleApiHeadersPlugin.kt: (52, 68): Type mismatch: inferred type is String? but String was expected
e: /Users/amarchuk/.pub-cache/hosted/pub.dartlang.org/google_api_headers-1.2.0+1/android/src/main/kotlin/io/github/zeshuaro/google_api_headers/GoogleApiHeadersPlugin.kt: (58, 68): Type mismatch: inferred type is String? but String was expected

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':google_api_headers: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.
2

* Get more help at https://help.gradle.org

BUILD FAILED in 33s
Exception: Gradle task assembleDebug failed with exit code 1
Exited


Solution 1:[1]

as a temporarily solutions

  1. Downgrade from Flutter 3.0
    flutter downgrade 2.10.5
  1. open the file producing error GoogleApiHeadersPlugin.kt (cmd + click on it in console for macOS) and cut all the try catch part
    try {
                val info: PackageInfo
                if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.P) {
                    info = context!!.packageManager.getPackageInfo(call.arguments<String>(), PackageManager.GET_SIGNING_CERTIFICATES)
                    for (signature in info.signingInfo.apkContentsSigners) {
                        parseSignature(signature, result)
                    }
                } else {
                    @Suppress("DEPRECATION")
                    info = context!!.packageManager.getPackageInfo(call.arguments<String>(), PackageManager.GET_SIGNATURES)
                    @Suppress("DEPRECATION")
                    for (signature in info.signatures) {
                        parseSignature(signature, result)
                    }
                }

            } catch (e: Exception) {
                result.error("ERROR", e.toString(), null)
            }

so if method is empty and doing nothing

if (call.method == "getSigningCertSha1") {}

I don't have enough knowledge to say what are the consequences of this but my app is working and all the google APIs are working too (google maps, google sign in, Firebase)

I suggest you save the deleted code somewhere.

Solution 2:[2]

upgrading all Firebase plugins solves the issue. For the date of this answer latest versions are:

cloud_firestore to 3.1.15   
firebase_auth to 3.3.18   
firebase_core to 1.17.0   
firebase_crashlytics to 2.8.0    
firebase_messaging to 11.4.0   
firebase_remote_config to 2.0.7    
firebase_storage to 10.2.16 

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 Marchuk Anton