无法从加载程序dalvik.system.PathClassLoader加载avutil

时间:2015-08-11 19:54:25

标签: android

我想在Android Studio中创建一个使用ffmpegMediaPlayer播放流的简单示例

我按照链接https://github.com/wseemann/FFmpegMediaPlayer

中的说明操作

我在模拟器中运行应用程序时遇到此错误

生成错误:

08-11 15:46:02.619      903-903/com.example.audiostreamingusingffmpeglibrary E/AndroidRuntime﹕ FATAL EXCEPTION: main
    java.lang.UnsatisfiedLinkError: Couldn't load avutil from loader dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.example.audiostreamingusingffmpeglibrary-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.audiostreamingusingffmpeglibrary-2, /system/lib]]]: findLibrary returned null
            at java.lang.Runtime.loadLibrary(Runtime.java:355)
            at java.lang.System.loadLibrary(System.java:525)
            at wseemann.media.FFmpegMediaPlayer.<clinit>(FFmpegMediaPlayer.java:620)
            at com.example.audiostreamingusingffmpeglibrary.MyActivity.onCreate(MyActivity.java:21)
            at android.app.Activity.performCreate(Activity.java:5133)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
            at android.app.ActivityThread.access$600(ActivityThread.java:141)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
            at android.os.Handler.dispatchMessage(Handler.java:99)
            at android.os.Looper.loop(Looper.java:137)
            at android.app.ActivityThread.main(ActivityThread.java:5103)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:525)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
            at dalvik.system.NativeStart.main(Native Method)
08-11 15:46:02.669      275-424/system_process W/ActivityManager﹕ Force finishing activity com.example.audiostreamingusingffmpeglibrary/.MyActivity

Gradle构建文件

.....
dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile files('libs/fmp.jar')
}
.....

主要活动

.....
public class MyActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_my);


        FFmpegMediaPlayer mp = new FFmpegMediaPlayer();
        mp.setOnPreparedListener(new FFmpegMediaPlayer.OnPreparedListener() {

            @Override
            public void onPrepared(FFmpegMediaPlayer mp) {
                mp.start();
            }
        });
        mp.setOnErrorListener(new FFmpegMediaPlayer.OnErrorListener() {

            @Override
            public boolean onError(FFmpegMediaPlayer mp, int what, int extra) {
                mp.release();
                return false;
            }
        });

        try {
            mp.setDataSource("http://www.brothershouse.narod.ru/music/pepe_link_-_guitar_vibe_113_club_mix.mp3");
            mp.prepareAsync();
        } catch (IllegalArgumentException e) {
            e.printStackTrace();
        } catch (SecurityException e) {
            e.printStackTrace();
        } catch (IllegalStateException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }

    }

.......

1 个答案:

答案 0 :(得分:1)

我认为问题在于你没有在编译中包含.so文件。

尝试以下步骤:

  1. 将带有.so文件的四个文件夹放在名为“lib”的新文件夹中。
  2. 压缩zip文件中的文件夹“lib”。
  3. 将文件扩展名从zip更改为jar。
  4. 复制在项目的libs文件夹中创建的新jar。
  5. 编译依赖项中的新jar文件。