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 3.24 build apk issue #5542

Open
2 of 14 tasks
KishanD24 opened this issue Oct 13, 2024 · 26 comments
Open
2 of 14 tasks

Flutter 3.24 build apk issue #5542

KishanD24 opened this issue Oct 13, 2024 · 26 comments
Labels
auth Issues related to the Auth Category not-reproducible Issues that cannot be reproduced using the steps provided pending-close-response-required The issue will be closed if details necessary to reproduce the issue are not provided within 7 days. question A question about the Amplify Flutter libraries

Comments

@KishanD24
Copy link

Description

amplify_auth_cognito Having issue win32 and 2nd is as below issue

i fixed win32 by adding
dependency_overrides:
win32: ^5.6.0

but still having issue in flutter 3.24 as below

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

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: C:\Users\Kishan\AppData\Local\Android\sdk\platforms\android-34\core-for-system-modules.jar.
> Error while executing process C:\Program Files\Android\Android Studio\jbr\bin\jlink.exe with arguments {--module-path C:\Users\Kishan.gradle\caches\transforms-3\4a46fc8
9ed5f9adfe3afebf74eb8bfeb\transformed\output\temp\jmod --add-modules java.base --output C:\Users\Kishan.gradle\caches\transforms-3\4a46fc89ed5f9adfe3afebf74eb8bfeb\transformed\output\jdkImage --disable-plugin system-modules}

  • 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.
Get more help at https://help.gradle.org.

Categories

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

Steps to Reproduce

Just run in flutter 3.24

Screenshots

Screenshot 2024-10-13 132211

Platforms

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

Flutter Version

3.24.3

Amplify Flutter Version

2.4.1

Deployment Method

Amplify Gen 2

Schema

No response

@github-actions github-actions bot added pending-triage This issue is in the backlog of issues to triage pending-maintainer-response Pending response from a maintainer of this repository labels Oct 13, 2024
@tyllark
Copy link
Member

tyllark commented Oct 14, 2024

Hi @KishanD24, thank you for taking the time to submit this issue. We will look into it and provide updates when we can.

@github-actions github-actions bot removed the pending-maintainer-response Pending response from a maintainer of this repository label Oct 14, 2024
@tyllark tyllark added auth Issues related to the Auth Category pending-maintainer-response Pending response from a maintainer of this repository to-be-reproduced Issues that have not been reproduced yet, but have reproduction steps provided labels Oct 14, 2024
@passsy
Copy link
Contributor

passsy commented Oct 14, 2024

I have the same problem, changing the win32 version does not resolve the issue for me

@NikaHsn
Copy link
Member

NikaHsn commented Oct 14, 2024

@passsy @KishanD24 would you please provide reproduction steps so that we can investigate this issue. thanks.

@github-actions github-actions bot removed the pending-maintainer-response Pending response from a maintainer of this repository label Oct 14, 2024
@NikaHsn NikaHsn added the pending-community-response Pending response from the issue opener or other community members label Oct 14, 2024
@passsy
Copy link
Contributor

passsy commented Oct 15, 2024

  1. Create a flutter project
  2. add amplify_auth_cognito
  3. Build the android version

We discovered that is was caused by JDK 21. Downgrading to JDK 17 resolved the issue

@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 Oct 15, 2024
@KishanD24
Copy link
Author

KishanD24 commented Oct 15, 2024 via email

@alishawnee
Copy link

Description
Build fails with amplify auth

FAILURE: Build failed with an exception.

* What went wrong:
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: C:\Users\alish\AppData\Local\Android\sdk\platforms\android-34\core-for-system-modules.jar.
         > Error while executing process C:\Program Files\Android\Android Studio1\jbr\bin\jlink.exe with arguments {--module-path C:\Users\alish\.gradle\caches\transforms-3\4a46fc8
9ed5f9adfe3afebf74eb8bfeb\transformed\output\temp\jmod --add-modules java.base --output C:\Users\alish\.gradle\caches\transforms-3\4a46fc89ed5f9adfe3afebf74eb8bfeb\transformed\output\jdkImage --disable-plugin system-modules}

