简体   繁体   English

强制构建仅适用于 ARMv7 的 flutter 应用程序

[英]force build a flutter application for ARMv7 only

My project is a flutter application as frontend of an Android Service that I import as an AAR.我的项目是一个 Flutter 应用程序,作为我作为 AAR 导入的 Android 服务的前端。

That Android Service is mostly C++ and only packs ARMV7 libraries.该 Android 服务主要是 C++ 并且只包含 ARMV7 库。 No ARM64.没有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).如果我在Android studio中运行项目,上传的调试APK只包含Flutter ARM64库,但没有ARM库(来自服务),因此服务无法启动(Flutter部分工作正常)。

  • 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.如果我通过终端使用flutter build apk --debug --target-platform=android-arm运行项目,则生成的 APK 将包含 flutter ARM 库和其余的服务 ARM 库。 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.所以我的问题是,如何将参数--target-platform=android-arm附加到从 Android Studio 触发的 flutter 构建中,这样我就不需要手动创建和上传 APK。

I have tried Add abiFilters to gradle properties but it doesn't seem related.我已经尝试将 abiFilters 添加到 gradle 属性,但它似乎没有关系。

The project property target-platform can be defined on the main build.gradle , to add a property to the subprojects.项目属性target-platform可以在主build.gradle上定义,以向子项目添加属性。 This variable is parsed by flutter.gradle to pack the desired architecture.该变量由flutter.gradle解析以打包所需的架构。 A comma-separated list of platforms can be provided as well.也可以提供以逗号分隔的平台列表。

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

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简而言之 - 修改 $flutterRoot/packages/flutter_tools/gradle/flutter.gradle(从 getBasePlatform 方法返回 PLATFORM_ARM32)并将 ndk.abiFilters 添加到 defaultConfig

Issue on github.发布在GitHub上。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM