-
Notifications
You must be signed in to change notification settings - Fork 173
Description
Description
After applying the namespace fix from PR #81, there's an additional build error due to missing kotlinOptions configuration in the android/build.gradle file.
This issue is related to PR #81 but requires an additional fix for full AGP 8+ compatibility.
Environment
- screenshot_callback version: 3.0.1
- Flutter SDK: 3.27.2
- Dart SDK: 3.6.1
- Android Gradle Plugin: 7.1.2+
- Kotlin version: 1.6.10
Steps to Reproduce
- Apply the namespace fix from PR feat: AGP 8 Support #81
- Add screenshot_callback: ^3.0.1 to pubspec.yaml
- Run flutter pub get
- Run flutter build apk or flutter run
- Build fails with JVM-target compatibility error
Error Message
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':screenshot_callback:compileDebugKotlin'.
> Inconsistent JVM-target compatibility detected for tasks 'compileDebugJavaWithJavac' (1.8) and 'compileDebugKotlin' (21).Expected Behavior
The plugin should build successfully without requiring manual modifications to package files.
Actual Behavior
Build fails after applying only the namespace fix. Requires additional kotlinOptions configuration.
Root Cause
The android/build.gradle file is missing the kotlinOptions block that sets the JVM target to match Java's version (1.8).
Proposed Solution
android {
namespace 'com.flutter.moum.screenshot_callback'
compileSdkVersion 33
defaultConfig {
minSdkVersion 21
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
lintOptions {
disable 'InvalidPackage'
}
kotlinOptions { // Add this block
jvmTarget = '1.8'
}
}Impact
This affects all users of this plugin with:
- Android Gradle Plugin 7.0 or higher
- Recent Flutter SDK versions
- Projects targeting Android SDK 33+
Workaround
Manually edit [pub-cache]/hosted/pub.dev/screenshot_callback-3.0.1/android/build.gradle to add the kotlinOptions block. However, this must be repeated on every development machine and after flutter clean.
Related
- PR feat: AGP 8 Support #81: Adds namespace (partially solves AGP 8+ compatibility)
- This issue: Adds kotlinOptions (completes AGP 8+ compatibility)
Both fixes are needed for full compatibility.
Additional Note
It appears this package may not be actively maintained (PR #81 has been open since October 2023). If there's no response, I'm willing to create a fork with both fixes and maintain it for the community.