Open thgoebel opened 1 month ago
I can reproduce the issue on the latest Flutter channels.
➜ flutter-apk unzip -l app-debug.apk
Archive: app-debug.apk
Length Date Time Name
--------- ---------- ----- ----
...
13203632 01-01-1981 01:01 lib/arm64-v8a/libVkLayer_khronos_validation.so
39755544 01-01-1981 01:01 lib/arm64-v8a/libflutter.so
40100568 01-01-1981 01:01 lib/x86/libflutter.so
40800744 01-01-1981 01:01 lib/x86_64/libflutter.so
...
➜ flutter-apk unzip -l app-release.apk
Archive: app-release.apk
Length Date Time Name
--------- ---------- ----- ----
...
2950048 01-01-1981 01:01 lib/arm64-v8a/libapp.so
10811088 01-01-1981 01:01 lib/arm64-v8a/libflutter.so
...
@thgoebel is this a regression from a previous version of the flutter tool?
I don't know if it is a regression. I just started working on this Flutter app now. I was coming from the Rust sharedlib side, wanting to help our Flutter app team integrate it. So I downloaded Flutter just now. I don't now if this was working in the past or not. And none of my team mates wanted to use this up to now, because only with Rust's long build times it started to matter.
Anyway, I checked out 3.0.1, and the same behaviour (target platform is ignored) is present there as well. So it is not a recent regression, if it is one at all.
This seems like a reasonable request both the feature to make --debug work with --target-platform and if not then to update the documentation to make that clear.
This seems reasonable and is something i'd be willing to review a PR for.
For future readers gradle.dart needs to be modified to look at target architectures when building in debug mode.
@thgoebel as a work around try setting --split-per-abi
in addition to your target flag.
Based on reading this code you might get what you are looking for.
@thgoebel confirmed with a sample app that you can use flutter build apk --target-platform=android-arm64 --debug --split-per-abi
and you will only get the arm so files.
Good find! I can confirm that with --split-per-abi
the resulting APK only contains arm64 code.
However, it still compiles for (arm64, i686/x86_32, x86_64)
. So for my use case (quicker builds because Rust is slow), this doesn't quite solve it since it still compiles for three target platforms. However, I am not sure if this is due to Flutter's code or due to Rinf's code. So I filed an issue with rinf as well: https://github.com/cunarist/rinf/issues/413
It is more likely an issue with flutter code. I linked the file but this is not likely to get more of my attention anytime soon.
Pull requests are welcome however.
Steps to reproduce
flutter create testproject
cd testproject
flutter build apk --target-platform=android-arm64 --debug
Expected results
The resulting
app-debug.apk
only contains code for android-arm64.Actual results
The resulting
app-debug.apk
contains code for android-arm, android-arm64, android-x86, android-x64.When running without
--debug
, i.e.flutter build apk --target-platform=android-arm64
then the resultingapp-release.apk
correctly contains only code for android-arm64.Why this is relevant
I am using https://github.com/cunarist/rinf. Sometimes you have to do a
flutter clean
. And (re)compiling Rust code for 4 target archs takes a loooong time. But I only need and only want to compile for one arch. I expect--target-platform
to work with--debug
.Alternatively (but not ideal), the output of
flutter build apk --help
should indicate that these two options are incompatible.Code sample
No need for a code sample. Just run
flutter create testproject
and use that.Screenshots or Video
n/a
Logs
n/a
Flutter Doctor output
Doctor output
```console Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel stable, 3.24.0, on macOS 14.5 23F79 darwin-arm64, locale en-CH) [✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0) [✓] Xcode - develop for iOS and macOS (Xcode 15.4) [✗] Chrome - develop for the web (Cannot find Chrome executable at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome) ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable. [✓] Android Studio (version 2024.1) [✓] VS Code (version 1.92.0) [✓] Connected device (3 available) [✓] Network resources ! Doctor found issues in 1 category ```