* 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.
> Get more help at https://help.gradle.org.

BUILD FAILED in 22s
Running Gradle task 'assembleDebug'...                             23.6s
Error: Gradle task assembleDebug failed with exit code 1

Development environment

  • Flutter 3.24.3
  • Dart 3.5.3
  • DevTools 2.37.3
  • java 17.0.11 2024-04-16 LTS
  • O.S window 11

amplify packages
amplify_flutter: ^2.4.1
amplify_auth_cognito: ^2.4.1

reproduction steps
Create a flutter project
add amplify_auth_cognito
Build the android version

@NikaHsn
Copy link
Member

NikaHsn commented Oct 15, 2024

@passsy @KishanD24 @alishawnee thanks for providing the info. we will look into this issue and get back to you with any updates.

@github-actions github-actions bot removed the pending-maintainer-response Pending response from a maintainer of this repository label Oct 15, 2024
@NikaHsn NikaHsn added question A question about the Amplify Flutter libraries and removed pending-triage This issue is in the backlog of issues to triage labels Oct 15, 2024
@NikaHsn
Copy link
Member

NikaHsn commented Oct 16, 2024

@passsy @KishanD24 @alishawnee I was not able to reproduce this issue following the steps. I get the below error if I do not update android platform settings as described here.

Execution failed for task ':app:processDebugMainManifest'.
> Manifest merger failed : uses-sdk:minSdkVersion 21 cannot be smaller than version 24 declared in library [:amplify_auth_cognito] /Users/nikaws/gh-issues/gh5542/build/amplify_auth_cognito/intermediates/merged_manifest/debug/AndroidManifest.xml as the library might be using APIs not available in 21
  	Suggestion: use a compatible library with a minSdk of at most 21,
  		or increase this project's minSdk version to at least 24,
  		or use tools:overrideLibrary="com.amazonaws.amplify.amplify_auth_cognito" to force usage (may lead to runtime failures)

After following the android platform setup I was able to build the android app and run it sucessfully.

@NikaHsn NikaHsn added not-reproducible Issues that cannot be reproduced using the steps provided pending-community-response Pending response from the issue opener or other community members and removed to-be-reproduced Issues that have not been reproduced yet, but have reproduction steps provided labels Oct 16, 2024
@KishanD24
Copy link
Author

KishanD24 commented Oct 17, 2024 via email

@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 Oct 17, 2024
@NikaHsn
Copy link
Member

NikaHsn commented Oct 17, 2024

thanks for the reply and glad that the issue is resolved. as mentioned in our docs Amplify Flutter supports minimum java version 17 when targeting android platform.
@alishawnee let me know if you are still facing this issue, otherwise I will be closing this as there is no action on our end.

@github-actions github-actions bot removed the pending-maintainer-response Pending response from a maintainer of this repository label Oct 17, 2024
@NikaHsn NikaHsn added the pending-close-response-required The issue will be closed if details necessary to reproduce the issue are not provided within 7 days. label Oct 17, 2024
@ekjotmultani
Copy link
Member

Hi @sguptazeil, sorry to hear that you are also facing this issue. Can you confirm that you are on Java 17 or higher as mentioned above?

@github-actions github-actions bot removed the pending-maintainer-response Pending response from a maintainer of this repository label Nov 1, 2024
@Thechi2000
Copy link

Hi. I'm running into the exact same issue, using Java 17.

If I follow this guide, I instead get the error

FAILURE: Build failed with an exception.

* What went wrong:
Could not open cp_settings generic class cache for settings file './android/settings.gradle' (~/.gradle/caches/8.0/scripts/euncovhsbnx2l7anthcwnehgw).
> BUG! exception in phase 'semantic analysis' in source unit '_BuildScript_' Unsupported class file major version 65

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

* Get more help at https://help.gradle.org

Changing the gradle-wrapper version (e.g. to 8.3 or 8.10) gets me back to the initial issue.

./gradlew -v gives:

------------------------------------------------------------
Gradle 8.10
------------------------------------------------------------

