文章目录
- 一、报错信息
- 二、解决方案
一、报错信息
Android 应用中 , 引入了 ijkplayer , 其中涉及到需要加载 libijkffmpeg.so 动态库 , 在 64 位手机中 , 报如下错误 ;
代码语言:javascript复制2022-05-26 22:08:58.532 28613-28661/com.example.app E/libc: Access denied finding property "vendor.debug.egl.profiler"
2022-05-26 22:08:58.664 28613-28613/com.example.app E/libEGL: call to OpenGL ES API with no current context (logged once per thread)
2022-05-26 22:09:03.750 28613-28613/com.example.app E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.app, PID: 28613
java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/system/framework/org.apache.http.legacy.boot.jar", zip file "/data/app/com.example.app-7GPRX3SHDXuOB6ERQJ3_dg==/base.apk"],nativeLibraryDirectories=[/data/app/com.example.app-7GPRX3SHDXuOB6ERQJ3_dg==/lib/arm64, /data/app/com.example.app-7GPRX3SHDXuOB6ERQJ3_dg==/base.apk!/lib/arm64-v8a, /system/lib64]]] couldn't find "libijkffmpeg.so"
at java.lang.Runtime.loadLibrary0(Runtime.java:1012)
at java.lang.System.loadLibrary(System.java:1669)
at tv.danmaku.ijk.media.player.IjkMediaPlayer$1.loadLibrary(IjkMediaPlayer.java:179)
at tv.danmaku.ijk.media.player.IjkMediaPlayer.loadLibrariesOnce(IjkMediaPlayer.java:190)
at tv.danmaku.ijk.media.player.IjkMediaPlayer.initPlayer(IjkMediaPlayer.java:231)
at tv.danmaku.ijk.media.player.IjkMediaPlayer.<init>(IjkMediaPlayer.java:227)
at tv.danmaku.ijk.media.player.IjkMediaPlayer.<init>(IjkMediaPlayer.java:218)
at com.example.app.VideoPlayerIJK.createPlayer(VideoPlayerIJK.java:139)
at com.example.app.VideoPlayerIJK.load(VideoPlayerIJK.java:118)
at com.example.app.VideoPlayerIJK.access$100(VideoPlayerIJK.java:24)
at com.example.app.VideoPlayerIJK$LmnSurfaceCallback.surfaceChanged(VideoPlayerIJK.java:105)
at android.view.SurfaceView.updateSurface(SurfaceView.java:682)
at android.view.SurfaceView$2.onPreDraw(SurfaceView.java:143)
at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:977)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2471)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1463)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7190)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:949)
at android.view.Choreographer.doCallbacks(Choreographer.java:761)
at android.view.Choreographer.doFrame(Choreographer.java:696)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:935)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6718)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
二、解决方案
上述报错提示 无法找到 libijkffmpeg.so 动态库 , 先检查下 apk 打包时 , 是否有上述动态库 ;
最后发现 , 在打包出来的 apk 文件中 ,
lib/armeabi-v7a 中存在 libijkffmpeg.so 动态库 ,
但是在 lib/arm64-v8a 中不存在 libijkffmpeg.so 动态库 ,
手机设备是 64 位的 , 自然加载 lib/arm64-v8a 中 的动态库 , 因此报上述错误 ;
在 build.gradle 中的 dependencies 依赖中 , 添加
代码语言:javascript复制implementation 'tv.danmaku.ijk.media:ijkplayer-arm64:0.8.8'
依赖 , 即可将 64 位的 libijkffmpeg.so 动态库编译到应用中 ;
代码语言:javascript复制dependencies {
implementation 'tv.danmaku.ijk.media:ijkplayer-java:0.8.8'
implementation 'tv.danmaku.ijk.media:ijkplayer-armv7a:0.8.8'
implementation 'tv.danmaku.ijk.media:ijkplayer-arm64:0.8.8'
implementation 'tv.danmaku.ijk.media:ijkplayer-exo:0.8.8'
}