jenly1314 / WeChatQRCode

⛄ 基于OpenCV开源的微信二维码引擎移植的二维码扫码识别库
https://jenly1314.github.io/WeChatQRCode/
Apache License 2.0
607 stars 120 forks source link

Java_org_opencv_wechat_1qrcode_WeChatQRCode_WeChatQRCode_10方法未实现 #47

Closed EVANGELION-K closed 6 months ago

EVANGELION-K commented 6 months ago

电脑:win10 手机:小米13 高通骁龙8 Gen2 logcat: No implementation found for long org.opencv.wechat_qrcode.WeChatQRCode.WeChatQRCode_0(java.lang.String, java.lang.String, java.lang.String, java.lang.String) (tried Java_org_opencv_wechat_1qrcode_WeChatQRCode_WeChatQRCode_10 and Java_org_opencv_wechat_1qrcode_WeChatQRCode_WeChatQRCode_10__Ljava_lang_String_2Ljava_lang_String_2Ljava_lang_String_2Ljava_lang_String_2) - is the library loaded, e.g. System.loadLibrary?

2024-02-20 16:50:38.920 9745-9745 AndroidRuntime com.tencent.yolov5ncnn D Shutting down VM 2024-02-20 16:50:38.922 9745-9745 AndroidRuntime com.tencent.yolov5ncnn E FATAL EXCEPTION: main Process: com.tencent.yolov5ncnn, PID: 9745 java.lang.UnsatisfiedLinkError: No implementation found for long org.opencv.wechat_qrcode.WeChatQRCode.WeChatQRCode_0(java.lang.String, java.lang.String, java.lang.String, java.lang.String) (tried Java_org_opencv_wechat_1qrcode_WeChatQRCode_WeChatQRCode_10 and Java_org_opencv_wechat_1qrcode_WeChatQRCode_WeChatQRCode_10__Ljava_lang_String_2Ljava_lang_String_2Ljava_lang_String_2Ljava_lang_String_2) - is the library loaded, e.g. System.loadLibrary? at org.opencv.wechat_qrcode.WeChatQRCode.WeChatQRCode_0(Native Method) at org.opencv.wechat_qrcode.WeChatQRCode.(WeChatQRCode.java:44) at com.king.wechat.qrcode.WeChatQRCodeDetector.initWeChatQRCode(WeChatQRCodeDetector.java:87) at com.king.wechat.qrcode.WeChatQRCodeDetector.init(WeChatQRCodeDetector.java:45) at com.tencent.yolov5ncnn.MainActivity.onCreate(MainActivity.java:97) at android.app.Activity.performCreate(Activity.java:8891) at android.app.Activity.performCreate(Activity.java:8856) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1468) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3969) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4140) at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:103) at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:149) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:99) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2585) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loopOnce(Looper.java:224) at android.os.Looper.loop(Looper.java:318) at android.app.ActivityThread.main(ActivityThread.java:8744) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:561) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1013) 2024-02-20 16:50:38.923 9745-9745 cent.yolov5ncnn com.tencent.yolov5ncnn W type=1400 audit(0.0:544615): avc: denied { search } for name="miuilog" dev="dm-51" ino=427 scontext=u:r:untrusted_app_29:s0:c95,c257,c512,c768 tcontext=u:object_r:data_log_file:s0 tclass=dir permissive=0 app=com.tencent.yolov5ncnn 2024-02-20 16:50:38.926 9745-9745 ScoutUtils com.tencent.yolov5ncnn W Failed to mkdir /data/miuilog/stability/memleak/heapdump/ 2024-02-20 16:50:38.941 9745-9745 Process com.tencent.yolov5ncnn I Process is going to kill itself! java.lang.Exception at android.os.Process.killProcess(Process.java:1356) at com.android.internal.os.RuntimeInit$KillApplicationHandler.uncaughtException(RuntimeInit.java:174) at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:1071) at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:1066) at java.lang.Thread.dispatchUncaughtException(Thread.java:2306) 2024-02-20 16:50:38.941 9745-9745 Process com.tencent.yolov5ncnn I Sending signal. PID: 9745 SIG: 9

app的build.gradle文件

//应用 Android 应用程序插件,表示这个项目是一个 Android 应用程序。 apply plugin: 'com.android.application'

