Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Getting error while creating a release APK #44

Closed
rajat-ventura opened this issue Dec 10, 2024 · 13 comments
Closed

Getting error while creating a release APK #44

rajat-ventura opened this issue Dec 10, 2024 · 13 comments
Labels
bug Something isn't working wontfix This will not be worked on

Comments

@rajat-ventura
Copy link

rajat-ventura commented Dec 10, 2024

version: 0.9.6

command run: flutter build apk --release

Error Faced :-

Compiling bin/build_tool_runner.dart to kernel file bin/build_tool_runner.dill.
INFO: Precompiled binaries are disabled
INFO: Building rhttp for armv7-linux-androideabi
SEVERE: ================================================================================
SEVERE: Cargokit BuildTool failed with error:
SEVERE: --------------------------------------------------------------------------------
SEVERE: External Command: rustup "run" "stable" "cargo" "build" "--manifest-path" "/Users/rajatkr/.pub-cache/hosted/pub.dev/rhttp-0.9.6/rust/Cargo.toml" "-p" "rhttp" "--release" "--target" "armv7-linux-androideabi" "--target-dir" "/Users/rajatkr/StudioProjects/project-X/build/rhttp/build"
SEVERE: Returned Exit Code: 101
SEVERE: --------------------------------------------------------------------------------
SEVERE: STDOUT:
SEVERE: --------------------------------------------------------------------------------
SEVERE: STDERR:
SEVERE: Compiling rhttp v0.1.0 (/Users/rajatkr/.pub-cache/hosted/pub.dev/rhttp-0.9.6/rust)
SEVERE: error: linking with /Users/rajatkr/.pub-cache/hosted/pub.dev/rhttp-0.9.6/cargokit/run_build_tool.sh failed: exit status: 1
SEVERE: |
SEVERE: = note: LC_ALL="C" PATH="/Users/rajatkr/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/bin:/Applications/Android Studio.app/Contents/jbr/Contents/Home/bin:/opt/homebrew/opt/llvm/bin:/opt/homebrew/opt/postgresql@16/bin:/opt/homebrew/opt/libpq/bin:/opt/homebrew/opt/ruby/bin:/Users/rajatkr/.shorebird/bin:/opt/homebrew/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Library/Apple/usr/bin:/usr/local/go/bin:/Users/rajatkr/.cargo/bin:/Users/rajatkr/flutter_3.19.6/flutter/bin:/opt/homebrew/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Library/Apple/usr/bin:/usr/local/go/bin:/Users/rajatkr/.cargo/bin:/Users/rajatkr/flutter_3.19.6/flutter/bin/cache/dart-sdk/bin:/opt/homebrew/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Library/Apple/usr/bin:/usr/local/go/bin:/Users/rajatkr/.cargo/bin:/Users/rajatkr/flutter_3.19.6/flutter/bin:/opt/homebrew/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Library/Apple/usr/bin:/usr/local/go/bin:/Users/rajatkr/.cargo/bin:/Users/rajatkr/.pub-cache/bin:/opt/homebrew/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Library/Apple/usr/bin:/usr/local/go/bin:/Users/rajatkr/.cargo/bin:/Users/rajatkr/flutter_3.19.6/flutter/bin:/opt/homebrew/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Library/Apple/usr/bin:/usr/local/go/bin:/Users/rajatkr/.cargo/bin:/Users/rajatkr/flutter_3.19.6/flutter/bin/cache/dart-sdk/bin:/opt/homebrew/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Library/Apple/usr/bin:/usr/local/go/bin:/Users/rajatkr/.cargo/bin:/Users/rajatkr/flutter_3.19.6/flutter/bin:/opt/homebrew/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Library/Apple/usr/bin:/usr/local/go/bin:/Users/rajatkr/.cargo/bin" VSLANG="1033" "/Users/rajatkr/.pub-cache/hosted/pub.dev/rhttp-0.9.6/cargokit/run_build_tool.sh" "-Wl,--version-script=/var/folders/p_/h5ncldp53977pc31x8z_mfq80000gn/T/rustcDibPFv/list" "-Wl,--no-undefined-version" "-march=armv7-a" "/var/folders/p_/h5ncldp53977pc31x8z_mfq80000gn/T/rustcDibPFv/symbols.o" "/Users/rajatkr/StudioProjects/project-X/build/rhttp/build/armv7-linux-androideabi/release/deps/rhttp.rhttp.12a36c4b568ced2c-cgu.0.rcgu.o" "-Wl,--as-needed" "-Wl,-Bstatic" "/var/folders/p_/h5ncldp53977pc31x8z_mfq80000gn/T/rustcDibPFv/libring-7c5922a14e7f8df2.rlib" "/var/folders/p_/h5ncldp53977pc31x8z_mfq80000gn/T/rustcDibPFv/libdart_sys_fork-3ac60082871a0e6d.rlib" "/Users/rajatkr/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/armv7-linux-androideabi/lib/libcompiler_builtins-f1565bab862f9fca.rlib" "-Wl,-Bdynamic" "-llog" "-ldl" "-llog" "-lunwind" "-ldl" "-lm" "-lc" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-L" "/Users/rajatkr/StudioProjects/project-X/build/rhttp/build/cargokit/libgcc_workaround/21" "-L" "/Users/rajatkr/StudioProjects/project-X/build/rhttp/build/armv7-linux-androideabi/release/build/dart-sys-fork-3abec6d99a3d083f/out" "-L" "/Users/rajatkr/StudioProjects/project-X/build/rhttp/build/armv7-linux-androideabi/release/build/ring-b4906c0878e05012/out" "-o" "/Users/rajatkr/StudioProjects/project-X/build/rhttp/build/armv7-linux-androideabi/release/deps/librhttp.so" "-Wl,--gc-sections" "-shared" "-Wl,-z,relro,-z,now" "-Wl,-O1" "-Wl,--strip-all" "-nodefaultlibs"
SEVERE: = note: SEVERE: ================================================================================
SEVERE: SEVERE: Cargokit BuildTool failed with error:
SEVERE: SEVERE: --------------------------------------------------------------------------------
SEVERE: SEVERE: External Command: /Users/rajatkr/Library/Android/sdk/ndk/21.1.6352462/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang "--target=armv7-linux-androideabi26" "-Wl,--version-script=/var/folders/p_/h5ncldp53977pc31x8z_mfq80000gn/T/rustcDibPFv/list" "-Wl,--no-undefined-version" "-march=armv7-a" "/var/folders/p_/h5ncldp53977pc31x8z_mfq80000gn/T/rustcDibPFv/symbols.o" "/Users/rajatkr/StudioProjects/project-X/build/rhttp/build/armv7-linux-androideabi/release/deps/rhttp.rhttp.12a36c4b568ced2c-cgu.0.rcgu.o" "-Wl,--as-needed" "-Wl,-Bstatic" "/var/folders/p_/h5ncldp53977pc31x8z_mfq80000gn/T/rustcDibPFv/libring-7c5922a14e7f8df2.rlib" "/var/folders/p_/h5ncldp53977pc31x8z_mfq80000gn/T/rustcDibPFv/libdart_sys_fork-3ac60082871a0e6d.rlib" "/Users/rajatkr/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/armv7-linux-androideabi/lib/libcompiler_builtins-f1565bab862f9fca.rlib" "-Wl,-Bdynamic" "-llog" "-ldl" "-llog" "-lunwind" "-ldl" "-lm" "-lc" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-L" "/Users/rajatkr/StudioProjects/project-X/build/rhttp/build/cargokit/libgcc_workaround/21" "-L" "/Users/rajatkr/StudioProjects/project-X/build/rhttp/build/armv7-linux-androideabi/release/build/dart-sys-fork-3abec6d99a3d083f/out" "-L" "/Users/rajatkr/StudioProjects/project-X/build/rhttp/build/armv7-linux-androideabi/release/build/ring-b4906c0878e05012/out" "-o" "/Users/rajatkr/StudioProjects/project-X/build/rhttp/build/armv7-linux-androideabi/release/deps/librhttp.so" "-Wl,--gc-sections" "-shared" "-Wl,-z,relro,-z,now" "-Wl,-O1" "-Wl,--strip-all" "-nodefaultlibs"
SEVERE: SEVERE: Returned Exit Code: 1
SEVERE: SEVERE: --------------------------------------------------------------------------------
SEVERE: SEVERE: STDOUT:
SEVERE: SEVERE: --------------------------------------------------------------------------------
SEVERE: SEVERE: STDERR:
SEVERE: SEVERE: /Users/rajatkr/Library/Android/sdk/ndk/21.1.6352462/toolchains/llvm/prebuilt/darwin-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: fatal error: out of file descriptors and couldn't close any
SEVERE: SEVERE: clang: error: linker command failed with exit code 1 (use -v to see invocation)
SEVERE: SEVERE: --------------------------------------------------------------------------------
SEVERE: SEVERE: #0 runCommand (package:build_tool/src/util.dart:121:5)
SEVERE: SEVERE: #1 AndroidEnvironment.clangLinkerWrapper (package:build_tool/src/android_environment.dart:36:5)
SEVERE: SEVERE: #2 runMain (package:build_tool/src/build_tool.dart:240:33)
SEVERE: SEVERE: #3 runMain (package:build_tool/build_tool.dart:7:21)
SEVERE: SEVERE: #4 main (file:///Users/rajatkr/StudioProjects/project-X/build/rhttp/build/build_tool/bin/build_tool_runner.dart:3:14)
SEVERE: SEVERE: #5 delayEntrypointInvocation. (dart:isolate-patch/isolate_patch.dart:295:33)
SEVERE: SEVERE: #6 RawReceivePort.handleMessage (dart:isolate-patch/isolate_patch.dart:184:12)
SEVERE: SEVERE: --------------------------------------------------------------------------------
SEVERE: SEVERE: BuildTool arguments: [-Wl,--version-script=/var/folders/p
/h5ncldp53977pc31x8z_mfq80000gn/T/rustcDibPFv/list, -Wl,--no-undefined-version, -march=armv7-a, /var/folders/p
/h5ncldp53977pc31x8z_mfq80000gn/T/rustcDibPFv/symbols.o, /Users/rajatkr/StudioProjects/project-X/build/rhttp/build/armv7-linux-androideabi/release/deps/rhttp.rhttp.12a36c4b568ced2c-cgu.0.rcgu.o, -Wl,--as-needed, -Wl,-Bstatic, /var/folders/p
/h5ncldp53977pc31x8z_mfq80000gn/T/rustcDibPFv/libring-7c5922a14e7f8df2.rlib, /var/folders/p_/h5ncldp53977pc31x8z_mfq80000gn/T/rustcDibPFv/libdart_sys_fork-3ac60082871a0e6d.rlib, /Users/rajatkr/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/armv7-linux-androideabi/lib/libcompiler_builtins-f1565bab862f9fca.rlib, -Wl,-Bdynamic, -llog, -ldl, -llog, -lunwind, -ldl, -lm, -lc, -Wl,--eh-frame-hdr, -Wl,-z,noexecstack, -L, /Users/rajatkr/StudioProjects/project-X/build/rhttp/build/cargokit/libgcc_workaround/21, -L, /Users/rajatkr/StudioProjects/project-X/build/rhttp/build/armv7-linux-androideabi/release/build/dart-sys-fork-3abec6d99a3d083f/out, -L, /Users/rajatkr/StudioProjects/project-X/build/rhttp/build/armv7-linux-androideabi/release/build/ring-b4906c0878e05012/out, -o, /Users/rajatkr/StudioProjects/project-X/build/rhttp/build/armv7-linux-androideabi/release/deps/librhttp.so, -Wl,--gc-sections, -shared, -Wl,-z,relro,-z,now, -Wl,-O1, -Wl,--strip-all, -nodefaultlibs]
SEVERE: SEVERE: ================================================================================
SEVERE: Resolving dependencies...
SEVERE: Downloading packages...
SEVERE: args 2.4.2 (2.6.0 available)
SEVERE: collection 1.18.0 (1.19.1 available)
SEVERE: convert 3.1.1 (3.1.2 available)
SEVERE: crypto 3.0.3 (3.0.6 available)
SEVERE: github 9.17.0 (9.24.0 available)
SEVERE: http 1.1.0 (1.2.2 available)
SEVERE: http_parser 4.0.2 (4.1.1 available)
SEVERE: logging 1.2.0 (1.3.0 available)
SEVERE: path 1.8.0 (1.9.1 available)
SEVERE: petitparser 5.4.0 (6.0.2 available)
SEVERE: toml 0.14.0 (0.16.0 available)
SEVERE: typed_data 1.3.2 (1.4.0 available)
SEVERE: version 3.0.0 (3.0.2 available)
SEVERE: Got dependencies!
SEVERE: 13 packages have newer versions incompatible with dependency constraints.
SEVERE: Try dart pub outdated for more information.
SEVERE: Compiling bin/build_tool_runner.dart to kernel file bin/build_tool_runner.dill.
SEVERE:
SEVERE:
SEVERE: error: could not compile rhttp (lib) due to 1 previous error
SEVERE: --------------------------------------------------------------------------------
SEVERE: #0 runCommand (package:build_tool/src/util.dart:121:5)
SEVERE: #1 RustBuilder.build (package:build_tool/src/builder.dart:144:5)
SEVERE:
SEVERE: #2 ArtifactProvider.getArtifacts (package:build_tool/src/artifacts_provider.dart:71:25)
SEVERE:
SEVERE: #3 BuildGradle.build (package:build_tool/src/build_gradle.dart:35:23)
SEVERE:
SEVERE: #4 BuildGradleCommand.runBuildCommand (package:build_tool/src/build_tool.dart:65:5)
SEVERE:
SEVERE: #5 BuildCommand.run (package:build_tool/src/build_tool.dart:37:5)
SEVERE:
SEVERE: #6 CommandRunner.runCommand (package:args/command_runner.dart:212:13)
SEVERE:
SEVERE: #7 runMain (package:build_tool/src/build_tool.dart:251:5)
SEVERE:
SEVERE: --------------------------------------------------------------------------------
SEVERE: BuildTool arguments: [build-gradle]
SEVERE: ================================================================================

