title: java.lang.UnsatisfiedLinkError: Couldn't load cpuinfo from loader dalvik.system.PathClassLoader
body: <p>I am developing an app requiring CPU information. I placed the cpuinfo library in the jni folder. but i got this error:</p>
  
  <blockquote>
    <p>java.lang.UnsatisfiedLinkError: Couldn't load cpuinfo from loader
    dalvik.system.PathClassLoader[dexPath=/data/app/com.iman.marashi.deviceinfo-2.apk,libraryPath=/data/app-lib/com.iman.marashi.deviceinfo-2]:
    findLibrary returned null</p>
  </blockquote>
  
  <p>that error got from this code:</p>
  
  <pre><code>static {
      try {
          System.loadLibrary("cpuinfo");
          isAvailable = true;
      } catch (UnsatisfiedLinkError ule) {
          Log.e("Loading cpuinfo native library", "" + ule);
      }
  </code></pre>
  
  <p><strong>cpuinfo.c</strong> code:</p>
  
  <pre><code> #include &lt;jni.h&gt;
   #include &lt;stdio.h&gt;
   #include &lt;stdlib.h&gt;
   #include &lt;cpu-features.h&gt;
   #include &lt;android/log.h&gt;
  
   #define LOGV(...) __android_log_print(ANDROID_LOG_VERBOSE, "jason", __VA_ARGS__)
   #define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,   "jason", __VA_ARGS__)
   #define LOGI(...) __android_log_print(ANDROID_LOG_INFO,    "jason", __VA_ARGS__)
   #define LOGW(...) __android_log_print(ANDROID_LOG_WARN,    "jason", __VA_ARGS__)
   #define LOGE(...) __android_log_print(ANDROID_LOG_ERROR,   "jason", __VA_ARGS__)
  
   const int cpu_features_list[] = {
       ANDROID_CPU_ARM_FEATURE_ARMv7,
       ANDROID_CPU_ARM_FEATURE_VFPv3,
       ANDROID_CPU_ARM_FEATURE_NEON,
       ANDROID_CPU_ARM_FEATURE_LDREX_STREX,
       ANDROID_CPU_ARM_FEATURE_VFPv2,
       ANDROID_CPU_ARM_FEATURE_VFP_D32,
       ANDROID_CPU_ARM_FEATURE_VFP_FP16,
       ANDROID_CPU_ARM_FEATURE_VFP_FMA,
       ANDROID_CPU_ARM_FEATURE_NEON_FMA,
       ANDROID_CPU_ARM_FEATURE_IDIV_ARM,
       ANDROID_CPU_ARM_FEATURE_IDIV_THUMB2,
       ANDROID_CPU_ARM_FEATURE_iWMMXt,
       ANDROID_CPU_X86_FEATURE_SSSE3,
       ANDROID_CPU_X86_FEATURE_POPCNT,
       ANDROID_CPU_X86_FEATURE_MOVBE
   };
  
   const char cpu_features_string_list[][20] = {
       "armv7",
       "vfpv3",
       "neon",
       "ldrex_strex",
       "vfpv2",
       "vfp_d32",
       "vfp_fp16",
       "vfp_fma",
       "neon_fma",
       "idiv_arm",
       "idiv_thumb2",
       "iwmmxt",
       "ssse3",
       "popcnt",
       "movbe"
   };
  
   void appendString(char *strDestination, char *strSource) {
       strcat(strDestination, " ");
       strcat(strDestination, strSource);
   }
  
   char* get_cpu_family() {
       if (android_getCpuFamily() == ANDROID_CPU_FAMILY_ARM) {
           return "ARM";
       } else if (android_getCpuFamily() == ANDROID_CPU_FAMILY_X86) {
           return "X86";
       } else if (android_getCpuFamily() == ANDROID_CPU_FAMILY_MIPS) {
           return "MIPS";
       } else {
           return "Unknown";
       }
   }
  
   char* get_cpu_features() {
       char cpu_features[256] = "";
       uint64_t features = android_getCpuFeatures();
  
       int i = 0;
       int features_length = sizeof(cpu_features_list) / sizeof(int);
       for (i = 0; i &lt; features_length; i++) {
           if (features &amp; cpu_features_list[i]) {
               appendString(cpu_features, cpu_features_string_list[i]);
           }
       }
  
       return cpu_features;
   }
  
   jstring
   Java_hardwareinfo_HardwareInfoActivity_getCpuFamilyFromJNI( JNIEnv* env,
                                                  jobject thiz )
   {
       return (*env)-&gt;NewStringUTF(env, get_cpu_family());
   }
  
   jstring
   Java_hardwareinfo_HardwareInfoActivity_getCpuCountFromJNI( JNIEnv* env,
                                                  jobject thiz )
   {
       return android_getCpuCount();
   }
  
   jstring
   Java_hardwareinfo_HardwareInfoActivity_getCpuFeaturesFromJNI( JNIEnv* env,
                                                  jobject thiz )
   {
       char buffer[256];
       strlcpy(buffer, get_cpu_features(), sizeof buffer);
       return (*env)-&gt;NewStringUTF(env, buffer);
   }
  </code></pre>
  
  <p><strong>Application.mk</strong> code:</p>
  
  <pre><code># Build both ARMv5TE and ARMv7-A machine code.
  APP_ABI := armeabi armeabi-v7a
  </code></pre>
  
  <p><strong>Android.mk</strong> code:</p>
  
  <pre><code>LOCAL_PATH := $(call my-dir)
  include $(CLEAR_VARS)
  LOCAL_MODULE := cpuinfo
  LOCAL_SRC_FILES := cpuinfo.c
  ifeq ($(TARGET_ARCH_ABI),armeabi-v7a)
  LOCAL_CFLAGS := -DHAVE_NEON=1
  #LOCAL_SRC_FILES += cpuinfo-intrinsics.c.neon
  endif
  LOCAL_STATIC_LIBRARIES := cpufeatures
  LOCAL_LDLIBS := -llog
  include $(BUILD_SHARED_LIBRARY)
  $(call import-module,cpufeatures)
  </code></pre>