apache / cordova-android

Apache Cordova Android
https://cordova.apache.org/
Apache License 2.0
3.59k stars 1.52k forks source link

The Android Gradle plugin supports only kotlin-android-extensions Gradle plugin version 1.6.20 and higher. #1645

Closed lianglee closed 8 months ago

lianglee commented 8 months ago

Bug Report

When using android platform 12 while compiling the app getting error

The Android Gradle plugin supports only kotlin-android-extensions Gradle plugin version 1.6.20 and higher.

Information

> Configure project :app
Adding classpath: com.google.gms:google-services:4.3.8
Warning: The 'kotlin-android-extensions' Gradle plugin is deprecated. Please use this migration guide (https://goo.gle/kotlin-android-extensions-deprecation) to start working with View Binding (https://developer.android.com/topic/libraries/view-binding) and the 'kotlin-parcelize' plugin.

FAILURE: Build failed with an exception.

* What went wrong:
The Android Gradle plugin supports only kotlin-android-extensions Gradle plugin version 1.6.20 and higher.
The following dependencies do not satisfy the required version:
root project 'App' -> org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.20

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

See https://docs.gradle.org/7.6/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 3s
Command failed with exit code 1: c:\app\platforms\android\gradlew -b c:\app\platforms\android\build.gradle cdvBuildDebug
breautek commented 8 months ago

cordova-android@12 kotlin version defaults to 1.7.21

Is your app or any of your installed plugins overriding the GradlePluginKotlinVersion preference?

lianglee commented 8 months ago

@breautek thank you for saving my time it was indeed one plugin that I used. Removed it and resolved the issue.

One last question how to use cordovaConfig.AGP_VERSION these variables in build.gradle (root) ?

MY ROOT/build.gradle

signingConfigs {
   release {
       storeFile file("/PATH/keystore")
       storePassword "****"
       keyAlias "****"
       keyPassword "****"
   }
}

buildscript {
    repositories {
        maven { url 'https://plugins.gradle.org/m2/'}
    }
   dependencies {
    // Add this line
      classpath 'com.google.gms:google-services:4.3.8'
  }
}
buildTypes {
        release {
            // (...)
            signingConfig signingConfigs.release
        }
}
breautek commented 8 months ago

I think you'll need apply from: 'CordovaLib/cordova.gradle' (or a way to import the cordova.gradle which is what sets up cordovaConfig whose values are mostly sourced from a generated json file.

But i'm not 100% confident if that will work. I'd need to do testing and experimenting which I don't really have the time to do.

the cordova.gradle is applied at the project level however, so I think all modules should have access to cordovaConfig, including the app module gradle file.

lianglee commented 8 months ago

Thanks for letting me know I will check it out!