Cause of occurrence
The problem arises because we use the SO library in the project, or the third-party SDK referenced in the project uses the SO library. You need to use different.so files for different CPU architectures when referencing the SO library. Armeabi, Armeabi-V7A, x86, ARM64-V8A, these are the CPU architectures that people usually adapt to. However, the problem with Flutter is that it does not incorporate arm32 and arm64’s libflutter. I couldn’t find libflutter. So when I installed a packed Apk onto a phone with arm64 architecture (the default packaging introduces ARM32).
How to solve
-
Pack arm32 and arm64 separately (Flutter provides commands to pack arm32 and arm64 separately)
-
flutter build apk --target-platform=android-arm32
-
flutter build apk --target-platform=android-arm64
We used the Flutter build apk –target-platform= Android-arm64 to package the APK and install it on an ARM64CPU mobile phone. It worked perfectly. However, the problem recurred when we installed APK to 32 bits, and the reasons were not repeated. Obviously this approach does not solve the problem at this point, we need to package arm32 and ARM64 separately, and most domestic application markets cannot upload different APKS for different CPU architectures.
-
-
Do not adapt arm64, package to exclude other non-ARM32 so files
There are “compatibility” issues with arm64 phones because the arm64 libflutter so file was not included in the package. Here simply say a little bit about the reference so library some knowledge, understand the friends we can directly skip. The arm64 CPU architecture can be compatible with the following, simple is that the ARM64 CPU architecture can use the arm32. So file. The real cause of the problem is that we are compatible with ARM64 when we reference the SO library (the reference tripartite library references so library). This could cause the runtime system to mistakenly believe that our application is arm64 compliant for all so libraries, but libflutter does not include an ARM64 version when packaged. This causes the system to look for the ARM64 version of libflutter and find none. The system has misunderstood us and we can only resolve this misunderstanding by excluding other so files that are not arm32 architecture when gradle is packaging.
Ok how to exclude other SO files that are not arm32 architecture. Add the following code to the gradle file in app
BuildTypes {release {NDK {armeabi-v7a; Armeabi abiFilters armeabi debug {NDK {// The debug package will fail. X86 recommended to add otherwise partial emulator return error abiFilters "armeabi", "armeabi-v7A "," arm64-v8A "," x86"}}Copy the code
The last
This problem has existed in official issues for a long time and there is no perfect solution for the time being. If there is a new solution, I will update it as soon as possible. In the future, I will continue to update some problems encountered in the development of Flutter, as well as some good articles (including raw meat, I will try to stir-fry it due to my limited English ability). I hope I can help you avoid some detours. I hope you can correct me and help me make progress. Thank you in advance. thank you