Since Flutter was not designed to support the CPU of The Armeabi architecture, it is necessary to intervene in the compilation process of Flutter to adapt to Armeabi if native engineering cannot be modified. Different versions of Flutter adaptation are also different
FlutterSdk 1.9.6 old version in the so in the SDK bin/cache/artifacts in the engine
Option 1: github.com/lizhangqu/p…
Plan 2: Meituan plan
for arch in android-arm android-arm-profile android-arm-release ; Unzip flutter. Jar lib/armeabi-v7a/libflutter. So mv lib/armeabi-v7a lib/armeabi zip -d flutter.jar lib/armeabi-v7a/libflutter.so zip flutter.jar lib/armeabi/libflutter.so popd doneCopy the code
FlutterSdk 2.0.3 version for remote dependent mirrors.sjtug.sjtu.edu.cn/download.fl… Plan 1 and Plan 2 above are no longer applicable
The new scheme modified the packaging process and completed the copy logic of SO in the packaging process, thus reducing the inapplicability of scripts caused by major modifications of FlutterSdk
Create the flutter_arm. Gradle file
project.setProperty('target-platform', 'android-arm') project.afterEvaluate { android.applicationVariants.all { variant -> def variantName = variant.name.capitalize() def multidexTask = project.tasks.findByName("transformNativeLibsWithMergeJniLibsFor${variantName}") if (multidexTask ! = null) { def copyFlutterSoTask = createcopyFlutterSoTask(variant) multidexTask.finalizedBy copyFlutterSoTask } } } def copyFile(String src, String dest) { println "libflutter src: " + src + " dest: " + dest def srcFile = new File(src) def targetFile = new File(dest) targetFile.withOutputStream { os -> srcFile.withInputStream { ins -> os << ins } } } def createcopyFlutterSoTask(variant) { def variantName = variant.name.capitalize() return task("replace${variantName}FlutterArm").doLast { def root = rootDir.getParentFile().getAbsolutePath() + File.separator + "build" + File.separator + "app" + File.separator + "intermediates" + File.separator + "transforms" + File.separator + "mergeJniLibs" + File.separator + variantName + File.separator + "0" + File.separator + "lib"; String fromFilePath = root + File.separator + "armeabi-v7a" + File.separator + "libflutter.so" String foFilePath = root + File.separator + "armeabi" + File.separator + "libflutter.so" copyFile(fromFilePath, foFilePath) File foFile = new File(foFilePath) if (! foFile.exists() || foFile.length() < 100) { throw new GradleException("copyFlutter libflutter.so error please check") } }}Copy the code
Libflutter. So of Armeabi-v7a was copied into Armeabi after MergeJniLibs
Apply from: "flutter_arm.gradle" // Must be placed before the reference of flutter. Gradle otherwise the target-platform value cannot be read apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"Copy the code