![](/img/trans.png)
[英]java.lang.UnsatisfiedLinkError…couldn't find “libaacdecoder.so”
[英]JNI DETECTED ERROR IN APPLICATION java.lang.UnsatisfiedLinkError couldn't find "xxxxx.so" in android.tools.build:gradle 3.6.0
我有 a.aar,包括一些 native.so。 Andrid 項目 B 實現 this.aar 如下:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation(name: 'abcd', ext:'aar')
implementation(name: 'somethingelse', ext:'aar')
}
在 Android 項目 B 中,當我使用 android.tools.build:gradle 3.4.0 和 3.5.0 時,一切正常。 但是當我在根 gradle 中更改為 3.6.0 時:
dependencies {
classpath 'com.android.tools.build:gradle:3.6.0' // dont work
classpath 'com.android.tools.build:gradle:3.4.0' // works fine
}
運行時給我這樣的錯誤:
2021-05-24 20:41:55.723 6064-6153/com.xxxx.xxxxx A/xxxx: java_vm_ext.cc:577] JNI DETECTED ERROR IN APPLICATION: JNI GetMethodID called with pending exception java.lang.UnsatisfiedLinkError: dalvik.system.DexClassLoader[DexPathList[[zip file "/data/app/~~tqEwSNB6cPXs4GapbzXZzQ==/com.xxxx.xxxxx-TRHmC-RfgNxXwoU9Ax-Hrw==/base.apk"],nativeLibraryDirectories=[/data/app/~~tqEwSNB6cPXs4GapbzXZzQ==/com.xxxx.xxxxx-TRHmC-RfgNxXwoU9Ax-Hrw==/lib/arm64, /system/lib64, /system_ext/lib64]]] couldn't find "libcamera_lib.so"
java_vm_ext.cc:577] at void java.lang.Runtime.loadLibrary0(java.lang.ClassLoader, java.lang.Class, java.lang.String) (Runtime.java:1083)
java_vm_ext.cc:577] at void java.lang.Runtime.loadLibrary0(java.lang.Class, java.lang.String) (Runtime.java:1008)
java_vm_ext.cc:577] at void java.lang.System.loadLibrary(java.lang.String) (System.java:1664)
高光:
nativeLibraryDirectories=[/data/app/~~tqEwSNB6cPXs4GapbzXZzQ==/com.xxxx.xxxxx-TRHmC-RfgNxXwoU9Ax-Hrw==/lib/arm64, /system/lib64, /system_ext/lib64]]] couldn't find "libcamera_lib.so"
但是當我解壓縮並檢查 aar 甚至是最終的 output apk 時,我確實發現 cmera_lib.so 就在那里。
知道那里發生了什么嗎? 為什么更改 android.tools.build:gradle 會導致.so not found error in run time and the.so is right inside the apk?
3.6.0 中發生的更改是android:extractNativeLibs
默認值已更改:
如果在 AndroidManifest.xml 中未配置 extractNativeLibs,則默認值為“true”。 However, when building your app using Android Gradle plugin 3.6.0 or higher, this property is reset to "false" if it is NOT configured in AndroidManifest.xml and minSdkVersion >= 23. If minSdkVersion < 23 and extractNativeLibs is explicitly set to " false" 在 AndroidManifest.xml 中,您必須將以下內容添加到您應用的 build.gradle 文件中:
packagingOptions { jniLibs { useLegacyPackaging = false } }
問題是某些設備(例如小米)仍然不支持非提取的本機庫。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.