FlutterToast icon indicating copy to clipboard operation
FlutterToast copied to clipboard

Unresolved reference: R

Open vitaminwater opened this issue 11 months ago • 13 comments

Looks like this issue is back.

e: file:///Users/stant/.pub-cache/hosted/pub.dev/fluttertoast-8.2.10/android/src/main/kotlin/io/github/ponnamkarthik/toast/fluttertoast/MethodCallHandlerImpl.kt:50:62 Unresolved reference: R
e: file:///Users/stant/.pub-cache/hosted/pub.dev/fluttertoast-8.2.10/android/src/main/kotlin/io/github/ponnamkarthik/toast/fluttertoast/MethodCallHandlerImpl.kt:51:26 Variable expected
e: file:///Users/stant/.pub-cache/hosted/pub.dev/fluttertoast-8.2.10/android/src/main/kotlin/io/github/ponnamkarthik/toast/fluttertoast/MethodCallHandlerImpl.kt:54:45 Unresolved reference: R
e: file:///Users/stant/.pub-cache/hosted/pub.dev/fluttertoast-8.2.10/android/src/main/kotlin/io/github/ponnamkarthik/toast/fluttertoast/MethodCallHandlerImpl.kt:57:60 Unresolved reference: R
e: file:///Users/stant/.pub-cache/hosted/pub.dev/fluttertoast-8.2.10/android/src/main/kotlin/io/github/ponnamkarthik/toast/fluttertoast/MethodCallHandlerImpl.kt:60:26 Variable expected
e: file:///Users/stant/.pub-cache/hosted/pub.dev/fluttertoast-8.2.10/android/src/main/kotlin/io/github/ponnamkarthik/toast/fluttertoast/MethodCallHandlerImpl.kt:63:30 Variable expected
e: file:///Users/stant/.pub-cache/hosted/pub.dev/fluttertoast-8.2.10/android/src/main/kotlin/io/github/ponnamkarthik/toast/fluttertoast/MethodCallHandlerImpl.kt:75:30 Variable expected```

App code is here: https://github.com/supergreenlab/SuperGreenApp2

Thanks:)

vitaminwater avatar Jan 21 '25 17:01 vitaminwater

@ponnamkarthik is there a permanent fix to this issue? every time the app build,s we need to open the Kotlin file and refresh the dependencies for the app to build correctly

isrishu avatar Mar 04 '25 13:03 isrishu

Have you test with latest version 8.2.12

ponnamkarthik avatar Mar 04 '25 13:03 ponnamkarthik

yes, the issue has started from 8.2.12. I had 8.2.10 before and it was all good.

isrishu avatar Mar 04 '25 13:03 isrishu

is it possible for you to send me a sample project with issue

ponnamkarthik avatar Mar 04 '25 13:03 ponnamkarthik

sorry i got delayed in prepping a sample project. here it is https://github.com/isrishu/toast_test_app

isrishu avatar Mar 07 '25 16:03 isrishu

+1

lukeirvin avatar Apr 02 '25 22:04 lukeirvin

+1

ebonke avatar Apr 16 '25 12:04 ebonke

No solution yet ?

Suheb786 avatar Apr 23 '25 05:04 Suheb786

I guess most of you have upgraded the Android Gradle Plugin (AGP) to 8.x and are encountering namespace issues because the Gradle group name doesn’t match the package name. When you use this script to set the namespace, the R class cannot be resolved, since the group name is "com.example.FlutterToast", which isn’t the correct package name. This issue can occur in many plugins too.

afterEvaluate { project -> if (project.hasProperty('android')) { project.android { if (!hasProperty('namespace') || namespace == null || namespace.isEmpty()) { // Assign a default namespace based on the project name or group namespace = project.group.toString() ?: "com.example.${project.name}" println ">>> [${project.name}] namespace = ${namespace}" } } } }

I hope this helps you all. Thanks! #561

Jaemin-VIRNECT avatar May 14 '25 05:05 Jaemin-VIRNECT

@Jaemin-VIRNECT, this seems to fix the issue. thank you

isrishu avatar May 15 '25 03:05 isrishu

nope. @Jaemin-VIRNECT it did not fix the issue. the error persists. hope there is a response from @ponnamkarthik

isrishu avatar May 15 '25 11:05 isrishu

It worked for me. Hope you can fix your issue soon!

@isrishu I’d be happy to test it with your sample project this weekend if you're facing any difficulties. Would you like me to give it a try?

Jaemin-VIRNECT avatar May 15 '25 13:05 Jaemin-VIRNECT

hi @Jaemin-VIRNECT thanks for your offer. i did put in my sample project above. but I have decided to not use this plugin now. it is too much work wrote myself a workaround with snackbars

isrishu avatar Jun 01 '25 05:06 isrishu