Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Requires newer version of Kotlin Gradle Plugin #1517

Open
3 of 8 tasks
anmol-me opened this issue May 22, 2024 · 27 comments
Open
3 of 8 tasks

[Bug]: Requires newer version of Kotlin Gradle Plugin #1517

anmol-me opened this issue May 22, 2024 · 27 comments

Comments

@anmol-me
Copy link

anmol-me commented May 22, 2024

Please check the following before submitting a new issue.

Please select affected platform(s)

  • Android
  • iOS
  • Linux
  • macOS
  • Web
  • Windows

Steps to reproduce

  1. Install the dependency.
  2. Run in Android emulator without even importing the package.

Expected results

Should run without any errors.

Actual results

App doesn't run

Code sample

android\build

allprojects {
    repositories {
        google()
        mavenCentral()
    }
}

rootProject.buildDir = "../build"
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
    project.evaluationDependsOn(":app")
}

tasks.register("clean", Delete) {
    delete rootProject.buildDir
}

app\build

plugins {
    id "com.android.application"
    id "kotlin-android"
    // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
    id "dev.flutter.flutter-gradle-plugin"
}

def localProperties = new Properties()
def localPropertiesFile = rootProject.file("local.properties")
if (localPropertiesFile.exists()) {
    localPropertiesFile.withReader("UTF-8") { reader ->
        localProperties.load(reader)
    }
}

def flutterVersionCode = localProperties.getProperty("flutter.versionCode")
if (flutterVersionCode == null) {
    flutterVersionCode = "1"
}

def flutterVersionName = localProperties.getProperty("flutter.versionName")
if (flutterVersionName == null) {
    flutterVersionName = "1.0"
}

android {
    namespace = "com.anisingh.travel_project"
    compileSdk = flutter.compileSdkVersion
    ndkVersion = flutter.ndkVersion

    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_1_8
        targetCompatibility = JavaVersion.VERSION_1_8
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId = "com.anisingh.travel_project"
        // You can update the following values to match your application needs.
        // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
        minSdk = 28
        targetSdk = flutter.targetSdkVersion
        versionCode = flutterVersionCode.toInteger()
        versionName = flutterVersionName
    }

    buildTypes {
        release {
            // TODO: Add your own signing config for the release build.
            // Signing with the debug keys for now, so `flutter run --release` works.
            signingConfig = signingConfigs.debug
        }
    }
}

flutter {
    source = "../.."
}

Version

12.0.0

Flutter Doctor output

e: C:/Users/Anmol/.gradle/caches/transforms-3/362b2d499a05b04c0c112f7a304aa7e2/transformed/jetified-kotlin-stdlib-common-1.9.0.jar!/META-INF/kotlin-stdlib-common.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.9.0, expected version is 1.7.1.
e: C:/Users/Anmol/.gradle/caches/transforms-3/a986ff86be3aa69fb7fd119d17309b08/transformed/jetified-kotlin-stdlib-1.9.0.jar!/META-INF/kotlin-stdlib-jdk7.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.9.0, expected version is 1.7.1.
e: C:/Users/Anmol/.gradle/caches/transforms-3/a986ff86be3aa69fb7fd119d17309b08/transformed/jetified-kotlin-stdlib-1.9.0.jar!/META-INF/kotlin-stdlib-jdk8.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.9.0, expected version is 1.7.1.
e: C:/Users/Anmol/.gradle/caches/transforms-3/a986ff86be3aa69fb7fd119d17309b08/transformed/jetified-kotlin-stdlib-1.9.0.jar!/META-INF/kotlin-stdlib.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.9.0, expected version is 1.7.1.

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':app:compileDebugKotlin'.

A failure occurred while executing org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction
Compilation error. See log for more details

  • 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.

BUILD FAILED in 7s

┌─ Flutter Fix ──────────────────────────────────────────────────────────────────────────────┐
│ [!] Your project requires a newer version of the Kotlin Gradle plugin. │
│ Find the latest version on https://kotlinlang.org/docs/releases.html#release-details, then │
│ update C:\Users\Anmol\FlutterProjects\travel_project\android\build.gradle: │
│ ext.kotlin_version = '' │
└────────────────────────────────────────────────────────────────────────────────────────────┘
Error: Gradle task assembleDebug failed with exit code 1

@FlutteriPOP
Copy link

i am also facing the same issue

@rminkler1
Copy link

This is related to geolocator_android 4.6.0
A workaround is to add 4.5.5 to your dependencies until 4.6.0 gets fixed.

@anmol-me
Copy link
Author

This is related to geolocator_android 4.6.0 A workaround is to add 4.5.5 to your dependencies until 4.6.0 gets fixed.

Thanks @rminkler1

  1. Add the following to dependencies:
    geolocator: ^12.0.0
    geolocator_android: 4.5.5

  2. Run the following commands:
    flutter clean
    flutter pub get

@FlutteriPOP
Copy link

Thanks @rminkler1 Now Its Working Perfectolly

@Muhammadurasheed
Copy link

