无法在Android Studio中添加* .so库.JniLibs目录不起作用 [英] Can't add a *.so library in Android Studio. JniLibs directory don't work
问题描述
我对问题的答案做了很多研究,但没有发现任何东西.我无法在项目中添加.so库.
I researched a lot for an answer of my question, but I didn't find anything. I can't add the .so library in my project.
我将库放在/app/src/main/jniLibs/arm64-v8a中.该项目将完成,但是在执行时会出现以下错误.
I put the library in /app/src/main/jniLibs/arm64-v8a. The project will complile but on execution the following error comes.
谢谢所有答案.
目录结构在这里.arm64-v8a是我的系统的正确文件夹.
Structure of directorys is here. arms64-v8a is the correct folder for my System.
build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.vtas_kassenterminal"
minSdkVersion 27
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/notice.txt'
exclude 'META-INF/ASL2.0'
exclude 'org/apache/http/version.properties'
exclude 'org/apache/http/nio/version.properties'
exclude 'org/apache/http/client/version.properties'
exclude 'org.apache.http.impl.nio.DefaultHttpServerIODispatch'
}
productFlavors {
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.squareup.okhttp3:okhttp:3.9.1'
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'
implementation files('libs/acssmc-1.1.4.jar')
implementation 'org.jetbrains:annotations-java5:15.0'
implementation 'com.android.volley:volley:1.1.0'
}
日志:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.vtas_kassenterminal, PID: 10504
java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.example.vtas_kassenterminal-zh4y12ECK4PCd-N-FXMp6A==/base.apk"],nativeLibraryDirectories=[/data/app/com.example.vtas_kassenterminal-zh4y12ECK4PCd-N-FXMp6A==/lib/arm, /system/lib, /system/vendor/lib]]] couldn't find "libpcsclite.so"
at java.lang.Runtime.loadLibrary0(Runtime.java:1011)
at java.lang.System.loadLibrary(System.java:1657)
at com.example.vtas_kassenterminal.JacspcscLoader.<clinit>(JacspcscLoader.java:280)
at com.example.vtas_kassenterminal.nfcTest.onCreate(nfcTest.java:135)
at android.app.Activity.performCreate(Activity.java:7258)
at android.app.Activity.performCreate(Activity.java:7249)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1222)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2927)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3059)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1724)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:7000)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:441)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1408)
推荐答案
这意味着 libpcsclite.so 在 arms64-v8a 文件夹中找不到.尝试删除.so文件中的多余字符 .1.0.0 (我在图片中看到了此内容)
That means libpcsclite.so not find in arms64-v8a folde. Try to remove your .so file extra character .1.0.0 (I saw this in image)
如果上述解决方案不起作用,请遵循以下内容.
If above solution not work follow the below.
.so文件不仅可以在 arms64-v8a 文件夹中使用.将您的.so文件添加到 armeabi-v7a 目录中.文件夹名称取决于电话硬件(可能是处理器).
The .so file not only work in arms64-v8a folder. Add your .so file in armeabi-v7a directory. The folder name depend on Phone Hardware (May be processor).
.so文件对于特定文件夹(例如 arms64-v8a 或 armeabi-v7a 等)可能会有所不同.通常,最大的设备保护范围 armeabi-v7a .
And .so file May be different for specific folder like arms64-v8a or armeabi-v7a and so on. Generally maximum device cover armeabi-v7a.
这篇关于无法在Android Studio中添加* .so库.JniLibs目录不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!