zoukankan      html  css  js  c++  java
  • Couldn't load libPassword from loader:NDK开发中C文件编译成cpu对应的so类库时,找不到类库报错的原因之一

    LogCat输出:

    03-03 12:42:32.665: E/AndroidRuntime(32432): FATAL EXCEPTION: main
    03-03 12:42:32.665: E/AndroidRuntime(32432): Process: com.toro.passwordencode, PID: 32432
    03-03 12:42:32.665: E/AndroidRuntime(32432): java.lang.UnsatisfiedLinkError: Couldn't load libPassword from loader dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.toro.passwordencode-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.toro.passwordencode-1, /vendor/lib, /system/lib]]]: findLibrary returned null
    03-03 12:42:32.665: E/AndroidRuntime(32432):     at java.lang.Runtime.loadLibrary(Runtime.java:358)
    03-03 12:42:32.665: E/AndroidRuntime(32432):     at java.lang.System.loadLibrary(System.java:526)
    03-03 12:42:32.665: E/AndroidRuntime(32432):     at com.toro.passwordencode.MainActivity.<clinit>(MainActivity.java:15)
    03-03 12:42:32.665: E/AndroidRuntime(32432):     at java.lang.Class.newInstanceImpl(Native Method)
    03-03 12:42:32.665: E/AndroidRuntime(32432):     at java.lang.Class.newInstance(Class.java:1208)
    03-03 12:42:32.665: E/AndroidRuntime(32432):     at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
    03-03 12:42:32.665: E/AndroidRuntime(32432):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2116)
    03-03 12:42:32.665: E/AndroidRuntime(32432):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2258)
    03-03 12:42:32.665: E/AndroidRuntime(32432):     at android.app.ActivityThread.access$800(ActivityThread.java:147)
    03-03 12:42:32.665: E/AndroidRuntime(32432):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1211)
    03-03 12:42:32.665: E/AndroidRuntime(32432):     at android.os.Handler.dispatchMessage(Handler.java:102)
    03-03 12:42:32.665: E/AndroidRuntime(32432):     at android.os.Looper.loop(Looper.java:136)
    03-03 12:42:32.665: E/AndroidRuntime(32432):     at android.app.ActivityThread.main(ActivityThread.java:5135)
    03-03 12:42:32.665: E/AndroidRuntime(32432):     at java.lang.reflect.Method.invokeNative(Native Method)
    03-03 12:42:32.665: E/AndroidRuntime(32432):     at java.lang.reflect.Method.invoke(Method.java:515)
    03-03 12:42:32.665: E/AndroidRuntime(32432):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:795)
    03-03 12:42:32.665: E/AndroidRuntime(32432):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:611)
    03-03 12:42:32.665: E/AndroidRuntime(32432):     at dalvik.system.NativeStart.main(Native Method)

    Android.mk代码如下:

    LOCAL_PATH := $(call my-dir)
    
    include $(CLEAR_VARS)
    
    #LOCAL_MODULE    := libEncodePassword #导致错误的行,此处so类库名前不能以“lib”开头。应该是编译时生成的so类库文件都以lib为前缀有冲突。此处打个问号,求解
    LOCAL_MODULE    := EncodePassword #正确行#
    LOCAL_SRC_FILES := Password.c
    
    include $(BUILD_SHARED_LIBRARY)

    MainActivity.java代码如下:

        //加载cpu架构对应的so类库
        static{
            //System.loadLibrary("libEncodePassword"); //导致错误的行,此处so类库名前不能以“lib”开头
            System.loadLibrary("EncodePassword"); //正确
        }
  • 相关阅读:
    QT移植详解
    如何构建Qt4.7.0嵌入式开发环境
    Qt触摸屏、键盘的驱动[转]
    【详解】如何编写Linux下Nand Flash驱动
    QT安装 -->Error: register or shift expression expected -- `orr r3,r2,lsl#16'
    QT环境搭建常见的bug解决 -->ld: cannot find –lbootstrap 错误
    SDK支付流程
    IOS与Unity交互
    Android
    [转]个人对AutoResetEvent和ManualResetEvent的理解
  • 原文地址:https://www.cnblogs.com/qq641120784/p/5238250.html
Copyright © 2011-2022 走看看