E/AndroidRuntime(7698): Cause by: java.lang.RuntimeException: stop failed.
if (mediarecorder != null) {
mediarecorder.stop();
mediarecorder.release();
mediarecorder = null;
if (mCamera != null) {
mCamera.release();
mCamera = null;
}
}
Now, in mediarecord. Stop(); This sentence is wrong, now in mediarecord. Stop(); If you add a few sentences before this sentence, you won’t make a mistake
mediarecorder.setOnErrorListener(null);
mediarecorder.setOnInfoListener(null);
mediarecorder.setPreviewDisplay(null);
After modification:
if (mediarecorder != null) {
//added by ouyang start
try {
//The following three parameters must be added, if not, it will crash, in mediarecorder.stop();
// error is reported as: RuntimeException:stop failed
mediarecorder.setOnErrorListener(null);
mediarecorder.setOnInfoListener(null);
mediarecorder.setPreviewDisplay(null);
mediarecorder.stop();
} catch (IllegalStateException e) {
// TODO: handle exception
Log.i("Exception", Log.getStackTraceString(e));
}catch (RuntimeException e) {
// TODO: handle exception
Log.i("Exception", Log.getStackTraceString(e));
}catch (Exception e) {
// TODO: handle exception
Log.i("Exception", Log.getStackTraceString(e));
}
//added by ouyang end
mediarecorder.release();
mediarecorder = null;
if (mCamera != null) {
mCamera.release();
mCamera = null;
}
}
Read More:
- [Android Error] java.lang.RuntimeException: An error occurred while executing doInBackground()
- Rabbitmq failed to stop normally: ERROR: node with name “rabbit” already running on “localhost”
- Win assembleDebug Downloading gradle.zip Error: Exception in thread “main” java.lang.RuntimeException: javax.net.ssl.SSLExce
- Hive Error: FAILED: RuntimeException Error loading hooks(hive.exec.post.hooks): java.lang.ClassNotFoundException: org.apache.atlas.hive.hook.HiveHook
- [Solved] PCH Warning: header stop not at file scope
- [Solved] Android mediaplayer.prepare() Error: Caused by: java.lang.IllegalStateException
- [Solved] Android Error: java.lang.IllegalStateException: Not allowed to start service Intent
- [Solved] Android DataBinding Error: java.lang.ArrayIndexOutOfBoundsException: length=2; index=2 fragment Changes to Fragm
- How to Solve Error: Android java.lang.IllegalStateException: Could not execute method of the activity
- [Solved] ViewBinding Error: java.lang.ClassCastException: android.widget.RelativeLayout cannot be
- Hive ERROR Failed with exception java.io.IOException:java.lang.IllegalArgumentException
- [Solved] .java.lang.IllegalArgumentException: requirement failed: Can only call getServletHandlers on a runn
- Java.lang.AbstractMethodError: org.mybatis.spring.transaction.SpringManagedTransaction.getTimeout()Ljava/lang/Integer; error resolution
- NestedServletException, Handler dispatch failed; nested exception is java.lang.StackOverflowError [Solved]
- POI Export Excel Error: HTTP Status 500 – Request processing failed; nested exception is java.lang.NullPointerException
- [Solved] java.lang.NoClassDefFoundError: Failed resolution of: Lorg/apache/http/util/ByteArrayBuffer
- [ERROR] Terminal initialization failed; falling back to unsupported java.lang.IncompatibleClassChang
- [Solved] java.lang.reflect.InaccessibleObjectException: Unable to make protected java.net.http.HttpRequest()…
- [Solved] java.lang.UnsatisfiedLinkError: dlopen failed: /lib/arm64/libc++_shared.so not found