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

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

Open
8 tasks done
simhead opened this issue May 15, 2024 · 5 comments
Labels
question Further information is requested

Comments

@simhead
Copy link

simhead commented May 15, 2024

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

  • I searched issues in this repository and couldn't find such bug/problem
  • I Google'd a solution and I couldn't find it
  • I searched on StackOverflow for a solution and I couldn't find it
  • I read the README.md file of the plugin
  • I am using the latest version of the plugin
  • All dependencies are up to date with flutter pub upgrade
  • I did a flutter clean
  • I tried running the example project
@simhead simhead added the question Further information is requested label May 15, 2024
@vbuberen
Copy link
Collaborator

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.

@simhead
Copy link
Author

simhead commented May 16, 2024

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?

@vbuberen
Copy link
Collaborator

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

@simhead
Copy link
Author

simhead commented May 16, 2024

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
Copy link
Author

simhead commented May 16, 2024

btw I am using macos 14.4.1

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

No branches or pull requests

2 participants