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

flutter build apk results in "Module was compiled with an incompatible version of Kotlin..." #4771

Closed
2 of 14 tasks
michaelokonji opened this issue Apr 24, 2024 · 8 comments
Closed
2 of 14 tasks
Assignees
Labels
Build Issues related to building apps using Amplify flutter Documentation Improvements or fixes to public documentation (docs.amplify.aws, pub.dev, readmes).

Comments

@michaelokonji
Copy link

michaelokonji commented Apr 24, 2024

Description

flutter run works, but flutter build apk returns error for amplify kotlin module versions incompatibility.

Please help.

PS C:\Users\mich\workspaces\dev\app> flutter build apk
Font asset "MaterialIcons-Regular.otf" was tree-shaken, reducing it from 1645184 to 1424 bytes (99.9% reduction). Tree-shaking can be disabled by providing the --no-tree-shake-icons flag when building your app.
e: C:/Users/mich/workspaces/dev/app/build/amplify_secure_storage/.transforms/882fc968585de2a39939a5ade8ba94a7/transformed/out/jars/classes.jar!/META-INF/amplify_secure_storage_release.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.6.0.
e: C:/Users/mich/workspaces/dev/app/build/amplify_analytics_pinpoint/.transforms/86ba004b69ab9b970b47a9b61df31275/transformed/out/jars/classes.jar!/META-INF/amplify_analytics_pinpoint_release.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.6.0.
e: C:/Users/mich/workspaces/dev/app/build/amplify_db_common/.transforms/5f76e43e93e3d2d06d16b288304d908d/transformed/out/jars/classes.jar!/META-INF/amplify_db_common_release.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.6.0.
e: C:/Users/mich/workspaces/dev/app/build/amplify_auth_cognito/.transforms/ed980aea3cd907e9d20b8ec694411005/transformed/out/jars/classes.jar!/META-INF/amplify_auth_cognito_release.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.6.0.
e: C:/Users/mich/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.9.10/72812e8a368917ab5c0a5081b56915ffdfec93b7/kotlin-stdlib-1.9.10.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.6.0.
e: C:/Users/mich/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.9.10/72812e8a368917ab5c0a5081b56915ffdfec93b7/kotlin-stdlib-1.9.10.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.6.0.
e: C:/Users/mich/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.9.10/72812e8a368917ab5c0a5081b56915ffdfec93b7/kotlin-stdlib-1.9.10.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.6.0.
e: C:/Users/mich/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-common/1.9.10/dafaf2c27f27c09220cee312df10917d9a5d97ce/kotlin-stdlib-common-1.9.10.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.6.0.
Running Gradle task 'assembleRelease'...                           70.3s
√  Built build\app\outputs\flutter-apk\app-release.apk (58.6MB).
PS C:\Users\mich\workspaces\dev\app>

Categories

  • Analytics
  • API (REST)
  • API (GraphQL)
  • Auth
  • Authenticator
  • DataStore
  • Notifications (Push)
  • Storage

Steps to Reproduce

  • pubspec.yaml
name: app
description: "A new Flutter project."
publish_to: 'none' # Remove this line if you wish to publish to pub.dev

version: 1.0.0+1

environment:
  sdk: '>=3.3.4 <4.0.0'

dependencies:
  flutter:
    sdk: flutter
  amplify_auth_cognito: ^1.8.0
  amplify_flutter: ^1.8.0    
  logger: ^2.2.0
  cupertino_icons: ^1.0.6  

dev_dependencies:
  flutter_test:
    sdk: flutter
  mocktail: ^1.0.3
  integration_test:
    sdk: flutter    
  flutter_lints: ^3.0.0

flutter:
  uses-material-design: true
  assets:
    - assets/globe_logo.png

  • settings.gradle
pluginManagement {
    def flutterSdkPath = {
        def properties = new Properties()
        file("local.properties").withInputStream { properties.load(it) }
        def flutterSdkPath = properties.getProperty("flutter.sdk")
        assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
        return flutterSdkPath
    }
    settings.ext.flutterSdkPath = flutterSdkPath()

    includeBuild("${settings.ext.flutterSdkPath}/packages/flutter_tools/gradle")

    repositories {
        google()
        mavenCentral()
        gradlePluginPortal()
    }
}

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
}