Build time:    2024-08-14 11:07:45 UTC
Revision:      fef2edbed8af1022cefaf44d4c0514c5f89d7b78

Kotlin:        1.9.24
Groovy:        3.0.22
Ant:           Apache Ant(TM) version 1.10.14 compiled on August 16 2023
Launcher JVM:  17.0.12 (Arch Linux 17.0.12+7)
Daemon JVM:    /usr/lib/jvm/java-17-openjdk (no JDK specified, using current Java home)
OS:            Linux 5.15.167-1-MANJARO amd64

@github-actions github-actions bot added the pending-maintainer-response Pending response from a maintainer of this repository label Nov 18, 2024
@NikaHsn
Copy link
Member

NikaHsn commented Nov 19, 2024

@sguptazeil @Thechi2000 can you please provide us with reproduction steps.

@github-actions github-actions bot removed the pending-maintainer-response Pending response from a maintainer of this repository label Nov 19, 2024
@Thechi2000
Copy link

After further investigation, it turns out that flutter was using Android Studio's java21 installation. Changing the jdk path to java17 fixed the issue.

Still, if you are interested, here are the reproduction steps in java21:

  1. Create a new project flutter create test && cd test
  2. Add flutter cognito flutter pub add amplify_flutter amplify_auth_cognito amplify_authenticator
  3. Apply those instructions.
  4. Change the gradle-wrapper version to >= 8.3 (android/gradle/wrapper/gradle-wrapper.properties) to fix Unsupported class file major version 65
  5. Set the Kotlin JVM to > 17 (android/app/build.gradle) to fix Unknown Kotlin JVM target: 21

A full diff for the last three steps:

