java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList

出现的错误:

java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.example.app_myapp-1/base.apk", zip file "/data/app/com.example.app_myapp-1/split_lib_dependencies_apk.apk", zip file "/data/app/com.example.app_myapp-1/split_lib_slice_0_apk.apk", zip file "/data/app/com.example.app_myapp-1/split_lib_slice_1_apk.apk", zip file "/data/app/com.example.app_myapp-1/split_lib_slice_2_apk.apk", zip file "/data/app/com.example.app_myapp-1/split_lib_slice_3_apk.apk", zip file "/data/app/com.example.app_myapp-1/split_lib_slice_4_apk.apk", zip file "/data/app/com.example.app_myapp-1/split_lib_slice_5_apk.apk", zip file "/data/app/com.example.app_myapp-1/split_lib_slice_6_apk.apk", zip file "/data/app/com.example.app_myapp-1/split_lib_slice_7_apk.apk", zip file "/data/app/com.example.app_myapp-1/split_lib_slice_8_apk.apk", zip file "/data/app/com.example.app_myapp-1/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.example.app_myapp-1/lib/arm, /vendor/lib, /system/lib]]] couldn't find "libHardControl.so"

 

原因:

我将android studio 3.4.0中的HardControl.java的如下代码中的“hardcontrol”写成了 “HardControl”,从而导至了如上的错误。

package com.example.hardlibrary;

public class HardControl{
    public static native int ledCtrl(int which,int status);
    public static native int ledOpen();
    public static native void ledClose();

    static{
        try {
            System.loadLibrary("hardcontrol");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }


}

E:\and_learning\Myled\app\libs\armeabi\  目录下的   libhardcontrol.so,这里的hardcontrol要与上文中的System.loadLibrary("hardcontrol");大小写要一至,

E:\and_learning\Myled\app\src\main\java\com\example\hardlibrary目录下的HardControl.java的名字大小要与下文中的HardControl名称的大小写一致。

/* System.loadLibrary */
JNIEXPORT jint JNICALL
JNI_OnLoad(JavaVM *jvm, void *reserved)
{
    JNIEnv *env;
    jclass cls;

    if ((*jvm)->GetEnv(jvm, (void **)&env, JNI_VERSION_1_4)) {
        return JNI_ERR; /* JNI version not supported */
    }
    cls = (*env)->FindClass(env, "com/example/hardlibrary/HardControl");
    if (cls == NULL) {
        return JNI_ERR;
    }

    /* 2. map java hello <-->c c_hello */
    if ((*env)->RegisterNatives(env, cls, methods, sizeof(methods)/sizeof(methods[0])) < 0)
        return JNI_ERR;

    return JNI_VERSION_1_4;
}
 

因为上面的错误,拆磨我好久,现在记下来,希望你们少走弯路。

=============================如下是gradle  APP完整的正确代码==============================

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.example.app_myapp"
        minSdkVersion 15
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    sourceSets{
        main{
            jniLibs.srcDirs=['libs']
        }
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值