include ":app"
  • build.gradle
buildscript {
    ext.kotlin_version = '1.9.10'
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:8.1.0'
        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
}
  • gradle-wrapper.properties
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1-all.zip

Screenshots

No response

Platforms

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

Flutter Version

3.19.6

Amplify Flutter Version

1.8.0

Deployment Method

Amplify CLI

Schema

No response

@Jordan-Nelson
Copy link
Member

@michaelokonji I think those may be warnings. The command seems to complete as it finishes with √ Built build\app\outputs\flutter-apk\app-release.apk (58.6MB).

Do you see an apk in that directory? You should be able to install it on your device with flutter install

@Jordan-Nelson Jordan-Nelson added pending-triage This issue is in the backlog of issues to triage Build Issues related to building apps using Amplify flutter pending-community-response Pending response from the issue opener or other community members labels Apr 24, 2024
@michaelokonji
Copy link
Author

@Jordan-Nelson You're correct, the build completes and app-release.apk is in the specified path but I'm uncertain if I can safely ignore these and move forward with with my release.

@Jordan-Nelson Jordan-Nelson removed the pending-community-response Pending response from the issue opener or other community members label Apr 24, 2024
@Jordan-Nelson
Copy link
Member

@michaelokonji - Thanks for the update. We will take a look at warnings and get back to you.

@Jordan-Nelson Jordan-Nelson added question A question about the Amplify Flutter libraries and removed pending-triage This issue is in the backlog of issues to triage labels May 7, 2024
@Jordan-Nelson Jordan-Nelson self-assigned this May 7, 2024
@harini18
Copy link

harini18 commented May 13, 2024

When I run flutter build appbundle --release
I get

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':amplify_db_common:compileReleaseJavaWithJavac'.

error: invalid source release: 17

My pubspec.yml

dependencies:
amplify_auth_cognito: ^2.0.0
amplify_authenticator: ^2.0.0
amplify_flutter: ^2.0.0

settings.gradle

plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version "7.4.2" apply false
id "org.jetbrains.kotlin.android" version "1.9.10" apply false
}

@NikaHsn
Copy link
Member

NikaHsn commented May 14, 2024

thank you for providing these details. we will look into this issue and get back to you with any updates.

@Jordan-Nelson Jordan-Nelson changed the title Flutter amplify dependency fails on apk build flutter build apk results in "Module was compiled with an incompatible version of Kotlin..." May 15, 2024
@Jordan-Nelson
Copy link
Member

@harini18 - Do you mind opening a separate issue so that we can keep this issue focused on the "incompatible version of kotlin" warning?

@Jordan-Nelson
Copy link
Member

Jordan-Nelson commented Jun 17, 2024

@michaelokonji I was able to reproduce this following the set up for Android in the docs. I think this is caused by using Android Gradle Plugin (AGP) v7 and Kotlin 1.9. If you update AGP to v8.1 and gradle to v8.0, the issue should go away. Here are the steps you would take to do that (Note: if your app was created prior to Flutter 3.16 follow these steps first):

  • update com.android.application in android/settings.gradle to "8.1.0"
  • update org.jetbrains.kotlin.android in android/settings.gradle to "1.9.10"
  • update distributionUrl in android/gradle/wrapper/gradle-wrapper.properties to https\://services.gradle.org/distributions/gradle-8.0-all.zip
  • update sourceCompatibility and targetCompatibility in android/app/build.gradle to JavaVersion.VERSION_17

Let me know if you have any issues. I am going to mark this as a docs issue since our docs currently recommend using a lower version of AGP and gradle

@Jordan-Nelson Jordan-Nelson added Documentation Improvements or fixes to public documentation (docs.amplify.aws, pub.dev, readmes). and removed Investigating question A question about the Amplify Flutter libraries labels Jun 17, 2024
@Jordan-Nelson
Copy link
Member

The documentation has been updated. Please refer to https://docs.amplify.aws/flutter/start/platform-setup/#android and let use know if you have any questions. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Build Issues related to building apps using Amplify flutter Documentation Improvements or fixes to public documentation (docs.amplify.aws, pub.dev, readmes).
Projects
None yet
Development

No branches or pull requests

4 participants