Android uses the gradle architecture of Android applications, need to do special processing of . So library , because will not find, will lead to compile correct, use error; Common usage is based on different CPUs, there are different libraries, including: armeabi,mips,x86 and so on.
Error:
?
| 1 |
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 ways to solve this:
1. Generate a jar for the ". So" library
To bring the jar into the project, you need to note the order of the directories:
?
| 123 |
-lib--armeabi---xxx.so |
Command:
?
| 1 |
jar cvf xxx_cpu.jar ./lib |
Then load into the application, you can;
2. Using Gradle Configuration
Within the scope of android{} , add:
?
| 12345678910111213141516171819 |
//noinspection alltask 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 alltasks.withType(com.android.build.gradle.tasks.PackageApplication) { pkgTask -> pkgTask.jniFolders = new HashSet<file>() pkgTask.jniFolders.add(new File(buildDir, ‘native-libs‘))}</file> |
Yes,//noinspection All can remove warning.
A companion tour, a free dating site: www.jieberu.com
Push family, free tickets, scenic spots: www.tuituizu.com
The ". So" library used in the Android-gradle schema