flutter_web_auth icon indicating copy to clipboard operation
flutter_web_auth copied to clipboard

how to solve this error i am stucking on this issue from 7 days

Open Mithudonn opened this issue 9 months ago • 5 comments

e: file:///C:/Users/hp/AppData/Local/Pub/Cache/hosted/pub.dev/flutter_web_auth_2-3.1.2/android/src/main/kotlin/com/linusu/flutter_web_auth_2/FlutterWebAuth2Plugin.kt:15:48 Unresolved reference: Registrar e: file:///C:/Users/hp/AppData/Local/Pub/Cache/hosted/pub.dev/flutter_web_auth_2-3.1.2/android/src/main/kotlin/com/linusu/flutter_web_auth_2/FlutterWebAuth2Plugin.kt:21:5 This annotation is not applicable to target 'class'

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':flutter_web_auth_2: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 1m 2s Error: Gradle task assembleDebug failed with exit code 1

Mithudonn avatar Mar 21 '25 05:03 Mithudonn

Did you resolve it?

carlgrob5171989 avatar Apr 02 '25 02:04 carlgrob5171989

Did you resolve it?

Nope now I am start working on another project

Mithudonn avatar Apr 02 '25 02:04 Mithudonn

Hi! This is what works for me:

locally, you can open the referenced file: C:/Users/hp/AppData/Local/Pub/Cache/hosted/pub.dev/flutter_web_auth_2-3.1.2/android/src/main/kotlin/com/linusu/flutter_web_auth_2/FlutterWebAuth2Plugin.kt

and comment these parts:

//import io.flutter.plugin.common.PluginRegistry.Registrar

class FlutterWebAuthPlugin(private var context: Context? = null, private var channel: MethodChannel? = null): MethodCallHandler, FlutterPlugin {
  companion object {
    val callbacks = mutableMapOf<String, Result>()
//
//    @JvmStatic
//    fun registerWith(registrar: Registrar) {
//        val plugin = FlutterWebAuthPlugin()
//        plugin.initInstance(registrar.messenger(), registrar.context())
//    }
//
  }

basically you have to comment the parts related to Registrar. That’s it. Now the plugin will only register via onAttachedToEngine, which is the modern way.

negahdaripour avatar Apr 06 '25 06:04 negahdaripour

Pls look into the Pull requests there is a fix for it but not merged yet

ChristopherHelmbold avatar May 07 '25 06:05 ChristopherHelmbold

Hi! This is what works for me:

locally, you can open the referenced file: C:/Users/hp/AppData/Local/Pub/Cache/hosted/pub.dev/flutter_web_auth_2-3.1.2/android/src/main/kotlin/com/linusu/flutter_web_auth_2/FlutterWebAuth2Plugin.kt

and comment these parts:

//import io.flutter.plugin.common.PluginRegistry.Registrar

class FlutterWebAuthPlugin(private var context: Context? = null, private var channel: MethodChannel? = null): MethodCallHandler, FlutterPlugin {
  companion object {
    val callbacks = mutableMapOf<String, Result>()
//
//    @JvmStatic
//    fun registerWith(registrar: Registrar) {
//        val plugin = FlutterWebAuthPlugin()
//        plugin.initInstance(registrar.messenger(), registrar.context())
//    }
//
  }

basically you have to comment the parts related to Registrar. That’s it. Now the plugin will only register via onAttachedToEngine, which is the modern way.

it worked, thank you very much. I've been stuck for weeks.

WeStayCoolin avatar May 21 '25 13:05 WeStayCoolin