Skip to content

Android AGP 9: Unresolved reference SnapshotSender / PostHogFlutterSurveysDelegate #602

Description

@jamalalayeq

posthog_flutter 5.42.1 and 5.47.0 fail to compile on Android Gradle Plugin 9.2 when android.builtInKotlin=false (the Flutter migrator default).

e: PosthogFlutterPlugin.kt:154:34 Unresolved reference 'SnapshotSender'.
e: PosthogFlutterPlugin.kt:158:41 Unresolved reference 'PostHogFlutterSurveysDelegate'.
e: PosthogFlutterPlugin.kt:651:40 Unresolved reference 'PostHogFlutterSurveysDelegate'.
e: PosthogFlutterPlugin.kt:2202:33 Unresolved reference 'handleSurveyAction'.

SnapshotSender, PostHogFlutterSurveysDelegate, and handleSurveyAction are all in android/src/main/kotlin/com/posthog/flutter/, same package as PosthogFlutterPlugin.kt. They are unresolved because android/build.gradle still does:

sourceSets {
    main.java.srcDirs += 'src/main/kotlin'
}

AGP 9 does not support adding Kotlin sources to the Java source set (migration guide). Those .kt files are then compiled apart from the Kotlin source set, so sibling classes are invisible. 5.47.0 still has this block.

Please stop adding src/main/kotlin to java.srcDirs. src/main/kotlin is already the Kotlin source directory for both KGP and built-in Kotlin.

Toolchain: AGP 9.2.0, Kotlin 2.2.20, android.builtInKotlin=false, android.newDsl=false.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    AndroidbugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions