将 minSdkVersion 从 21 更改为 24 后,我收到异常:
java.lang.UnsatisfiedLinkError: dalvik.system.DexClassLoader[DexPathList[[dex file "/data/user/0/com.test.testprint/files/nepcore.dex"],nativeLibraryDirectories=[/data/app/com.test.testprint-2/lib/arm, /data/resource/lib, /vendor/lib, /system/lib]]] couldn't find "libDeviceConfig.so"
切换回 minSdk 21 后,一切恢复正常。
我也尝试添加 ndk 过滤器,但没有帮助:(
任何人都可以帮助理解这个异常是如何与 minSdkVersion 联系起来的吗?
需要在清单文件中的应用程序部分添加一行:)
<application
...
android:extractNativeLibs="true">
对于 minSdk >= 23 和 Android Gradle Plugin >= 4.2.0,需要在应用程序的 build.gradle 文件中使用 useLegacyPackaging 而不是 Androidmanifest.xml 中的 extractNativeLibs
DSL 打包压缩原生库的示例用法(可以在这里找到)
android {
packagingOptions {
jniLibs {
useLegacyPackaging true
}
}
}
你好,我仍然有这个问题。
android { packagingOptions { exclude ('/lib/armeabi/*' + '*') exclude ('/lib/mips/*' + '*') exclude ('/lib/mips64/*' + '*') exclude ('/lib/x86/*' + '*') exclude ('/lib/x86_64/*' + '*') jniLibs { useLegacyPackaging = true } } }
我还有
> Configure project :launcher WARNING:The option setting 'android.bundle.enableUncompressedNativeLibs=false' is deprecated. The current default is 'true'. It will be removed in version 8.0 of the Android Gradle plugin. You can add the following to your build.gradle instead: android { packagingOptions { jniLibs { useLegacyPackaging = true } } } IncrementalTaskInputs has been deprecated. This is scheduled to be removed in Gradle 8.0. On method 'IncrementalTask.taskAction$gradle_core' use 'org.gradle.work.InputChanges' instead. Consult the upgrading guide for further information: https://docs.gradle.org/7.6.3/userguide/upgrading_version_7.html#incremental_task_inputs_deprecation