我正在从异步函数执行HTTP Get,并且不断收到此UnsatisfiedLinkError:

Caused by: java.lang.UnsatisfiedLinkError: com.android.tools.fd.runtime.IncrementalClassLoader$DelegateClassLoader[DexPathList[[
dex file "/data/data/com.myapp.myapp/files/instant-run/dex/slice-universal-image-loader-1.9.5_5a96e3a3bb879858d826e5f3576c34ad5d6c1936-classes.dex",
dex file "/data/data/com.myapp.myapp/files/instant-run/dex/slice-support-annotations-23.3.0_55d9fdcf7c91c0058d2cbcc7e08fd782b38fe66d-classes.dex",
dex file "/data/data/com.myapp.myapp/files/instant-run/dex/slice-socialauth-android-3.2_9611dca6f615df1d34c2b5a60ba28a7611388175-classes.dex",
dex file "/data/data/com.myapp.myapp/files/instant-run/dex/slice-socialauth-4.4_1b9c6d31199994c03c332e5e0578e2f0b2fe0c48-classes.dex",
dex file "/data/data/com.myapp.myapp/files/instant-run/dex/slice-slice_9-classes.dex",
dex file "/data/data/com.myapp.myapp/files/instant-run/dex/slice-slice_8-classes.dex",
dex file "/data/data/com.myapp.myapp/files/instant-run/dex/slice-slice_7-classes.dex",
dex file "/data/data/com.myapp.myapp/files/instant-run/dex/slice-slice_6-classes.dex",
dex file "/data/data/com.myapp.myapp/files/instant-run/dex/slice-slice_5-classes.dex",
dex file "/data/data/com.myapp.myapp/files/instant-run/dex/slice-slice_4-classes.dex",
dex file "/data/data/com.myapp.myapp/files/instant-run/dex/slice-slice_3-classes.dex",
dex file "/data/data/com.myapp.myapp/files/instant-run/dex/slice-slice_2-classes.dex",
dex file "/data/data/com.myapp.myapp/files/instant-run/dex/slice-slice_1-classes.dex",
dex file "/data/data/com.myapp.myapp/files/instant-run/dex/slice-slice_0-classes.dex",
dex file "/data/data/com.myapp.myapp/files/instant-run/dex/slice-simple-xml-2.7.1_f2a506737e8b5ed93d4b881fc0c6c7a35026d813-classes.dex",
dex file "/data/data/com.myapp.myapp/files/instant-run/dex/slice-library-2.4.0_16c20551d1515298e4f820dbb2437cde217a49b7-classes.dex",
dex file "/data/data/com.myapp.myapp/files/instant-run/dex/slice-ksoap2-android-assembly-3.6.1-jar-with-dependencies_a1a9b67170b6d055b09be56a35ddecd8b9faafce-classes.dex",
dex file "/data/data/com.myapp.myapp/files/instant-run/dex/slice-internal_impl-23.3.0_e42bbcf06b9ce4060096cb8ce36b6ab3c865197c-classes.dex",
dex file "/data/data/com.myapp.myapp/files/instant-run/dex/slice-httpclient-4.3.6_e4c2a7ccc6f36fc0c0b6db3cd84168431f19da97-classes.dex",
dex file "/data/data/com.myapp.myapp/files/instant-run/dex/slice-guava-19.0_789e0cb8a020dcf43fb5056f93875e715c03d36c-classes.dex",
dex file "/data/data/com.myapp.myapp/files/instant-run/dex/slice-gcm_4bcd93ef73ae7672956b56c7a5314a899b41e0a9-classes.dex",
dex file "/data/data/com.myapp.myapp/files/instant-run/dex/slice-de.mrmaffen-vlc-android-sdk-1.9.8_183f7022a4ff9bc2fcad3ecf80fe616b030d8981-classes.dex", dex file "/data/data/com.myapp.myapp/files/instant-run/dex/slice-com.github.ganfra-material-spinner-1.1.1_3c6f77a530740d43591c90873c9d9105e0afdcd9-classes.dex",
dex file "/data/data/com.myapp.myapp/files/instant-run/dex/slice-com.android.support-support-vector-drawable-23.3.0_a59a3afa176f79a2a84e41a6156deee0023dc2e8-classes.dex",
dex file "/data/data/com.myapp.myapp/files/instant-run/dex/slice-com.android.support-support-v4-23.3.0_95f566be28123c8c85ef97806b7b803eab311dd5-classes.dex", dex file "/data/data/com.myapp.myapp/f


我正在执行的代码如下(在doInBackground内部):-

 String url1 = "http://172.23.3.54:8054/Streaming/channels/102/preview";

 httpclient = new DefaultHttpClient();
 httpParams = httpclient.getParams();
 httpget = new HttpGet(URI.create(url1));
 HttpConnectionParams.setConnectionTimeout(httpParams, 5 * 1000);
 HttpConnectionParams.setSoTimeout(httpParams, 5 * 1000);
 Log.i(TAG, "1. Sending http request");

 credentials = new UsernamePasswordCredentials("admin", "12345");
 httpclient.getCredentialsProvider().setCredentials(AuthScope.ANY, credentials);


 try {
  res = httpclient.execute(httpget);
  Log.i(TAG, "2. Request finished, status = " + res.getStatusLine().getStatusCode() + ", " + res.getStatusLine().getReasonPhrase());

  try {
   InputStream is = res.getEntity().getContent(); //error occurs here
  } catch (IOException e) {
   e.printStackTrace();
  }

 } catch (IOException e) {
  e.printStackTrace();
 }


我似乎找不到有关UnsatisfiedLinkError的很多信息。我试过重建项目,但无济于事。如果有人能告诉我造成这种情况的可能原因,将非常感谢,因为堆栈跟踪没有提供很多有用的信息。



更新资料

该错误仅发生在我的实际设备(LG G4)上,而不发生在Nexus 4 AVD上。看起来像这样。

java - java.lang.UnsatisfiedLinkError:在HTTP Get on Android-LMLPHP

最佳答案

好的,我终于设法解决了这个问题。首先,我禁用了在Android Studio上的即时运行。这以某种方式改变了产生的错误消息:

Caused by: java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.myapp.myapp-1/base.apk"],nativeLibraryDirectories=[/data/app/com.myapp.myapp-1/lib/arm64, /data/app/com.myapp.myapp-1/base.apk!/lib/arm64-v8a, /vendor/lib64, /system/lib64]]] couldn't find "libImageProc.so"


因此,事实证明缺少本机库。

最后,我通过在gradle构建中应用过滤器解决了该问题。

defaultConfig {
...
    ndk {
        moduleName "ImageProc"
        abiFilters "armeabi", "armeabi-v7a", "x86", "mips"
    }
}


这只是指定要打包的32位体系结构。

关于java - java.lang.UnsatisfiedLinkError:在HTTP Get on Android,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/39032823/

10-10 09:42