Wow!
It works 🤗
You just saved the day. You won't believe that I've been battling with the error for days

@rminkler1
Copy link

Wow! It works 🤗 You just saved the day. You won't believe that I've been battling with the error for days

I do believe you, because I was also battling this for days. I updated Flutter and I thought I broke something with my Flutter install. It took me almost a week to figure out it was this package.

@ravikumarbigwings
Copy link

This is related to geolocator_android 4.6.0 A workaround is to add 4.5.5 to your dependencies until 4.6.0 gets fixed.

thank you bro

@Meizzosama
Copy link

@anmol-me @rminkler1 what version to use for location package?

@rminkler1
Copy link

geolocator: ^12.0.0
geolocator_android: 4.5.5

@Meizzosama
Copy link

@rminkler1 sir i am asking for location package not for geolocator..

@rminkler1
Copy link

@rminkler1 sir i am asking for location package not for geolocator..

Then I'm afraid I don't understand what you are asking. Geolocator is the package that gets the location of the device. This thread is about a bug in the Android implementation of that package and how to workaround that bug until it is fixed.
I've only used geolocator once and ran into this bug, so I'm afraid I can't help beyond this.

@anmol-me
Copy link
Author

@Meizzosama Hey, please search if you can find a similar issue with the author of location package. If you can't find it, please raise the issue with the author.

Here is a link to help you get started: https://github.com/Lyokone/flutterlocation/issues

@Meizzosama
Copy link

@anmol-me Brother i found the solution. i-e, I haven't updated the kotlin version on file "settings.gradle" that's why it was giving me that error, but later on i fixed it. Thanks a bunch for your reply :)

@saumon
Copy link

saumon commented Jun 3, 2024

@rminkler1 thanks, switching to geolocator_android: 4.5.5 saved me hours of researches....

@aliwaseem27
Copy link

Facing the same problem, after searching for days found out that geolocator causing it. hope it will be fixed soon.

@Pieter-Uys
Copy link

geolocator: ^12.0.0 geolocator_android: 4.5.5

So for some reason when you add

geolocator_android: 4.5.5 it fixes the issue and then you can remove geolocator_android: 4.5.5 afterwards and geolocator: ^12.0.0 will work without it.

@cnLiuMing
Copy link

  1. geolocator_android

geolocator: ^12.0.0 still gives an error

@rminkler1
Copy link

rminkler1 commented Jun 7, 2024

  1. geolocator_android

geolocator: ^12.0.0 still gives an error

Add the following two dependencies:
geolocator: ^12.0.0
geolocator_android: 4.5.5

Run the following commands:
flutter clean
flutter pub get

@rminkler1
Copy link

rminkler1 commented Jun 7, 2024

geolocator: ^12.0.0 geolocator_android: 4.5.5

So for some reason when you add

geolocator_android: 4.5.5 it fixes the issue and then you can remove geolocator_android: 4.5.5 afterwards and geolocator: ^12.0.0 will work without it.

That might happen if you don't re-run pub get. I suspect if you run pub get again, it breaks again.

@vincent-hoodoo vincent-hoodoo mentioned this issue Jun 18, 2024
9 tasks
@jsqi2009
Copy link

jsqi2009 commented Jul 1, 2024

Thanks @rminkler1, fixed my issue

@Pieter-Uys
Copy link

Pieter-Uys commented Jul 9, 2024

geolocator: ^12.0.0 geolocator_android: 4.5.5

So for some reason when you add
geolocator_android: 4.5.5 it fixes the issue and then you can remove geolocator_android: 4.5.5 afterwards and geolocator: ^12.0.0 will work without it.

That might happen if you don't re-run pub get. I suspect if you run pub get again, it breaks again.

nope mine works perfectly without ' geolocator_android'🤷🏻 ran multiple pub gets and cleans and nothing breaks

@robiulm60ict
Copy link

This Error
Launching lib\main.dart on sdk gphone64 x86 64 in debug mode...
Running Gradle task 'assembleDebug'...
e: C:/Users/M360 App 1/.gradle/caches/transforms-3/884371f8ba4c22f7d845ae45913c9f76/transformed/jetified-kotlin-stdlib-2.0.0.jar!/META-INF/kotlin-stdlib-jdk7.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.9.0, expected version is 1.7.1.
e: C:/Users/M360 App 1/.gradle/caches/transforms-3/884371f8ba4c22f7d845ae45913c9f76/transformed/jetified-kotlin-stdlib-2.0.0.jar!/META-INF/kotlin-stdlib-jdk8.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.9.0, expected version is 1.7.1.
e: C:/Users/M360 App 1/.gradle/caches/transforms-3/884371f8ba4c22f7d845ae45913c9f76/transformed/jetified-kotlin-stdlib-2.0.0.jar!/META-INF/kotlin-stdlib.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.9.0, expected version is 1.7.1.

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':app:compileDebugKotlin'.

A failure occurred while executing org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction
Compilation error. See log for more details

  • 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.

BUILD FAILED in 9s

┌─ Flutter Fix ──────────────────────────────────────────────────────────────────────────────┐
│ [!] Your project requires a newer version of the Kotlin Gradle plugin. │
│ Find the latest version on https://kotlinlang.org/docs/releases.html#release-details, then │
│ update G:\RobiulFlutterProject\crm-zayed_robiul\android\build.gradle: │
│ ext.kotlin_version = '' │
└────────────────────────────────────────────────────────────────────────────────────────────┘
Error: Gradle task assembleDebug failed with exit code 1

packace version:
geolocator: ^12.0.0
geolocator_android: ^4.5.5

buildscript {
ext.kotlin_version = '2.0.0'
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.4.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

}

}

allprojects {
repositories {
google()
mavenCentral()
}
}

rootProject.buildDir = "../build"
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(":app")
}

tasks.register("clean", Delete) {
delete rootProject.buildDir
}

plugins {
id "com.android.application"
// START: FlutterFire Configuration
id 'com.google.gms.google-services'
// END: FlutterFire Configuration
id "kotlin-android"
// The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
id "dev.flutter.flutter-gradle-plugin"

}

def localProperties = new Properties()
def localPropertiesFile = rootProject.file("local.properties")
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader("UTF-8") { reader ->
localProperties.load(reader)
}
}

def flutterVersionCode = localProperties.getProperty("flutter.versionCode")
if (flutterVersionCode == null) {
flutterVersionCode = "1"
}

def flutterVersionName = localProperties.getProperty("flutter.versionName")
if (flutterVersionName == null) {
flutterVersionName = "1.0"
}

def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
android {
namespace = "com.crm360employee.crm"
compileSdk = 34
ndkVersion "25.1.8937393"

compileOptions {
    sourceCompatibility = JavaVersion.VERSION_1_8
    targetCompatibility = JavaVersion.VERSION_1_8
}

defaultConfig {

    // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
    applicationId = "com.crm360employee.crm"
    // You can update the following values to match your application needs.
    // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
    minSdk = flutter.minSdkVersion
    targetSdk = flutter.targetSdkVersion
    versionCode = flutterVersionCode.toInteger()
    versionName = flutterVersionName

}

signingConfigs {
    release {
        keyAlias keystoreProperties['keyAlias']
        keyPassword keystoreProperties['keyPassword']
        storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
        storePassword keystoreProperties['storePassword']
    }
}
buildTypes {
    release {
        // TODO: Add your own signing config for the release build.
        // Signing with the debug keys for now,
        // so `flutter run --release` works.

// signingConfig signingConfigs.debug
signingConfig signingConfigs.release
}
}
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
// Other dependencies
}

flutter {
source = "../.."
}
cupertino_icons: ^1.0.6
page_transition:
intl:
url_launcher:
get:
shared_preferences:
http:
file_picker: ^8.0.3
image_picker: ^1.1.2
lottie:
in_app_update:
rive: ^0.13.5
iconsax_flutter: ^1.0.0
syncfusion_flutter_calendar: ^26.1.41
cached_network_image: ^3.3.1
shimmer: ^3.0.0
iconsax: ^0.0.8
path_provider: ^2.1.3
flutter_image_compress: ^2.3.0
gallery_saver: ^2.1.1
percent_indicator: ^4.2.3
flutter_otp_text_field: ^1.1.3+2
device_info_plus: ^10.1.0
firebase_core: ^3.2.0
firebase_messaging: ^15.0.3
flutter_local_notifications: ^17.2.1+1
animation_list: ^3.0.0
flutter_background_service: ^5.0.6
geolocator: ^12.0.0
geolocator_android: ^4.5.5
connectivity_plus: ^6.0.3
sqflite: ^2.3.3+1
socket_io_client: ^3.0.0-beta.2
googleapis:
googleapis_auth:
geocoding: ^3.0.0
badges: ^3.1.2
primer_progress_bar: ^0.4.2
aura_box: ^1.0.2

@khushpajwani
Copy link

You can try adding dependencies After that just try performing the above-mentioned steps.

geolocator: ^12.0.0

geolocator_android: 4.5.5

Make sure to perform these two steps just because I did not clean it, it took me 2 hours to figure it out
flutter clean
flutter pub get

@tgbv
Copy link

tgbv commented Aug 4, 2024

#1517 (comment)~~

Thank you for providing the solution! This solves the issue for building the APK in debug mode, but it doesn't solve it when I need to build the APK for production

I receive the following errors and APK features don't work:


After further investigations I conclude the issue is related to another library. Please ignore this post.

@rminkler1
Copy link

I wonder if it would work using the dependency override for the Android module instead of declaring it directly. I also saw an update to the Android module to fix some bugs. I don't think it fixes this issue, but it might work without the override now. Worth trying

@BAStriver
Copy link

2. flutter clean
flutter pub get

thanks bro, i also fixed it by your comment. it's blocking me for two days....

@sajil-cookee
Copy link

I am also facing the same issue...

geolocator: ^12.0.0
geolocator_android: 4.5.5

flutter clean
flutter pub get

Thanks @rminkler1 fixed my issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests