AndroidStudio工程
android studio 下引入有.so文件的包,出现如下错误:
java.lang.UnsatisfiedLinkError:
dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/net.comet.example-1/base.apk"],
nativeLibraryDirectories=[/data/app/net.comet.example-1/lib/arm64, /vendor/lib64, /system/lib64]]]
couldn't find "libffmpeg.so"
at java.lang.Runtime.loadLibrary(Runtime.java:366)
at java.lang.System.loadLibrary(System.java:989)
at com.dtr.zbar.build.ZBarDecoder.<clinit>(ZBarDecoder.java:6)
at me.ele.hbdteam.widget.ScanView$1.onPreviewFrame(ScanView.java:263)
at android.hardware.Camera$EventHandler.handleMessage(Camera.java:1565)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:155)
at android.app.ActivityThread.main(ActivityThread.java:5696)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1029)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:824)
解决思路是:
- 1、把libffmpeg.so拷贝一份到armeabi-v7a目录
2、在app.gradle增加jniLibs声明
sourceSets.main { jniLibs.srcDirs = ['libs'] }
SurfaceView
播放视频的时候只有声音没有图像,主要的原因是,在调用MediaPlayer开始播放视频时
SurfaceView却还未创建成功,解决办法是判断SurfaceView创建成功后再调用MediaPlayer的播放,
通过surfaceHolder的addCallBack()方法来监听surfaceCreated