FAILURE: Build failed with an exception.

  • Where:
    Script '/Users/rajatkr/.pub-cache/hosted/pub.dev/rhttp-0.9.6/cargokit/gradle/plugin.gradle' line: 68

  • What went wrong:
    Execution failed for task ':rhttp:cargokitCargoBuildRhttpRelease'.

Process 'command '/Users/rajatkr/.pub-cache/hosted/pub.dev/rhttp-0.9.6/cargokit/gradle/../run_build_tool.sh'' 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.

BUILD FAILED in 39s
*********************************************************
WARNING: This version of flutter_webview_plugin will break your Android build if it or its dependencies aren't compatible with AndroidX.
See https://goo.gl/CP92wY for more information on the problem and how to fix it.
This warning prints for all Android build failures. The real root cause of the error may be unrelated.
*********************************************************
Running Gradle task 'assembleRelease'... 40.0s
Gradle task assembleRelease failed with exit code 1

@rajat-ventura
Copy link
Author

i have tried reinstalling rust and installed cmake as well, but still facing the same error.

@Tienisto Tienisto added the bug Something isn't working label Dec 10, 2024
@Tienisto
Copy link
Owner

Does it work in debug mode?

@rajat-ventura
Copy link
Author

rajat-ventura commented Dec 10, 2024

