我在android中面对这个java.lang.UnsatisfiedLinkError。虽然我还有androidndk以及在android中运行ffmpeg所需的其他必要部件,如jni文件夹文件ffmped,armeabi,build_ files等。我已经想出了很多时间,但它尚未修复。请引导我解决我的问题。 这是我的基本代码
public class MainActivity extends Activity {
static {
System.loadLibrary("ffmpeg");
System.loadLibrary("ffmpeg-test-jni");
}
TextView text_titlebar_text;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
text_titlebar_text = (TextView) findViewById(R.id.tvView);
showVideoInfo(new File(Environment.getExternalStorageDirectory().getAbsoluteFile()+ "/video.mp4"));
}
//declare the jni functions
private static native void naInit(String _videoFileName);
private static native int[] naGetVideoResolution();
private static native String naGetVideoCodecName();
private static native String naGetVideoFormatName();
private static native void naClose();
private void showVideoInfo(final File _file) {
String videoFilename = _file.getAbsolutePath();
naInit(videoFilename);
int[] prVideoRes = naGetVideoResolution();
String prVideoCodecName = naGetVideoCodecName();
String prVideoFormatName = naGetVideoFormatName();
naClose();
String displayText = "Video: " + videoFilename + "\n";
displayText += "Video Resolution: " + prVideoRes[0] + "x" + prVideoRes[1] + "\n";
displayText += "Video Codec: " + prVideoCodecName + "\n";
displayText += "Video Format: " + prVideoFormatName + "\n";
text_titlebar_text.setText(displayText);
}
}
这是一个LogCat
01-01 07:04:18.862: E/AndroidRuntime(4653): FATAL EXCEPTION: main
01-01 07:04:18.862: E/AndroidRuntime(4653): java.lang.UnsatisfiedLinkError: Couldn't load ffmpeg from loader dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.example.testone-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.testone-1, /vendor/lib, /system/lib]]]: findLibrary returned null
01-01 07:04:18.862: E/AndroidRuntime(4653): at java.lang.Runtime.loadLibrary(Runtime.java:366)
01-01 07:04:18.862: E/AndroidRuntime(4653): at java.lang.System.loadLibrary(System.java:514)
01-01 07:04:18.862: E/AndroidRuntime(4653): at com.example.testone.MainActivity.<clinit>(MainActivity.java:16)
01-01 07:04:18.862: E/AndroidRuntime(4653): at java.lang.Class.newInstanceImpl(Native Method)
01-01 07:04:18.862: E/AndroidRuntime(4653): at java.lang.Class.newInstance(Class.java:1319)
01-01 07:04:18.862: E/AndroidRuntime(4653): at android.app.Instrumentation.newActivity(Instrumentation.java:1054)
01-01 07:04:18.862: E/AndroidRuntime(4653): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2260)
01-01 07:04:18.862: E/AndroidRuntime(4653): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2395)
01-01 07:04:18.862: E/AndroidRuntime(4653): at android.app.ActivityThread.access$600(ActivityThread.java:162)
01-01 07:04:18.862: E/AndroidRuntime(4653): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1364)
01-01 07:04:18.862: E/AndroidRuntime(4653): at android.os.Handler.dispatchMessage(Handler.java:107)
01-01 07:04:18.862: E/AndroidRuntime(4653): at android.os.Looper.loop(Looper.java:194)
01-01 07:04:18.862: E/AndroidRuntime(4653): at android.app.ActivityThread.main(ActivityThread.java:5371)
01-01 07:04:18.862: E/AndroidRuntime(4653): at java.lang.reflect.Method.invokeNative(Native Method)
01-01 07:04:18.862: E/AndroidRuntime(4653): at java.lang.reflect.Method.invoke(Method.java:525)
01-01 07:04:18.862: E/AndroidRuntime(4653): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
01-01 07:04:18.862: E/AndroidRuntime(4653): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
01-01 07:04:18.862: E/AndroidRuntime(4653): at dalvik.system.NativeStart.main(Native Method)
01-01 07:04:18.921: E/AppErrorDialog(496): Failed to get ILowStorageHandle instance