force build a flutter application for ARMv7 only

1,239

Solution 1

The project property target-platform can be defined on the main build.gradle, to add a property to the subprojects. This variable is parsed by flutter.gradle to pack the desired architecture. A comma-separated list of platforms can be provided as well.

subprojects {
    project.setProperty("target-platform", "android-arm")
}

Solution 2

You can try this workaround

In short - modify $flutterRoot/packages/flutter_tools/gradle/flutter.gradle (return PLATFORM_ARM32 from getBasePlatform method) and add ndk.abiFilters to defaultConfig

Issue on github.

Share:
1,239
rupps
Author by

rupps

Programming everyday since I was a kid and got my first computer back in 1983, where I enjoyed fantastic games like Xenon 1 for a while. But as this was a niche computer, software was nearly non-existant. And my journey started there ... from BASIC and 6502 Assembler in the funny 80´s, to today´s distributed cloud computing, I have been around digging as deep as possible. During the journey I studied Telecommunications Engineering, worked in Telefonica R&D, Lucent Technologies and Alcatel, mostly in the IPTV field, always taking charge of hardcore programming tasks, and finally created my independent "garage company" Nebular Streams, where research does not stop. LD HL, #C000 LD DE, #C001 LD BC, #3FFF LDIR RET

Updated on December 15, 2022

Comments

  • rupps
    rupps over 1 year

    My project is a flutter application as frontend of an Android Service that I import as an AAR.

    That Android Service is mostly C++ and only packs ARMV7 libraries. No ARM64.

    • If I run the project in Android studio, the debug APK uploaded only contains Flutter ARM64 library, but no ARM libraries (from the service), so the service fails to start (the Flutter part works OK).

    • If I run the project via terminal with flutter build apk --debug --target-platform=android-arm, the resulting APK contains flutter ARM library with the rest of the service ARM libraries. it works.

    So my question is, how can I append parameter --target-platform=android-arm to the flutter build triggered from Android Studio, so I don't need to manually create and upload the APK.

    I have tried Add abiFilters to gradle properties but it doesn't seem related.

  • rupps
    rupps over 4 years
    ey, thanks for answering. I was indeed going your route when I discovered in the flutter.gradle source code that it checks for a project variable to override platform value. Seems a workaround for the issue without the need of editing flutter.gradle! See my own answer. (btw- flutter.gradle is re-downloaded from github by the flutter toolchain quite frequently, so editions do not survive very long)