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

unable to build simple android project #350

Open
smacz opened this issue Dec 29, 2024 · 4 comments
Open

unable to build simple android project #350

smacz opened this issue Dec 29, 2024 · 4 comments

Comments

@smacz
Copy link

smacz commented Dec 29, 2024

Hello,

I'm totally new to this so please cut me some slack.

I run this image, create project with

flutter create -t app --platform android test_app

then cd into it and run

flutter build apk

this is what I get

# flutter build apk

Checking the license for package Android SDK Build-Tools 33.0.1 in /opt/android-sdk-linux/licenses
License for package Android SDK Build-Tools 33.0.1 accepted.
Preparing "Install Android SDK Build-Tools 33.0.1 v.33.0.1".
"Install Android SDK Build-Tools 33.0.1 v.33.0.1" ready.
Installing Android SDK Build-Tools 33.0.1 in /opt/android-sdk-linux/build-tools/33.0.1
"Install Android SDK Build-Tools 33.0.1 v.33.0.1" complete.
"Install Android SDK Build-Tools 33.0.1 v.33.0.1" finished.
Checking the license for package Android SDK Platform 35 in /opt/android-sdk-linux/licenses
License for package Android SDK Platform 35 accepted.
Preparing "Install Android SDK Platform 35 (revision 2)".
"Install Android SDK Platform 35 (revision 2)" ready.
Installing Android SDK Platform 35 in /opt/android-sdk-linux/platforms/android-35
"Install Android SDK Platform 35 (revision 2)" complete.
"Install Android SDK Platform 35 (revision 2)" finished.
Font asset "MaterialIcons-Regular.otf" was tree-shaken, reducing it from 1645184 to 1384 bytes (99.9% reduction). Tree-shaking can be disabled by providing the --no-tree-shake-icons flag when building your app.
Target android_aot_release_android-arm failed: ProcessException: Failed to find "/sdks/flutter/bin/cache/artifacts/engine/android-arm-release/linux-arm64/gen_snapshot" in the search path.
  Command: /sdks/flutter/bin/cache/artifacts/engine/android-arm-release/linux-arm64/gen_snapshot 
Target android_aot_release_android-arm64 failed: ProcessException: Failed to find "/sdks/flutter/bin/cache/artifacts/engine/android-arm64-release/linux-arm64/gen_snapshot" in the search path.
  Command: /sdks/flutter/bin/cache/artifacts/engine/android-arm64-release/linux-arm64/gen_snapshot 
Target android_aot_release_android-x64 failed: ProcessException: Failed to find "/sdks/flutter/bin/cache/artifacts/engine/android-x64-release/linux-arm64/gen_snapshot" in the search path.
  Command: /sdks/flutter/bin/cache/artifacts/engine/android-x64-release/linux-arm64/gen_snapshot 


FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileFlutterBuildRelease'.
> Process 'command '/sdks/flutter/bin/flutter'' finished with non-zero exit value 1

* 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 1m 52s
Running Gradle task 'assembleRelease'...                          113.1s
Gradle task assembleRelease failed with exit code 1

what can I do to solve this?

@dhruvin207
Copy link

Issue: Gradle Daemon Crashing and Slow Builds in Bitbucket Pipeline

I am using the Docker image ghcr.io/cirruslabs/flutter:3.24.5 in my Bitbucket Pipeline. The Gradle build process takes a long time to initialize (~5 minutes), and then fails unexpectedly without a detailed error message. Below are the relevant logs:

[04:45:33]: ▸ Changing current working directory to: /opt/atlassian/pipelines/agent/build
[04:51:48]: ▸ Running Gradle task 'assembleDevRelease'...
[04:51:48]: ▸ Checking the license for package Android SDK Build-Tools 33.0.1 in /opt/android-sdk-linux/licenses
[04:51:48]: ▸ License for package Android SDK Build-Tools 33.0.1 accepted.
[04:55:13]: ▸ FAILURE: Build failed with an exception.
[04:55:13]: ▸ * What went wrong:
[04:55:13]: ▸ Gradle build daemon disappeared unexpectedly (it may have been killed or may have crashed)
[04:55:13]: ▸ * Try:
[04:55:13]: ▸ > Run with --stacktrace option to get the stack trace.
[04:55:13]: ▸ > Run with --info or --debug option to get more log output.

This issue consistently occurs during the Gradle task execution, with no clear stack trace or debug information provided. The pipeline ends with a Gradle task assembleDevRelease failed with exit code 1.

@allou-deyforyou
Copy link

@dhruvin207 Are you found a solution ?

@ohadcn
Copy link

ohadcn commented Jan 29, 2025

The source problem appeared as a warning when you create your app - android build can only run with java 17, while the image has java 21.

Markers are mine.

$ flutter create -t app --platform android test_app
Creating project test_app...
...
All done!
...

In order to run your application, type:

$ cd test_app
$ flutter run

Your application code is in test_app/lib/main.dart.

The configured version of Java detected may conflict with the Gradle version in your new Flutter app.

To keep the default AGP version Gradle version 8.3, download a compatible Java version
(Java 17 <= (Java 17 <= compatible Java version < Java 21) Java version < Java 21). Configure this Java version
globally for Flutter by running:

flutter config --jdk-dir=<JDK_DIRECTORY>

...

$

$ apt install openjdk-17-jre openjdk-17-jdk
...
$ flutter config --jdk-dir /usr/lib/jvm/java-17-openjdk-amd64/
...
$ flutter build apk
...
Running Gradle task 'assembleRelease'... 172.9s
✓ Built build/app/outputs/flutter-apk/app-release.apk (18.8MB)
$

android docs also very clear about it - only openjdk-17 is supported

@fkorotkov can you verify this and downgrade java versions for next releases?

@jtothebell
Copy link

I'm running in to the same issue. It looks like the Android 34 image on which this is based was updated to use openjdk-21 here: cirruslabs/docker-images-android@90d9542

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

No branches or pull requests

5 participants