yes, that's the weird thing
Debug and release build runs happen for me via flutter run --release or flutter run but when I am running flutter build apk --release it throws above error

@Tienisto
Copy link
Owner

Tienisto commented Dec 10, 2024

Can you build a debug apk?
Checkout https://github.com/Tienisto/rhttp/blob/main/rhttp/rust/Cargo.toml
There are more optimizations in release mode. Maybe you can fork rhttp and try out locally what flag caused the error?
It might be strip, lto, or codegen-units

@rajat-ventura
Copy link
Author

oh ok, checking with debug build

@rajat-ventura
Copy link
Author

nope, debug APK is also not getting built

@Tienisto
Copy link
Owner

It seems that the following error line is important:

ld: fatal error: out of file descriptors and couldn't close any

After using Google, I've found the following:
https://stackoverflow.com/questions/68888635/error-in-linking-a-file-during-compilation-of-llvm

So maybe run this:

ulimit -n 65536

@rajat-ventura
Copy link
Author

i did this as well
but the issue was still not fixed

@rajat-ventura
Copy link
Author

SEVERE: Compiling rhttp v0.1.0 (/Users/rajatkr/.pub-cache/hosted/pub.dev/rhttp-0.9.6/rust)

I suspect this is the problem
any idea how to make this go up to 0.9.6?

@Tienisto
Copy link
Owner

It is the version of the Rust part https://github.com/Tienisto/rhttp/blob/main/rhttp/rust/Cargo.toml
It shouldn't matter because I've compiled apps with rhttp myself.

I can only say that ld: fatal error: out of file descriptors and couldn't close any is the relevant error message. Maybe flutter clean helps.

@rajat-ventura
Copy link
Author

i'll try clean in that case

@rajat-ventura
Copy link
Author

didn't work

@rajat-ventura
Copy link
Author

UPDATE: I suspected from the logs that the NDK version might be a problem, so I checked if it can be updated. On updating it from NDK v21 to v28. The APK build happened smoothy for release. Interesting it didn't throw while running app but when building APK.

Thanks for putting up with me @Tienisto

@Tienisto Tienisto added the wontfix This will not be worked on label Dec 10, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants