Jaw*_*een 6 android android-ndk flutter
我在 Google Play 商店上有一个正在生产的 Flutter 应用程序,其中包括一个使用 NDK 构建并在运行时加载的本机动态库(我称之为libraster.so)。在大多数设备上,该库都存在并且加载良好。ArgumentError但在某些设备上,运行时会发生以下情况Invalid argument(s): Failed to load dynamic library (dlopen failed: library "libraster.so" not found)。
我认为有问题的设备是 ARM 设备。该应用程序未abiFilter在应用程序模块的build.gradle文件中指定任何内容。
使用 Google Play Console 的 App Bundle Explorer,我可以下载将分发到受影响设备的 APK,并且它们libraster.so正常包含。
根据我的错误日志,到目前为止受影响的设备有:
| 模型 | 姓名 | 安卓版本 |
|---|---|---|
| SM-G928F | 三星 Galaxy S6 Edge+ | 6.0.1 |
| SM-J500M | 三星 Galaxy J5 | 6.0.1 |
| SM-J710GN | 三星 Galaxy J7 2016 | 6.0.1 |
| SM-T110 | 三星 Galaxy Tab 3 Lite 7.0 | 4.2.2 |
| SM-T111M | 三星 Galaxy Tab 3 Lite 7.0 | 4.2.2 |
| GT-I8262 | 三星 Galaxy Core 双核 | 4.1.2 |
| GT-I8552 | 三星 Galaxy Win Duo | 4.1.2 |
| GT-I8552B | 三星 Galaxy Win Duo | 4.1.2 |
| GT-I9082L | 三星 Galaxy Grand Duo | 4.2.2 |
| GT-I9300 | 三星 Galaxy S III | 4.1.2 |
| GT-N8000 | 三星 Galaxy Note 10.1 | 4.1.2 |
| GT-N8010 | 三星 Galaxy Note 10.1 | 4.1.2 |
| GT-P3110 | 三星 Galaxy Tab 2 7.0 | 4.1.2 |
| GT-P5110 | 三星 Galaxy Tab 2 10.1 | 4.2.2 |
| SO-03E | 索尼 Xperia 平板电脑 Z | 4.1.2 |
| B1-A71 | 宏碁 Iconia Tab B1-A71 | 4.1.2 |
| F-01F | 富士通 Arrows NX F-01F | 4.2.2 |
| ME173X | 华硕记事本HD7 | 4.2.2 |
主要是 Android 4.1.2、4.2.2 和 6.0.1 设备。
这是我的应用程序模块的简化版本build.gradle:
apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion 29
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
applicationId "com.example.package"
minSdkVersion 16
targetSdkVersion 29
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
externalNativeBuild {
cmake {
arguments "-DCOMPILE_TESTS:BOOL=OFF"
}
}
// Maintains debug symbols
packagingOptions {
doNotStrip '**.so'
}
}
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile file(keystoreProperties['storeFile'])
storePassword keystoreProperties['storePassword']
}
}
buildTypes {
release {
signingConfig signingConfigs.release
minifyEnabled true
useProguard true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
ndk {
debugSymbolLevel = 'FULL'
}
}
}
externalNativeBuild {
cmake {
version "3.19.2"
path "path/to/CMakeLists.txt"
}
}
}
flutter {
source '../..'
}
dependencies {
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.google.code.gson:gson:2.8.5'
implementation 'androidx.multidex:multidex:2.0.1'
}
apply plugin: 'com.google.gms.google-services'
Run Code Online (Sandbox Code Playgroud)
和proguard-rules.pro:
#Flutter Wrapper
-keep class io.flutter.app.** { *; }
-keep class io.flutter.plugin.** { *; }
-keep class io.flutter.util.** { *; }
-keep class io.flutter.view.** { *; }
-keep class io.flutter.** { *; }
-keep class io.flutter.plugins.** { *; }
-dontwarn io.flutter.embedding.**
-keep class com.example.package.** { *; }
Run Code Online (Sandbox Code Playgroud)
使用的Flutter版本稳定1.22.5。
这是 Flutter 中的一个错误吗?这些设备加载动态库的方式与其他设备不同吗?libraster.so只是在某些情况下实际上没有与 APK 一起打包吗?
这里报告了类似的问题:https ://github.com/simolus3/moor/issues/895
对于这种情况,建议的修复是创建一个调用 System.loadLibrary() 的 Flutter 插件
| 归档时间: |
|
| 查看次数: |
14656 次 |
| 最近记录: |