Search code examples
androidflutterkotlindartalgolia

How to solve flutter Execution failed for task ':twitter_login:compileReleaseKotlin' error?


I am trying to build an apk from my flutter application. I am using the algolia native api and modified my FlutterActivity according to this official documentation (https://www.algolia.com/doc/guides/building-search-ui/getting-started/how-to/flutter/android/) like this:

class MainActivity: FlutterActivity() {

val algoliaAPIAdapter = AlgoliaAPIFlutterAdapter(ApplicationID("****"), APIKey("*********************"))

 override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) {
    super.configureFlutterEngine(flutterEngine)
    MethodChannel(flutterEngine.dartExecutor.binaryMessenger, "com.algolia/api").setMethodCallHandler { call, result ->
        algoliaAPIAdapter.perform(call, result)
    }
  }
}

Unfortunately the build throws following error:

e: /Users/martinseubert/development/flutter/.pub-cache/hosted/pub.dartlang.org/twitter_login-4.1.0/android/src/main/kotlin/com/maru/twitter_login/TwitterLoginPlugin.kt: (21, 8): 'public open fun onNewIntent(Intent): Boolean defined in com.maru.twitter_login.TwitterLoginPlugin' clashes with 'protected/*protected and package*/ open fun onNewIntent(Intent): Unit defined in io.flutter.embedding.android.FlutterActivity': return types are incompatible
e: /Users/martinseubert/development/flutter/.pub-cache/hosted/pub.dartlang.org/twitter_login-4.1.0/android/src/main/kotlin/com/maru/twitter_login/TwitterLoginPlugin.kt: (21, 14): Cannot infer visibility for 'fun onNewIntent(p0: Intent): Boolean'. Please specify it explicitly
e: /Users/martinseubert/development/flutter/.pub-cache/hosted/pub.dartlang.org/twitter_login-4.1.0/android/src/main/kotlin/com/maru/twitter_login/TwitterLoginPlugin.kt: (76, 5): 'onNewIntent' overrides nothing

Any ideas, what goes wrong when building via flutter build apk? I am not using the twitter login at all and only added firebase_auth for the google login. I am currently using ext.kotlin_version = '1.6.10'.

Here is my flutter doctor output:

[✓] Flutter (Channel beta, 2.12.0-4.1.pre, on macOS 12.3.1 21E258 darwin-arm, locale de-DE)
[✓] Android toolchain - develop for Android devices (Android SDK version 32.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 13.3)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2020.3)
[✓] VS Code (version 1.66.0)
[✓] Connected device (1 available)
[✓] HTTP Host Availability

Solution

  • This issue is being addressed by the project flutterfire which uses an older version of twitter_login: issue, PR.

    Was fixed in v0.4.0+0.2, see changelog.