". So" library used in Android-Gradle Architecture
The. so library used in the Gradle Architecture
AndroidGradle ArchitectureAndroid Application, you need. So LibraryFor special processing, compilation is correct and usage is incorrect because it cannot be found. The common usage is that different CPUs have different libraries, including:Armeabi, mips, x86.
Error:
java.lang.UnsatisfiedLinkError: Couldn't load weibosdkcore from loader dalvik.system.PathClassLoader[DexPathList[[zip file /data/app/xxx.apk],nativeLibraryDirectories=[/data/app-lib/xxx-2, /vendor/lib, /system/lib]]]: findLibrary returned null
There are two solutions: 1. Generate the ". so" library and introduce the jar into the project. Pay attention to the directory sequence:
-lib--armeabi---xxx.so
Command:
jar cvf xxx_cpu.jar ./lib
Load it to the application;
2. Use gradle to configure
Android {}To add:
//noinspection all task copyNativeLibs(type: Copy) { // third party lib so from(new File(projectDir, 'libs')) { include 'armeabi/*.so' } into new File(buildDir, 'native-libs') } tasks.withType(JavaCompile) { compileTask -> //noinspection all compileTask.dependsOn copyNativeLibs } //noinspection all tasks.withType(com.android.build.gradle.tasks.PackageApplication) { pkgTask -> pkgTask.jniFolders = new HashSet
() pkgTask.jniFolders.add(new File(buildDir, 'native-libs')) }
You can,
// Noinspection allCan be removed
Warning.