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

amplify_auth_cognito:compileDebugJavaWithJavac #4946

Closed
2 of 14 tasks
FabryPostRock opened this issue May 31, 2024 · 11 comments
Closed
2 of 14 tasks

amplify_auth_cognito:compileDebugJavaWithJavac #4946

FabryPostRock opened this issue May 31, 2024 · 11 comments
Labels
Build Issues related to building apps using Amplify flutter pending-maintainer-response Pending response from a maintainer of this repository question A question about the Amplify Flutter libraries

Comments

@FabryPostRock
Copy link

FabryPostRock commented May 31, 2024

Description

Hi everyone!

I m having big trouble in building an app with amplify libraries especially with amplify_auth_cognito. It's been days with 0 lines of code!

As last chance I tried to build a default flutter project but still I was not able to build with the following error:

Could not resolve all files for configuration ':amplify_auth_cognito:androidJdkImage'. Failed to transform core-for-system-modules.jar to match attributes {artifactType=_internal_android_jdk_image, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}. Execution failed for JdkImageTransform: C:\Users\xxxx\AppData\Local\Android\sdk\platforms\android-33\core-for-system-modules.jar. C:\Users\xxxx\.gradle\caches\transforms-3\88b68384482bcb9fc6a5fd8fded5da0b\transformed\output\temp\jmod\java.base.jmod

Below here I ll put all my sdk,jdk,pubspec,kotlin configurations:

  • Android Studio Giraffe | 2022.3.1 Patch 4 and Android Studio Iguana | 2023.2.1 Patch 2. I have tried a fresh install of Iguana (deleting C:\Users\XXXX.gradle) , but i got the same error
  • Flutter 3.16.8 , Dart 3.2.5 : it's not up to date because it's the only version compatible with Unity. Moreover I tried Flutter 3.19 and 3.22 with no better results.
  • JDK : 11. I have checked that the Windows JAVA_HOME environment var and the bin PATH are correctly set to this version. In File->Project Structure->Platform Settings ->SDKs JDK 11 is set. In File->Project Structure->Project Settings->Project no SDK is set
  • Android SDK BuildTools : 35-rc4
  • Kotlin : 1.7.10
  • Gradle : 7.5
  • AGP : 7.3.0

Laslty here is my pubspec.yaml:


version: 1.0.0+1

environment:
   
  sdk: '>=3.2.5 <4.0.0'
 
dependencies:
  flutter:
    sdk: flutter


application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^1.0.2
  http: ^0.13.4
  permission_handler: ^11.0.1
  url_launcher: ^6.2.2
  google_fonts: ^4.0.4
  flutter_dotenv: ^5.1.0
  # oauth2_client: ^2.3.2  //needs flutter_secure_storage:^5.1.2
  amplify_flutter: ^1.7.0
  amplify_core: ^1.7.0
  amplify_auth_cognito: ^1.7.0
  amplify_storage_s3: ^1.7.0
  video_player: ^2.8.6
  chewie: any
  wakelock: ^0.6.1 # Compatible version
  flutter_secure_storage: ^8.1.0 # ^5.0.2 Updated version compatible with Dart SDK
  #package_info_plus: ^5.0.1 # Compatible with flutter  3.16 Dart 3.2.5

dev_dependencies:
  flutter_test:
    sdk: flutter
flutter:
  uses-material-design: true

dependency_overrides:
  win32: ^4.1.2

can you please help me find a solution?

Thank you in advance

Categories

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

Steps to Reproduce

  1. Create an empty Flutter project
  2. Use the configuration above.

Screenshots

No response

Platforms

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

Flutter Version

3.16, 3.22

Amplify Flutter Version

1.7.0

Deployment Method

Amplify CLI

Schema

No response

@FabryPostRock FabryPostRock changed the title amplify_auth_cognito : JavacCompilerError amplify_auth_cognito:compileDebugJavaWithJavac May 31, 2024
@Jordan-Nelson
Copy link
Member

Hello @FabryPostRock - I am sorry to hear you are facing this issue. This is not an error that I have see before. I have a few questions:

  1. Was this working previously (with a previous version of Amplify, Flutter, Java, etc.)?
  2. Does the project build if you remove amplify_auth_cognito? Does it build if you remove all amplify dependencies?
  3. Are you able to attempt to use jdk 17? A similar issue here seemed to be resolved by using jdk 17.

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

FabryPostRock commented May 31, 2024

Hello @FabryPostRock - I am sorry to hear you are facing this issue. This is not an error that I have see before. I have a few questions:

  1. Was this working previously (with a previous version of Amplify, Flutter, Java, etc.)?
  2. Does the project build if you remove amplify_auth_cognito? Does it build if you remove all amplify dependencies?
  3. Are you able to attempt to use jdk 17? A similar issue here seemed to be resolved by using jdk 17.

First of all thank you @Jordan-Nelson for the quick answer. It never worked for me changing to jdk 19 - 21 but i ll try in a few minutes your suggested solution with jdk 17.

If I remove all the amplify dependencies it still doesn't build successfully. This is almost new because I remember that removing amplify_auth_cognito it was working. I'll try removing other dependencies step by step.

Looking at Gradle Compatibility Matrix it s not necessary to use different Gradle /AGP / Kotlin versions. I think I'll try with Gradle 7.6 , AGP 7.4 , and Kotlin 1.7.10.

@Jordan-Nelson
Copy link
Member

@FabryPostRock Thanks for the info. Let us know if you have any luck with jdk 17 or if you are able to get the project to build without amplify dependencies.

@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 31, 2024
@FabryPostRock
Copy link
Author

FabryPostRock commented May 31, 2024

