java.lang.UnsatisfiedLinkError 解决方法

原项目是拿eclipse写的,要移植到AS上,项目包含so包的

如果错误日志是这样的
Java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader
[DexPathList[[zip file “/data/app/***/***.apk”],
nativeLibraryDirectories=[/data/app/***/lib/arm64, /vendor/lib64, /system/lib64]]] couldn’t find “lib***.so”

只要在app的build.gradle中添加如下代码

1
2
3
4
5
6
7
8
9
10
11
12
13
android {
    defaultConfig {
        multiDexEnabled true
        ndk {
            abiFilters "armeabi", "armeabi-v7a", "x86", "mips"
        }
    }
    sourceSets {
        main {
            jniLibs.srcDirs = ['libs']
        }
    }
}

如果日志是这样的
java.lang.UnsatisfiedLinkError: com.android.tools.fd.runtime.IncrementalClassLoader$DelegateClassLoader[DexPathList[[dex file “/data/data/com.xiaoyigou.xiaoyigou/files/instant-run/dex/slice-support-annotations-23.3.0_16262edeb4287d69eb7544500542e84bdbeff311-classes.dex”, dex file “/data/data/com.xiaoyigou.xiaoyigou/files/instant-run/dex/slice-slice_9-classes.dex”, dex file “/data/data/com.xiaoyigou.xiaoyigou/files/instant-run/dex/slice-slice_8-classes.dex”, dex file “/data/data/com.xiaoyigou.xiaoyigou/files/instant-run/dex/slice-slice_7-classes.dex”, dex file “/data/data/com.xiaoyigou.xiaoyigou/files/instant-run/dex/slice-slice_6-classes.dex”, dex file “/data/data/com.xiaoyigou.xiaoyigou/files/instant-run/dex/slice-slice_5-classes.dex”, dex file “/data/data/com.xiaoyigou.xiaoyigou/files/instant-run/dex/slice-slice_4-classes.dex”, dex file “/data/data/com.xiaoyigou.xiaoyigou/files/instant-run/dex/slice-slice_3-classes.dex”, dex file “/data/data/com.xiaoyigou.xiaoyigou/files/instant-run/dex/slice-slice_2-classes.dex”, dex file “/data/data/com.xiaoyigou.xiaoyigou/files/instant-run/dex/slice-slice_1-classes.dex”, dex file “/data/data/com.xiaoyigou.xiaoyigou/files/instant-run/dex/slice-slice_0-classes.dex”, dex file “/data/data/com.xiaoyigou.xiaoyigou/files/instant-run/dex/slice-library-2.4.0_7ffe8bd5b577e992eb7dff97483e1ae44e7853b5-classes.dex”, dex file “/data/data/com.xiaoyigou.xiaoyigou/files/instant-run/dex/slice-internal_impl-23.3.0_4c5a8e3a1f7b561e3a4f7df410b8d7747221c2ce-classes.dex”, dex file “/data/data/com.xiaoyigou.xiaoyigou/files/instant-run/dex/slice-httpclient-4.3.6_55936b5e45dd79b63dfcb7a1872cb42a0209ce63-classes.dex”, dex file “/data/data/com.xiaoyigou.xiaoyigou/files/instant-run/dex/slice-gson-2.6.2_11d97d98b61bdecb6c6185f802696ddd5b7aba67-classes.dex”, dex file “/data/data/com.xiaoyigou.xiaoyigou/files/instant-run/dex/slice-com.facebook.fresco-imagepipeline-base-0.10.0_edcabdf703447be1662978983f5f99305a2a8221-classes.dex”, dex file “/data/data/com.xiaoyigou.xiaoyigou/files/instant-run/dex/slice-com.facebook.fresco-imagepipeline-0.10.0_4fdddbca37100cb90c02f9164186e624577a1457-classes.dex”, dex file “/data/data/com.xiaoyigou.xiaoyigou/files/instant-run/dex/slice-com.facebook.fresco-fresco-0.10.0_fccc5665bd2599cff62b6c9c43fcec2ee9a6758b-classes.dex”, dex file “/data/data/com.xiaoyigou.xiaoyigou/files/instant-run/dex/slice-com.facebook.fresco-fbcore-0.10.0_bc604b6142c958cd8f2d61b2266a937db7be15d6-classes.dex”, dex file “/data/data/com.xiaoyigou.xiaoyigou/files/instant-run/dex/slice-com.facebook.fresco-drawee-0.10.0_f6a3a597d6b61a21cc8f7d59a28ab210e5a2be93-classes.dex”, dex file “/data/data/com.xiaoyigou.xiaoyigou/files/instant-run/dex/slice-com.android.support-support-vector-drawable-23.3.0_20814f4243e34fa155810145805f1dd4dff5ae74-classes.dex”, dex file “/data/data/com.xiaoyigou.xiaoyigou/files/instant-run/dex/slice-com.android.support-support-v4-23.3.0_7407e7b4aaaceb9ca0b0a0e60dc4d261288e0d3f-classes.dex”, dex file “/data/data/com.xiaoyigou.xiaoyigou/files/instant-run/dex/slice-com.android.support-recyclerview-v7-23.1.1_13be9b96c7e2c85b0d20a2ab49a6eb0148b65550-classes.dex”, dex file “/data/data/com.xiaoyigou.xiaoyigou/files/instant-run/dex/slice-com.android.support-design-23.1.1_a326e03c88de8252c6551bfc2eb6819dcc35e918-classes.dex”, dex file “/data/data/com.xiaoyigou.xiaoyigou/files/instant-run/dex/slice-com.android.support-appcompat-v7-23.3.0_a5dd40e12e41c8dceb0bd1e0b224c181cc251967-classes.dex”, dex file “/data/data/com.xiaoyigou.xiaoyigou/files/instant-run/dex/slice-com.android.support-animated-vector-drawable-23.3.0_2568e5dce9b2c1cdf0c424c5bcc23fef7490dacb-classes.dex”, dex file “/data/data/com.xiaoyigou.xiaoyigou/files/instant-run/dex/slice-bolts-android-1.1.4_50b9af6b6d02661c770682752771cc3318dbd9ad-classes.dex”, dex file “/data/data/com.xiaoyigou.xiaoyigou/files/instant-run/dex/slice-android-async-http-1.4.9_d2f0f75b2997a9409165e183f4d2f5265f12c670-classes.dex”],nativeLibraryDirectories=[/data/app/com

主要原因是android studio的instant run导致的,更改下设置

发表评论?

0 条评论。

发表评论


注意 - 你可以用以下 HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>