Skip to content

Update compile version and fix cast map - #152

Open
Daevsoft wants to merge 1 commit into
Yukams:masterfrom
Daevsoft:patch-1
Open

Update compile version and fix cast map#152
Daevsoft wants to merge 1 commit into
Yukams:masterfrom
Daevsoft:patch-1

Conversation

@Daevsoft

Copy link
Copy Markdown

This PR fixes a Kotlin return type mismatch that occurs when building with Kotlin 1.8+ or 1.9+.
The previous implementation returned a HashMap<String, Any?> while the declared return type was HashMap<Any, Any>, which causes a build failure due to stricter generic variance checks introduced in newer Kotlin versions.

Return type mismatch: expected 'java.util.HashMap<kotlin.Any, kotlin.Any>',
actual 'kotlin.collections.HashMap<kotlin.String, it(kotlin.Comparable<*>? & java.io.Serializable?)>'

🧩 Root Cause

Kotlin 1.8 and above enforces stronger generic type safety.
Returning HashMap<String, Any?> when the function signature expects HashMap<Any, Any> is no longer allowed implicitly.

🔧 Changes Made

Updated the function in LocationParserUtil.kt to use consistent generic types between declaration and return value.
Example fix:

fun toMap(location: Location): HashMap<String, Any?> {
    val map = HashMap<String, Any?>()
    ...
    return map
}

(Alternatively, the fix may safely cast the map to HashMap if necessary.)

✅ Result
Plugin now compiles successfully with:

  • Kotlin 1.8.x and 1.9.x
  • Android Gradle Plugin 8.x
  • compileSdkVersion 34
No behavioral changes to runtime logic.

🔬 Tested On

  • Flutter 3.24.3
  • Kotlin 1.9.24
  • Android Gradle Plugin 8.6.0
  • Android SDK 34

#🧠 Notes

This change maintains backward compatibility with older Kotlin versions while ensuring successful builds for projects using modern Flutter/Android toolchains.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant