plus_plugins icon indicating copy to clipboard operation
plus_plugins copied to clipboard

[Question]: Getting this error with The binary version of its metadata is 1.9.0, expected version is 1.7.1.

Open simhead opened this issue 1 year ago • 9 comments

What is your question?

I have added android_alarm_manager_plus: ^4.0.3 to pubspec.yaml and when I run flutter build apk, I am getting this error: ''' /.pub-cache/hosted/pub.dev/android_alarm_manager_plus-4.0.3/android/src/main/kotlin/dev/fluttercommunity/plus/androidalarmmanager/AlarmBroadcastReceiver.kt: (27, 18): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.9.0, expected version is 1.7.1. The class is loaded from /Users/peterkim/.gradle/caches/transforms-4/44f32ef92a48a9a2ea0a5cd6f6ead497/transformed/jetified-kotlin-stdlib-1.9.23.jar!/kotlin/Unit.class '''

here is my build.gradle: ''' buildscript { ext.kotlin_version = '1.9.24' repositories { google() jcenter() }

dependencies {
    classpath 'com.android.tools.build:gradle:7.2.0'
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}

} '''

can someone suggest how to fix this?

Checklist before submitting a question

  • [X] I searched issues in this repository and couldn't find such bug/problem
  • [X] I Google'd a solution and I couldn't find it
  • [X] I searched on StackOverflow for a solution and I couldn't find it
  • [X] I read the README.md file of the plugin
  • [X] I am using the latest version of the plugin
  • [X] All dependencies are up to date with flutter pub upgrade
  • [X] I did a flutter clean
  • [X] I tried running the example project

simhead avatar May 15 '24 07:05 simhead

Please check plugin's requirements first and update your project accordingly: https://github.com/fluttercommunity/plus_plugins/tree/main/packages/android_alarm_manager_plus#requirements

You need to update Android Gradle Plugin version in your project.

vbuberen avatar May 15 '24 08:05 vbuberen

I did followed the requirement and still getting the message. here are some details for my env: flutter --version

Flutter 3.22.0 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 5dcb86f68f (7 days ago) • 2024-05-09 07:39:20 -0500
Engine • revision f6344b75dc
Tools • Dart 3.4.0 • DevTools 2.34.3

java --version

java 17.0.7 2023-04-18 LTS
Java(TM) SE Runtime Environment (build 17.0.7+8-LTS-224)
Java HotSpot(TM) 64-Bit Server VM (build 17.0.7+8-LTS-224, mixed mode, sharing)

android/gradle/wrapper/gradle-wrapper.properties

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
# distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.3-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-all.zip

android/build.gradle

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
}

buildscript {
    ext.kotlin_version = '1.9.24'
    // repositories {
    //     google()
    //     mavenCentral()
    // }

    // dependencies {
    //     classpath 'com.android.tools.build:gradle:7.2.0'
    //     classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    // }
}

android/app/build.gradle

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.example.oci_alarm_manager"
    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.example.oci_alarm_manager"
        // 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.
        minSdkVersion flutter.minSdkVersion
        targetSdkVersion flutter.targetSdkVersion
        // minSdkVersion 21
        // targetSdkVersion 32
        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 = "../.."
}

can you tell me what's missing?

simhead avatar May 16 '24 06:05 simhead

//     classpath 'com.android.tools.build:gradle:7.2.0'

Which version of the Android Gradle Plugin you use instead of this commented line? It needs to be at least 8.3.0.

vbuberen avatar May 16 '24 07:05 vbuberen

I have tried as suggested and still getting the same error:

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
}

buildscript {
    ext.kotlin_version = '1.9.24'
    repositories {
        google()
        mavenCentral()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:8.3.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.24"
    }
}

simhead avatar May 16 '24 08:05 simhead

btw I am using macos 14.4.1

simhead avatar May 16 '24 08:05 simhead

hello am getting the same error, any solutions yet

bethel-m avatar Jun 11 '24 11:06 bethel-m

hello again, i tried this and it worked for me: i specified the kotlin version in the settings.gradle file, and i did not bother adding it again in the build.gradle file from this: plugins { id "dev.flutter.flutter-plugin-loader" version "1.0.0" id "com.android.application" version "7.3.0" apply false id "org.jetbrains.kotlin.android" version "1.7.10" apply false } to this: plugins { id "dev.flutter.flutter-plugin-loader" version "1.0.0" id "com.android.application" version "7.3.0" apply false id "org.jetbrains.kotlin.android" version "1.9.10" apply false }

bethel-m avatar Jun 14 '24 15:06 bethel-m

It worked for me: https://github.com/flutter-stripe/flutter_stripe/issues/1669

VanhnguyenX8 avatar Jul 09 '24 08:07 VanhnguyenX8

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 15 days

github-actions[bot] avatar Oct 08 '24 00:10 github-actions[bot]