android { compileSdk 34 //指定应用程序编译的 SDK 版本。 buildToolsVersion "29.0.2" //指定要使用的 Android 构建工具的版本。

//这个块包含应用程序的默认配置设置。
defaultConfig {
    applicationId "com.tencent.yolov5ncnn"  //指定应用程序的唯一应用程序 ID。
    archivesBaseName = "$applicationId"     //设置生成的构建存档的基本名称。
    //这个块配置原生开发工具包(NDK)的设置。
    ndk {
        moduleName "ncnn"  //指定使用 NDK 编译的模块的名称
        abiFilters "armeabi-v7a", "arm64-v8a"   //指定在构建中包含的 ABI(应用程序二进制接口)。
    }
    minSdkVersion 29    //指定运行应用程序所需的最低 Android API 级别。

    externalNativeBuild { //这个块配置了外部本地构建系统的设置。
        cmake { //指定使用 CMake 进行本地代码构建。
            arguments "-DANDROID_TOOLCHAIN=clang"  //指定了使用 clang 工具链进行构建
            //指定了 C 和 C++ 编译器的编译选项。
            cFlags "-fopenmp -O2 -fvisibility=hidden -fomit-frame-pointer -fstrict-aliasing -ffunction-sections -fdata-sections -ffast-math "
            cppFlags "-fopenmp -O2 -fvisibility=hidden -fvisibility-inlines-hidden -fomit-frame-pointer -fstrict-aliasing -ffunction-sections -fdata-sections -ffast-math "
            arguments "-DANDROID_STL=c++_shared", "-DANDROID_CPP_FEATURES=rtti exceptions"
            //指定了 STL 库和 C++ 特性的选项。
            cppFlags "-fexceptions"
            cppFlags "-std=c++11 -fopenmp -static-openmp"
            //cppFlags "-fstatic-openmp"
            //abiFilters 'armeabi-v7a', 'arm64-v8a'//,'x86_64' 'x86' , //指定了要构建的 ABI(应用程序二进制接口)。
        }
    }
}
//这个块定义了构建类型
buildTypes {
    //指定了 release 构建类型的配置。
    release {
        minifyEnabled false //指定是否启用代码混淆。
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        //指定了 ProGuard 配置文件。
    }
}
//这个块配置外部原生构建系统的设置。
externalNativeBuild {
    cmake {
        version "3.10.2"
        path file('src/main/jni/CMakeLists.txt')
    }
}

//这个块配置了 Lint 工具的选项。
lintOptions {
    abortOnError false  //指定是否在遇到 Lint 错误时中止构建。
    checkReleaseBuilds false  //指定是否在发布版本中进行 Lint 检查。
    disable 'MissingTranslation'
    //禁用了 "MissingTranslation" 错误。 防止在发布的时候出现因MissingTranslation导致Build Failed!

}
ndkVersion '21.0.6113669' //指定了使用的 NDK 版本。

}

dependencies { //vlc播放器的相关依赖 implementation fileTree(include: ['.jar'], dir: 'libs') //implementation fileTree(include: ['.jar'], dir: 'lib') implementation files('libs/libvlc-all-3.3.0-eap17.aar') //androidx依赖 implementation 'androidx.appcompat:appcompat:1.6.1' implementation 'androidx.constraintlayout:constraintlayout:2.1.4' //摄像头控制依赖 implementation files('libs/camerautil.jar') implementation 'androidx.exifinterface:exifinterface:1.3.7' //车牌识别相关依赖 implementation 'com.github.HyperInspire:hyperlpr3-android-sdk:1.0.3' //二维码识别相关库

implementation 'com.github.jenly1314.WeChatQRCode:opencv:2.1.0'
implementation 'com.github.jenly1314.WeChatQRCode:opencv-armv7a:2.1.0'
implementation 'com.github.jenly1314.WeChatQRCode:opencv-armv64:2.1.0'

// 微信二维码识别功能(可选) implementation 'com.github.jenly1314.WeChatQRCode:wechat-qrcode:2.1.0' //implementation 'org.opencv:opencv-android:4.5.4'

// // OpenCV基础库(*必须) // implementation 'com.github.jenly1314.WeChatQRCode:opencv:2.1.0' // //// 微信二维码识别功能(可选) // implementation 'com.github.jenly1314.WeChatQRCode:wechat-qrcode:2.1.0' // //// 微信二维码扫码功能(可选) // implementation 'com.github.jenly1314.WeChatQRCode:wechat-qrcode-scanning:2.1.0' ////MLKit的Camera核心库(可选),如果您使用了wechat-qrcode-scanning,则必须依赖mlkit-camera-core库 // implementation 'com.github.jenly1314.MLKit:mlkit-camera-core:1.0.1'

//无关依赖(后续考虑删除)
testImplementation 'junit:junit:4.13.2'
implementation 'com.github.bumptech.glide:glide:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'

}

jenly1314 commented 6 months ago

这是因为你项目中有其他依赖与 WeChatQRCode中的opencv 产生了冲突导致的。

EVANGELION-K commented 6 months ago

这是因为你的项目有其他依赖与WeChatQRCode中的opencv产生了冲突导致的。

感谢你的及时回复,请问你是怎么找到这个原因的?在我的项目中有ocr识别功能,确实用到了opencv不过应该和wechat使用的opencv是互不相干的.请问有什么解决方案吗? image

EVANGELION-K commented 6 months ago

这是因为你项目中有其他依赖与 WeChatQRCode中的opencv 产生了冲突导致的。

我同时在运行时还会遇到这个问题 2 files found with path 'lib/armeabi-v7a/libc++_shared.so' from inputs:

jenly1314 commented 6 months ago

这是因为你的项目有其他依赖与WeChatQRCode中的opencv产生了冲突导致的。

感谢你的及时回复,请问你是怎么找到这个原因的?在我的项目中有ocr识别功能,确实用到了opencv不过应该和wechat使用的opencv是互不相干的.请问有什么解决方案吗? image

这里提供两种可行方案:

  1. 既然都用到了opencv,你可以只保留一份opencv,然后一起编译,记得加上相同版本opencv_contrib中的wechat_qrcode。
  2. 使用其他库来实现扫码功能;比如:MLKit
EVANGELION-K commented 6 months ago

这是因为你的项目有其他依赖与WeChatQRCode中的opencv产生了冲突导致的。

感谢你的及时回复,请问你是怎么找到这个原因的?在我的项目中有ocr识别功能,确实用到了opencv不过应该和wechat使用的opencv是互不相干的.请问有什么解决方案吗? image

这里提供两种可行方案:

  1. 既然都用到了opencv,你可以只保留一份opencv,然后一起编译,记得加上相同版本opencv_contrib中的wechat_qrcode。
  2. 使用其他库来实现扫码功能;比如:MLKit

我明白了,感谢!