昨天躺床上伸懒腰,突然来了 APP 的崩溃通知邮件:
算了,起床修 bug。
这 bug 主要发生在 EMUI 上,找不到 so,只有华为和小米喜欢产这 bug (但是我红米 Note 3 没这问题)。
首先去 微博 SDK 的 GitHub 把 /so 全部下载下来,然后丢到 libs 里 (我在 jniLibs 里也丢了一份,不怕一万只怕万一)。
然后在 build.gradle 中:
android{ ... // 将 .so 文件打包为 Native_Libs.jar 包文件 task nativeLibsToJar(type: Zip, description: "create a jar archive of the native libs") { destinationDir file("$projectDir/libs") baseName "Native_Libs" extension "jar" from fileTree(dir: "libs", include: "**/*.so") into "lib" } tasks.withType(JavaCompile) { compileTask -> compileTask.dependsOn(nativeLibsToJar) } }
最后在 dependencies 中:
compile fileTree(include: ['*.jar'], dir: 'libs')
这样就 OK 了。