-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Description
Use case
Hi!
Our Android project is integrated with Flutter trough flutter module; it's a large native codebase project where we are migrating to 100% Flutter.
Context
The native side setup is built with Kotlin 2.0 and AGP 8.2.2 and we are doing well using flutter 3.24.0, which uses Kotlin 1.7.10 and agp 7.3.0, defined from default variable templateKotlinGradlePluginVersion and templateAndroidGradlePluginVersionForModule respectively, variables used to generate the .android folder for every run of flutter pub get or flutter build aar.
Problem
We are bumping our code base Flutter (plugins and third-party libraries) to Kotlin 2.0 and AGP 8.2.2 (like the native project setup), but we are not able to build the aar after upgrading the dynatrace_flutter_plugin. Which is reproducing the following output:
e: file:///Users/xxx/.pub-cache/hosted/pub.dev/dynatrace_flutter_plugin-3.305.2/android/src/main/kotlin/com/dynatrace/android/agent/SettingsApiImpl.kt:32:21 This declaration needs opt-in. Its usage must be marked with '@kotlin.ExperimentalStdlibApi' or '@OptIn(kotlin.ExperimentalStdlibApi::class)'
e: file:///Users/xxxx/.pub-cache/hosted/pub.dev/dynatrace_flutter_plugin-3.305.2/android/src/main/kotlin/com/dynatrace/android/agent/SettingsApiImpl.kt:32:41 This declaration needs opt-in. Its usage must be marked with '@kotlin.ExperimentalStdlibApi' or '@OptIn(kotlin.ExperimentalStdlibApi::class)'
e: file:///Users/xxx/.pub-cache/hosted/pub.dev/dynatrace_flutter_plugin-3.305.2/android/src/main/kotlin/com/dynatrace/android/agent/SettingsApiImpl.kt:32:41 The feature "enum entries" is only available since language version 1.9
This error indicates that the build of aar is using a Kotlin version below than 1.9.0; that is true, because in Flutter 3.27.0 the Kotlin version for templates is 1.8.22.
Steps to reproduce
The error above is reproduced using flutter 3.27.0.
- Create module:
flutter create -t module sample_module - Add dynatrace plugin:
cd sample_module && flutter pub add dynatrace_flutter_plugin - Build aar:
flutter build aar
- Note: The same occur using Flutter versions
3.24.0and3.24.3
Our proposals
Following the above scenario, we are requesting some of the following options to solve this problem:
1. Flexibility template options
Extend the functionality of pubspec yaml field module to support the definition of Kotlin, AGP, Gradle and the android.compileOptions.targetCompatibility/sourceCompatibility through YAML. Example:
name: sample_module
description: lorem epsum
version: 1.0.0+1
environment: ....
dependencies: ...
flutter:
module:
androidX: true
androidPackage: br.com.sample_module
...
kotlinVersion: 2.0.0
agpVersion: 8.2.2
gradleVresion: 8.2-all
javaTargetCompatiblity: 17
javaSourceCompatibility: 172. Create a toggle to prevent .android folder recreation
The Android setup has a note warning about the auto generated .android folder. It will be great if exists an toggle to turn off this auto-generation, so we can manually adjust the project and push to our repository.
3. Create a template that's supports kotlin 2.0 and AGP 8.x
Create a new template, adjusting setting up JAVA_17 and removing AndroidManifest.xml package field. Details here
Conclusion
I hope you guys understand our scenario and the steps to reproduce the error. Any doubts, touch me through e-mail: [email protected].
Best Regards,
Reberth Kelvin