--- a/android/app/build.gradle
+++ b/android/app/build.gradle
@@ -11,12 +11,12 @@ android {
     ndkVersion = flutter.ndkVersion
 
     compileOptions {
-        sourceCompatibility = JavaVersion.VERSION_1_8
-        targetCompatibility = JavaVersion.VERSION_1_8
+        sourceCompatibility = JavaVersion.VERSION_17
+        targetCompatibility = JavaVersion.VERSION_17
     }
 
     kotlinOptions {
-        jvmTarget = JavaVersion.VERSION_1_8
+        jvmTarget = JavaVersion.VERSION_17
     }
 
     defaultConfig {
@@ -24,7 +24,7 @@ android {
         applicationId = "com.example.test"
         // You can update the following values to match your application needs.
         // For more information, see: https://flutter.dev/to/review-gradle-config.
-        minSdk = flutter.minSdkVersion
+        minSdk = 24
         targetSdk = flutter.targetSdkVersion
         versionCode = flutter.versionCode
         versionName = flutter.versionName
diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties
index 0aaefbc..d11cdd9 100644
--- a/android/gradle/wrapper/gradle-wrapper.properties
+++ b/android/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
 distributionBase=GRADLE_USER_HOME
 distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.1-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-all.zip
 networkTimeout=10000
 validateDistributionUrl=true
 zipStoreBase=GRADLE_USER_HOME
diff --git a/android/settings.gradle b/android/settings.gradle
index b9e43bd..276cdab 100644
--- a/android/settings.gradle
+++ b/android/settings.gradle
@@ -19,7 +19,7 @@ pluginManagement {
 plugins {
     id "dev.flutter.flutter-plugin-loader" version "1.0.0"
     id "com.android.application" version "8.1.0" apply false
-    id "org.jetbrains.kotlin.android" version "1.8.22" apply false
+    id "org.jetbrains.kotlin.android" version "1.9.10" apply false
 }
 
 include ":app"

This exact same project builds correctly with java17

@github-actions github-actions bot added the pending-maintainer-response Pending response from a maintainer of this repository label Nov 20, 2024
@NikaHsn
Copy link
Member

NikaHsn commented Nov 20, 2024

thanks for confirming the issue is fixed using java 17. we will investigate this issue for java > 17 and provide update as we have them.

@github-actions github-actions bot removed the pending-maintainer-response Pending response from a maintainer of this repository label Nov 20, 2024
@ftauro99
Copy link

ftauro99 commented Dec 3, 2024

@NikaHsn Any update on this? I am attempting to build an APK for my project but am getting the same error as the above users:

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

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: C:\Users\user\AppData\Local\Android\sdk\platforms\android-34\core-for-system-modules.jar.
> Error while executing process C:\Program Files\Android\Android Studio\jbr\bin\jlink.exe with arguments {--module-path C:\Users\ftauro.gradle\caches\transforms-3\4a46fc89ed5f9adfe3afebf74eb8bfeb\transformed\output\temp\jmod --add-modules java.base --output C:\Users\ftauro.gradle\caches\transforms-3\4a46fc89ed5f9adfe3afebf74eb8bfeb\transformed\output\jdkImage --disable-plugin system-modules}

I am also using the same distribution URL as @alishawnee:
distributionUrl=https://services.gradle.org/distributions/gradle-8.3-all.zip

@github-actions github-actions bot added the pending-maintainer-response Pending response from a maintainer of this repository label Dec 3, 2024
@NikaHsn
Copy link
Member

NikaHsn commented Dec 3, 2024

@ftauro99 what Java version are you using? do you see this issue using Java 17?

@NikaHsn NikaHsn added pending-community-response Pending response from the issue opener or other community members and removed pending-maintainer-response Pending response from a maintainer of this repository labels Dec 3, 2024
@ftauro99
Copy link

ftauro99 commented Dec 3, 2024

@NikaHsn I am currently using Java 21:


Gradle 8.3

Build time: 2023-08-17 07:06:47 UTC
Revision: 8afbf24b469158b714b36e84c6f4d4976c86fcd5

Kotlin: 1.9.0
Groovy: 3.0.17
Ant: Apache Ant(TM) version 1.10.13 compiled on January 4 2023
JVM: 21.0.5 (Oracle Corporation 21.0.5+9-LTS-239)
OS: Windows 11 10.0 amd64

@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 3, 2024
@NikaHsn
Copy link
Member

NikaHsn commented Dec 3, 2024

@ftauro99 would you please try with Java 17 and let us know if you still face this issue?

@github-actions github-actions bot removed the pending-maintainer-response Pending response from a maintainer of this repository label Dec 3, 2024
@ftauro99
Copy link

ftauro99 commented Dec 4, 2024

@NikaHsn I just checked it appears to work fine using Java 17, just was curious on java versions > 17.

@github-actions github-actions bot added the pending-maintainer-response Pending response from a maintainer of this repository label Dec 4, 2024
@NikaHsn
Copy link
Member

NikaHsn commented Dec 4, 2024

@ftauro99 glad that the issue is resolved using Java 17. we will investigate this issue for java > 17 and provide update as we have them.

@github-actions github-actions bot removed the pending-maintainer-response Pending response from a maintainer of this repository label Dec 4, 2024
@Sathya-ac9
Copy link

Hi,

I am facing the same issue. The app runs when I open the Android folder in Android Studio, but I get an error when I try to run the main.dart file.

Here are the versions I’m using:

Java: 17
Flutter: 3.24.3
Dart: 3.5.3
DevTools: 2.37.3
Gradle: 8.5
How can I fix this issue?

@github-actions github-actions bot added the pending-maintainer-response Pending response from a maintainer of this repository label Dec 5, 2024
@Equartey Equartey added pending-maintainer-response Pending response from a maintainer of this repository and removed pending-maintainer-response Pending response from a maintainer of this repository labels Dec 9, 2024
@Equartey
Copy link
Contributor

Hi @Sathya-ac9, we are still investigating this issue. When we have updates we will provide them here.

@github-actions github-actions bot removed the pending-maintainer-response Pending response from a maintainer of this repository label Dec 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auth Issues related to the Auth Category not-reproducible Issues that cannot be reproduced using the steps provided pending-close-response-required The issue will be closed if details necessary to reproduce the issue are not provided within 7 days. question A question about the Amplify Flutter libraries
Projects
None yet
Development

No branches or pull requests