google / webcrypto.dart

Cross-platform implementation of Web Cryptography APIs
https://pub.dev/packages/webcrypto
Apache License 2.0
81 stars 48 forks source link

Migrate to Gradle's Plugin DSL and bump Kotlin version #146

Closed HamdaanAliQuatil closed 2 months ago

HamdaanAliQuatil commented 2 months ago

Flutter has deprecated imperative apply script method to apply Gradle plugins: Deprecated imperative apply of Flutter's Gradle plugins

While trying to run the example in this package, flutter run issues the following warning:

You are applying Flutter's app_plugin_loader Gradle plugin imperatively using the apply script method, which is deprecated and will be removed in a future release. 
Migrate to applying Gradle plugins with the declarative plugins block: https://flutter.dev/to/flutter-gradle-plugin-apply

You are applying Flutter's main Gradle plugin imperatively using the apply script method, which is deprecated and will be removed in a future release. 
Migrate to applying Gradle plugins with the declarative plugins block: https://flutter.dev/to/flutter-gradle-plugin-apply

The example code cannot run since Flutter's supported Kotlin version is 1.7.0 and the project uses 1.6.21. flutter run issues the following error:

FAILURE: Build failed with an exception.

* Where:
Script 'C:\flutter\packages\flutter_tools\gradle\src\main\kotlin\dependency_version_checker.gradle.kts' line: 375

* What went wrong:
Failed to apply plugin class 'Dependency_version_checker_gradle$FlutterDependencyCheckerPlugin'.
> Error: Your project's Kotlin version (1.6.21) is lower than Flutter's minimum supported version of 1.7.0. Please upgrade your Kotlin version. 
  Alternatively, use the flag "--android-skip-build-dependency-validation" to bypass this check.

  Potential fix: Your project's KGP version is typically defined in the plugins block of the `settings.gradle` file (C:\Users\Hamdaan\Desktop\downloads\webcrypto.dart\example\android/settings.gradle), by a plugin with the id of org.jetbrains.kotlin.android. 
  If you don't see a plugins block, your project was likely created with an older template version, in which case it is most likely defined in the top-level build.gradle file (C:\Users\Hamdaan\Desktop\downloads\webcrypto.dart\example\android/build.gradle) by the ext.kotlin_version property.

Solution: Bump Kotlin version in the new declarative plugins {} block to 1.7.10.

Step to Reproduce the error:

  1. Change directory to example.
  2. Execute flutter run.
HamdaanAliQuatil commented 2 months ago

Need to bump the Android NDK version as package requires version 26.1.10909125

Your project is configured with Android NDK 23.1.7779620, but the following plugin(s) depend on a different Android NDK version:
- integration_test requires Android NDK 26.1.10909125
- webcrypto requires Android NDK 26.1.10909125
Fix this issue by using the highest Android NDK version (they are backward compatible).
Add the following to \android\app\build.gradle:

    android {
        ndkVersion = "26.1.10909125"
        ...
    }