@FabryPostRock Thanks for the info. Let us know if you have any luck with jdk 17 or if you are able to get the project to build without amplify dependencies.

I have created a new default Flutter project and tried to build it first with jdk 11 without amplify packages and it worked. Then I added all amplify packages and it didn't work. Then i commented the amplify_auth_cognito package and it worked.

I have also tried jdk 17 with all amplify packages and without amplify_auth_cognito and I got the same result. With jdk 17 i have used gradle 7.6 and AGP 7.4.0

@Jordan-Nelson
Copy link
Member

If this is a new project I would recommend using the latest version of Amplify Flutter (2.0) and to follow the platform setup guide for Android here: https://docs.amplify.aws/gen1/flutter/start/getting-started/setup/

@FabryPostRock
Copy link
Author

If this is a new project I would recommend using the latest version of Amplify Flutter (2.0) and to follow the platform setup guide for Android here: https://docs.amplify.aws/gen1/flutter/start/getting-started/setup/

I have created a new project with the libraries of my real current project to mess up without problems. Any suggestion about the issue?

@Jordan-Nelson
Copy link
Member

@FabryPostRock - Maybe I misunderstood. Did you have a Flutter application with Amplify Flutter dependencies installed that was previously able to build?

@FabryPostRock
Copy link
Author

FabryPostRock commented May 31, 2024

@FabryPostRock - Maybe I misunderstood. Did you have a Flutter application with Amplify Flutter dependencies installed that was previously able to build?

With amplify dependencies I was never able to build successfully. I just started a default project just to work with libraries and anything else. Do you have any suggested sdk ,gradle , AGP , kotlin configuration for version 1.7.0?

I have tried to build with Amplify package 2.0.0 and gradle 8.4 , AGP 7.4.2 , Kotlin 1.9.10 and jdk 17 but without amplify_auth_cognito I got:

Execution failed for task ':amplify_db_common:compileDebugJavaWithJavac'.
Could not resolve all files for configuration ':amplify_db_common:androidJdkImage'.
   Failed to transform core-for-system-modules.jar to match attributes {artifactType=_internal_android_jdk_image, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}.
      Execution failed for JdkImageTransform: C:\Users\XXXX\AppData\Local\Android\sdk\platforms\android-33\core-for-system-modules.jar.
         C:\Users\XXX\.gradle\caches\transforms-3\4b24f995fc9fb7a800bd1535a562fa3d\transformed\output\temp\jmod\java.base.jmod

one thing that bothers me is if i need to update this build.gradle section:

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    kotlinOptions {
        jvmTarget = '1_8'
    }

@FabryPostRock
Copy link
Author

FabryPostRock commented Jun 1, 2024

Oh my god I finally made it work. Here is my configuration:

  • jdk 11
  • kotlin 1.7.10
  • gradle 7.6
  • agp 7.4.2
  • flutter 3.16

pubspec.yaml:

version: 1.0.0+1

environment:
   
  sdk: '>=3.1.4 <4.0.0'
 
dependencies:
  flutter:
    sdk: flutter


application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^1.0.2
  http: ^0.13.4
  permission_handler: ^11.0.1
  url_launcher: ^6.2.2
  google_fonts: ^4.0.4
  flutter_dotenv: ^5.1.0
  # oauth2_client: ^2.3.2  //needs flutter_secure_storage:^5.1.2
  amplify_flutter: ^1.7.0
  amplify_core: ^1.7.0
  amplify_auth_cognito: ^1.7.0
  amplify_storage_s3: ^1.7.0
  video_player: ^2.8.6
  chewie: any
  wakelock: ^0.6.1 # Compatible version
  flutter_secure_storage: ^8.1.0 # ^5.0.2 Updated version compatible with Dart SDK
  #package_info_plus: ^5.0.1 # Compatible with flutter  3.16 Dart 3.2.5

dev_dependencies:
  flutter_test:
    sdk: flutter
flutter:
  uses-material-design: true

dependency_overrides:
  win32: ^4.1.2

The trick was to configure Gradle 7.6 and AGP 7.4.2 and I'm sure of it because downgrading to Gradle 7.5 and AGP 7.3.0 generates the error. I changed the sdk dependency from 3.2.5 to sdk: '>=3.1.4 <4.0.0' but it works with both sdks.

@Jordan-Nelson
Copy link
Member

@FabryPostRock I am glad to hear you were able to get this to work. We do list the kotlin, gradle, and AGP versions to use here. These are for the latest version of Amplify Flutter though. If you have any issues using the setup linked above with the latest version of Amplify Flutter, please let us know. I will close this out since it sounds like you have resolved this.

@Sathya-ac9
Copy link

Sathya-ac9 commented Dec 6, 2024

Hi,
I am encountering the following issue even after following the instructions on this link

Execution failed for task :amplify_analytics_pinpoint:compileDebugJavaWithJavac. Could not resolve all files for configuration :amplify_analytics_pinpoint:androidJdkImage. Failed to transform core-for-system-modules.jar to match attributes {artifactType=_internal_android_jdk_image, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}. Execution failed for JdkImageTransform: /Users/xxxx/Library/Android/sdk/platforms/android-34/core-for-system-modules.jar.

Here are the versions I’m using:

Java: 17
Flutter: 3.24.3
Dart: 3.5.3
DevTools: 2.37.3
Gradle: 8.5

Any solution?

Thanks,
Sathya.

@github-actions github-actions bot added pending-maintainer-response Pending response from a maintainer of this repository and removed pending-community-response Pending response from the issue opener or other community members labels Dec 6, 2024
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 pending-maintainer-response Pending response from a maintainer of this repository question A question about the Amplify Flutter libraries
Projects
None yet
Development

No branches or pull requests

3 participants