4.2.0 fails to compile on Kotlin 2.2.20 host — Unresolved reference 'AppodealBaseFlutterPlugin'
Summary
stack_appodeal_flutter 4.2.0 (and 4.1.0) fails to compile its own Android Kotlin sources when the host app uses Kotlin 2.2.20. The module-internal internal abstract class AppodealBaseFlutterPlugin is reported as an unresolved reference from AppodealConsentManager.kt, despite being declared in the same package and same Gradle module. Reverting to 3.12.0 compiles cleanly with no other changes.
Environment
|
Version |
| Plugin |
stack_appodeal_flutter 4.2.0 (also reproduced with 4.1.0 source) |
| Flutter |
3.44.4 (stable, channel stable) |
| Dart |
3.12.2 |
| Kotlin (host) |
2.2.20 (settings.gradle.kts: id("org.jetbrains.kotlin.android") version "2.2.20") |
| AGP |
8.11.1 |
| Gradle |
8.14 |
| Target |
Android compileSdk/targetSdk = Flutter defaults (35), minSdk 24 |
| OS |
macOS (Darwin 25.5) |
Error
> Task :stack_appodeal_flutter:compileDebugKotlin FAILED
e: .../stack_appodeal_flutter-4.2.0/android/src/main/kotlin/com/appodeal/appodeal_flutter/AppodealConsentManager.kt:16:32
Unresolved reference 'AppodealBaseFlutterPlugin'.
e: .../AppodealConsentManager.kt:40:38 Unresolved reference 'activity'.
e: .../AppodealConsentManager.kt:85:42 Unresolved reference 'activity'.
e: .../AppodealConsentManager.kt:96:38 Unresolved reference 'activity'.
e: .../AppodealConsentManager.kt:127:45 Unresolved reference 'context'.
e: .../AppodealConsentManager.kt:143:38 Unresolved reference 'activity'.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':stack_appodeal_flutter:compileDebugKotlin'.
> Compilation error. See log for more details.
AppodealBaseFlutterPlugin is declared in AppodealBaseFlutterPlugin.kt (same package com.appodeal.appodeal_flutter, same module) as:
internal abstract class AppodealBaseFlutterPlugin :
FlutterPlugin, MethodChannel.MethodCallHandler, ActivityAware {
internal val activity: Activity get() = requireNotNull(activityReference.get())
internal val context: Context get() = requireNotNull(activityReference.get() ?: contextReference.get())
...
}
and referenced by AppodealConsentManager.kt:
internal class AppodealConsentManager(
private val flutterPlugin: AppodealBaseFlutterPlugin, // <-- unresolved
flutterPluginBinding: FlutterPlugin.FlutterPluginBinding
) : MethodChannel.MethodCallHandler { ... }
The 3.12.0 plugin has no such abstraction and compiles cleanly under the identical host config.
Reproduction
flutter create an app (Flutter 3.44.4).
- Add
stack_appodeal_flutter: ^4.2.0.
- Keep the default Kotlin version resolved by Flutter 3.44 (2.2.20).
flutter build apk --debug → :stack_appodeal_flutter:compileDebugKotlin fails with the errors above.
- Downgrade to
stack_appodeal_flutter: ^3.12.0 (no other changes) → builds successfully.
Expected behavior
The 4.2.0 plugin compiles on a standard current Flutter/Kotlin toolchain (Kotlin 2.2.x).
Actual behavior
Compilation of the plugin's own Kotlin module fails on Kotlin 2.2.20.
Workaround that does not work
Pinning the host Kotlin down to 2.1.0 (the version in the plugin's own build.gradle ext.kotlin_version) resolves the AppodealBaseFlutterPlugin error, but breaks unrelated dependencies that require newer Kotlin metadata. In particular, google_mobile_ads: ^9.0.0 → play-services-ads:25.3.0 is published with Kotlin metadata version 2.3.0, which the 2.1.0 compiler cannot read:
e: .../play-services-ads-25.3.0-api.jar!/META-INF/...kotlin_module
Module was compiled with an incompatible version of Kotlin.
The binary version of its metadata is 2.3.0, expected version is 2.1.0.
So there is currently no single Kotlin version that compiles both stack_appodeal_flutter 4.2.0 and the current google_mobile_ads, forcing apps that use AdMob directly to stay on plugin 3.12.0.
Notes / suggested fix
- The regression was introduced in 4.x via the new
AppodealBaseFlutterPlugin abstraction (absent in 3.12). Internal cross-file resolution of that class appears to break under Kotlin 2.2.20.
- Consider building/publishing the plugin against a current Kotlin (2.2.x / 2.3.x) and/or migrating to Flutter's built-in Kotlin (the
dev.flutter.flutter-plugin-loader "Built-in Kotlin" path), which would decouple the plugin's Kotlin from the host and avoid this class of conflict.
Happy to provide a full flutter doctor -v, build logs, or a minimal repro repo on request. Thank you!
4.2.0 fails to compile on Kotlin 2.2.20 host —
Unresolved reference 'AppodealBaseFlutterPlugin'Summary
stack_appodeal_flutter4.2.0 (and 4.1.0) fails to compile its own Android Kotlin sources when the host app uses Kotlin 2.2.20. The module-internalinternal abstract class AppodealBaseFlutterPluginis reported as an unresolved reference fromAppodealConsentManager.kt, despite being declared in the same package and same Gradle module. Reverting to 3.12.0 compiles cleanly with no other changes.Environment
stack_appodeal_flutter4.2.0 (also reproduced with 4.1.0 source)settings.gradle.kts:id("org.jetbrains.kotlin.android") version "2.2.20")compileSdk/targetSdk= Flutter defaults (35),minSdk24Error
AppodealBaseFlutterPluginis declared inAppodealBaseFlutterPlugin.kt(same packagecom.appodeal.appodeal_flutter, same module) as:and referenced by
AppodealConsentManager.kt:The 3.12.0 plugin has no such abstraction and compiles cleanly under the identical host config.
Reproduction
flutter createan app (Flutter 3.44.4).stack_appodeal_flutter: ^4.2.0.flutter build apk --debug→:stack_appodeal_flutter:compileDebugKotlinfails with the errors above.stack_appodeal_flutter: ^3.12.0(no other changes) → builds successfully.Expected behavior
The 4.2.0 plugin compiles on a standard current Flutter/Kotlin toolchain (Kotlin 2.2.x).
Actual behavior
Compilation of the plugin's own Kotlin module fails on Kotlin 2.2.20.
Workaround that does not work
Pinning the host Kotlin down to 2.1.0 (the version in the plugin's own
build.gradleext.kotlin_version) resolves theAppodealBaseFlutterPluginerror, but breaks unrelated dependencies that require newer Kotlin metadata. In particular,google_mobile_ads: ^9.0.0→play-services-ads:25.3.0is published with Kotlin metadata version 2.3.0, which the 2.1.0 compiler cannot read:So there is currently no single Kotlin version that compiles both
stack_appodeal_flutter4.2.0 and the currentgoogle_mobile_ads, forcing apps that use AdMob directly to stay on plugin 3.12.0.Notes / suggested fix
AppodealBaseFlutterPluginabstraction (absent in 3.12). Internal cross-file resolution of that class appears to break under Kotlin 2.2.20.dev.flutter.flutter-plugin-loader"Built-in Kotlin" path), which would decouple the plugin's Kotlin from the host and avoid this class of conflict.Happy to provide a full
flutter doctor -v, build logs, or a minimal repro repo on request. Thank you!