Flutter 3.24 build apk issue
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)
- [X] Auth
- [ ] Authenticator
- [ ] DataStore
- [ ] Notifications (Push)
- [ ] Storage
Steps to Reproduce
Just run in flutter 3.24
Screenshots
Platforms
- [ ] iOS
- [X] Android
- [ ] Web
- [ ] macOS
- [ ] Windows
- [ ] Linux
Flutter Version
3.24.3
Amplify Flutter Version
2.4.1
Deployment Method
Amplify Gen 2
Schema
No response
Hi @KishanD24, thank you for taking the time to submit this issue. We will look into it and provide updates when we can.
I have the same problem, changing the win32 version does not resolve the issue for me
@passsy @KishanD24 would you please provide reproduction steps so that we can investigate this issue. thanks.
- Create a flutter project
- add
amplify_auth_cognito - Build the android version
We discovered that is was caused by JDK 21. Downgrading to JDK 17 resolved the issue
Ok I try with lower jdk support.
On Tue, 15 Oct 2024, 3:23 pm Pascal Welsch, @.***> wrote:
- Create a flutter project
- add amplify_auth_cognito
- Build the android version
We discovered that is was caused by JDK 21. Downgrading to JDK 17 resolved the issue
— Reply to this email directly, view it on GitHub https://github.com/aws-amplify/amplify-flutter/issues/5542#issuecomment-2413428160, or unsubscribe https://github.com/notifications/unsubscribe-auth/AXLMEYS6B6K66REJUTSU5FTZ3TQ2HAVCNFSM6AAAAABP3GAL6GVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIMJTGQZDQMJWGA . You are receiving this because you were mentioned.Message ID: @.***>
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
@passsy @KishanD24 @alishawnee thanks for providing the info. we will look into this issue and get back to you with any updates.
@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.
Hello I solved that bug by updating my java version to 11 Now it's working fine in java 11.
If you want to close that issue then you can close it
Thank you for your response.
On Thu, 17 Oct 2024, 4:00 am NikaHsn, @.***> wrote:
@passsy https://github.com/passsy @KishanD24 https://github.com/KishanD24 @alishawnee https://github.com/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 https://docs.amplify.aws/flutter/start/platform-setup/#android.
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.
— Reply to this email directly, view it on GitHub https://github.com/aws-amplify/amplify-flutter/issues/5542#issuecomment-2418077379, or unsubscribe https://github.com/notifications/unsubscribe-auth/AXLMEYVZYKOXLKL5OM6EZALZ33SHTAVCNFSM6AAAAABP3GAL6GVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIMJYGA3TOMZXHE . You are receiving this because you were mentioned.Message ID: @.***>
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.
@NikaHsn Thank you so much for your help I did as you asked but I used jdistributionUrl=https://services.gradle.org/distributions/gradle-8.3-all.zip I'm getting the same error. It is not resolved yet.
Hi @alishawnee, I wasn't able to reproduce your error. I have this in my gradle-wrapper.properties file: distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-all.zip. I noticed there is the letter "j" in front of your distributionURL. Was this typo in your gradle-wrapper.properties file as well?
I'm also having the same issue
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?
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
@sguptazeil @Thechi2000 can you please provide us with reproduction steps.
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:
- Create a new project
flutter create test && cd test - Add flutter cognito
flutter pub add amplify_flutter amplify_auth_cognito amplify_authenticator - Apply those instructions.
- Change the gradle-wrapper version to >= 8.3 (
android/gradle/wrapper/gradle-wrapper.properties) to fixUnsupported class file major version 65 - Set the Kotlin JVM to > 17 (
android/app/build.gradle) to fixUnknown 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
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.
@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
@ftauro99 what Java version are you using? do you see this issue using Java 17?
@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
@ftauro99 would you please try with Java 17 and let us know if you still face this issue?
@NikaHsn I just checked it appears to work fine using Java 17, just was curious on java versions > 17.
@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.
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?
Hi @Sathya-ac9, we are still investigating this issue. When we have updates we will provide them here.
Here is the issue. Flutter default NDK is 21 while Amplify gen 2 uses NDK 25. Plus min sdk for flutter is 21 while min sdk for Amplify gen 2 is 24. Update those fields in your gradle file and it should do the trick.