Android media.AudioTrack.finalize Throwing IllegalStateException: Binder has been finalized - java

I am using a custom camera to record Videos on android.
The device experiencing the issue is a Nexus 5 with Android 6.0.1 on it.
When the camera finishes recording for only for the 2nd time, i get the following exception in the under-the-hood android media AudioTrack class. This is something that is called implicitly by android, by the FinalizerDaemon, and not as a result of any code I execute directly. So the FinalizerDaemon calls finalize on AudioTrack, and gets an IllegalStateException.
12-02 09:20:23.155 23705-23714/social.ivideo.greetings E/System: Uncaught exception thrown by finalizer
12-02 09:20:23.160 23705-23714/social.ivideo.greetings E/System: java.lang.IllegalStateException: Binder has been finalized!
at android.os.BinderProxy.transactNative(Native Method)
at android.os.BinderProxy.transact(Binder.java:615)
at com.android.internal.app.IAppOpsService$Stub$Proxy.stopWatchingMode(IAppOpsService.java:435)
at android.media.PlayerBase.baseRelease(PlayerBase.java:136)
at android.media.AudioTrack.finalize(AudioTrack.java:979)
at java.lang.Daemons$FinalizerDaemon.doFinalize(Daemons.java:222)
at java.lang.Daemons$FinalizerDaemon.run(Daemons.java:209)
at java.lang.Thread.run(Thread.java:761)
Perhaps I need to do some sort of clean up when the camera finishes recording? Here's the current code I'm using when the recording stops:
#Override
public void stopRecording(boolean wasCancelled, float duration) {
if (mMediaRecorder != null) {
mMediaRecorder.stop();
mMediaRecorder.reset();
if (flashState) {
toggleFlash();
}
if (!wasCancelled) {
callbacks.onFinishedRecording(null, mediaPath, duration, wasCancelled);
}
}
}
mMediaRecorder is an instance of MediaRecorder class.
Any suggestions?

So I think this might be an Android bug. Looks suspiciously like this issue, which is marked as fixed in a "future version": https://issuetracker.google.com/issues/37138597
Same Issue Reported in Android 7.1.2
fixed in Android 8.0 https://android.googlesource.com/platform/frameworks/base/+log/aee6ee94675d56e71a42d52b16b8d8e5fa6ea3ff/media/java/android/media/PlayerBase.java

Related

react-native-facebook-login: attempt to login results in Instrumentation.java error

I am using react-native-facebook-login for users authorization in my react-native app. It used to work just fine, but now it is not working when used with new versions of Android (in particular, with Android Pie). Old versions still work.
When I press Login button, some kind of loading happens, and then Facebook layout with following error shows up: "Login Error: There is an error in logging you into this application. Please try again later".
I've checked the logcat, and found this error showed up after the button was pressed.
2019-07-25 19:38:53.855 17122-17122/? E/Instrumentation: Uninitialized ActivityThread, likely app-created Instrumentation, disabling AppComponentFactory
java.lang.Throwable
at android.app.Instrumentation.getFactory(Instrumentation.java:1233)
at android.app.Instrumentation.newActivity(Instrumentation.java:1224)
at X.04T.newActivity(:4122)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3313)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3587)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:86)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2185)
at android.os.Handler.dispatchMessage(Handler.java:112)
at android.os.Looper.loop(Looper.java:216)
at android.app.ActivityThread.main(ActivityThread.java:7593)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:524)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:987)
This stacktrace has led me to Instrumentation.java, so this is the code where error occurs:
private AppComponentFactory getFactory(String pkg) {
if (pkg == null) {
Log.e(TAG, "No pkg specified, disabling AppComponentFactory");
return AppComponentFactory.DEFAULT;
}
if (mThread == null) {
Log.e(TAG, "Uninitialized ActivityThread, likely app-created Instrumentation,"
+ " disabling AppComponentFactory", new Throwable());
return AppComponentFactory.DEFAULT;
}
LoadedApk apk = mThread.peekPackageInfo(pkg, true);
// This is in the case of starting up "android".
if (apk == null) apk = mThread.getSystemContext().mPackageInfo;
return apk.getAppFactory();
}
I am not that good in Java to be able to understand how to fix it, or what is even going on here. I've found some articles where this stuff is mentioned, but all of them are in chinese and not really helping. So, if anyone knows how this could be handled, I'd really appreciate any help.

sinch video call camera permission problem with Android pei (9)

update
I am developing a small app which requires camera permission. I can handle the run time permission but the real problem is that when I relay to Sinchpayload and go to incomming call activity. This activity should request permissions (camera and other 2 permissions). But instead of showing the permission dialogue, it crash my app because of security exception. this thing happen only if I request camera permission - not happen to other permissions and only on Android 9 with camera "2" Api - Android 8.1 and lower works fine . THIS PROBLEM STILL HAPPEN WITH THE SINCH SAMPLE PUSH. The permission dialogue will show if start activity with intent as usual. This is the error :
-------- beginning of crash
2019-02-10 22:11:55.390 2113-2681/com.example.myapp.app E/AndroidRuntime: FATAL EXCEPTION: VideoCapturerThread
Process: com.example.myapp.app, PID: 2113
java.lang.SecurityException: validateClientPermissionsLocked:1054: Caller "com.example.myapp.app" (PID 10319, UID 2113) cannot open camera "1" without camera permission
at android.hardware.camera2.CameraManager.throwAsPublicException(CameraManager.java:747)
at android.hardware.camera2.CameraManager.openCameraDeviceUserAsync(CameraManager.java:405)
at android.hardware.camera2.CameraManager.openCameraForUid(CameraManager.java:567)
at android.hardware.camera2.CameraManager.openCamera(CameraManager.java:495)
at org.webrtc.Camera2Session.openCamera(Unknown Source:44)
at org.webrtc.Camera2Session.start(Unknown Source:60)
at org.webrtc.Camera2Session.<init>(Unknown Source:73)
at org.webrtc.Camera2Session.create(Unknown Source:17)
at org.webrtc.Camera2Capturer.createCameraSession(Unknown Source:17)
at org.webrtc.CameraCapturer$5.run(Unknown Source:52)
at android.os.Handler.handleCallback(Handler.java:891)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:207)
at android.os.HandlerThread.run(HandlerThread.java:65)
Caused by: android.os.ServiceSpecificException: validateClientPermissionsLocked:1054: Caller "com.example.myapp.app" (PID 10319, UID 2113) cannot open camera "1" without camera permission (code 1)
at android.os.Parcel.createException(Parcel.java:1967)
at android.os.Parcel.readException(Parcel.java:1921)
at android.os.Parcel.readException(Parcel.java:1871)
at android.hardware.ICameraService$Stub$Proxy.connectDevice(ICameraService.java:343)
at android.hardware.camera2.CameraManager.openCameraDeviceUserAsync(CameraManager.java:369)
at android.hardware.camera2.CameraManager.openCameraForUid(CameraManager.java:567) 
at android.hardware.camera2.CameraManager.openCamera(CameraManager.java:495) 
at org.webrtc.Camera2Session.openCamera(Unknown Source:44) 
at org.webrtc.Camera2Session.start(Unknown Source:60) 
at org.webrtc.Camera2Session.<init>(Unknown Source:73) 
at org.webrtc.Camera2Session.create(Unknown Source:17) 
at org.webrtc.Camera2Capturer.createCameraSession(Unknown Source:17) 
at org.webrtc.CameraCapturer$5.run(Unknown Source:52) 
at android.os.Handler.handleCallback(Handler.java:891) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:207) 
at android.os.HandlerThread.run(HandlerThread.java:65)`
and this is my code to request permissions :
if (Build.VERSION.SDK_INT>=23)
{
if (GlobalConstants.isAllPermissionsGrantedBefore_Video_Call(this)==false)
ActivityCompat.requestPermissions(
Video_incomming_call.this,
GlobalConstants.mPermissions_Video_Chat,
GlobalConstants.VIDEO_RECIEVE_CODE);
else {
Start_Calling();
}
} else Start_Calling();
The app permission dialog only shows in foreground.

Strange error at super.onStart();

I developed an Android application and it runs perfectly but sometimes it throws a strange error:
If the application had been executed before and you execute it again, just sometimes, it throws me the next error: android.database.CursorIndexOutOfBoundsException: Index 0 requested, with a size of 0.
The strange part of this (at least for me, cause I'm not an Android expert) is that, apart of that this doesn't occurs always, is that the first point appearing at the error log is thesuper.onStart(); line of my main.java and I don't have nothing before that line.
Here is my onStart method:
#Override
protected void onStart() {
super.onStart();
mPager.setOffscreenPageLimit(4);
mPager.setPageTransformer(true, new ZoomOutPageTransformer());
}
Here is the error log:
...
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.database.CursorIndexOutOfBoundsException: Index 0 requested, with a size of 0
at android.database.AbstractCursor.checkPosition(AbstractCursor.java:418)
at android.database.AbstractWindowedCursor.checkPosition(AbstractWindowedCursor.java:136)
at android.database.AbstractWindowedCursor.getInt(AbstractWindowedCursor.java:68)
at mysql.BaseDatos.getAsignaturaDataBase(BaseDatos.java:233)
at com.tfd.myapp.FragmentAsig.onCreateView(FragmentAsig.java:269)
at android.support.v4.app.Fragment.performCreateView(Fragment.java:1478)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:927)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1104)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1086)
at android.support.v4.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManager.java:1877)
at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:552)
at com.tfd.myapp.Principal.onStart(Principal.java:108)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1166)
at android.app.Activity.performStart(Activity.java:5254)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2043)
...
How this can be possible?
onStart() executes any pending fragment transactions. In this case it involves instantiating your FragmentAsig and the bug is there. Specifically:
at mysql.BaseDatos.getAsignaturaDataBase(BaseDatos.java:233)
at com.tfd.myapp.FragmentAsig.onCreateView(FragmentAsig.java:269)
you're calling getInt() on a Cursor that has no data. You need to check that e.g. moveToFirst() succeeded.

Why does android logcat not show the stack trace for a runtime exception?

An android application that I am currently developing was crashing (fixed that), due to what should have raised an IndexOutOfBoundsException. I was accessing a string in the doInBackground method of a class that extends AyncTask, from the variable arguments parameter (ie String...). I was accidentally accessing index 1 (not 0) of a one element variable argument string (mildly embarrassing...). When the application first crashed I looked at my logcat, (and many times again to confirm that I wasn't insane) and there was no stack trace for a RuntimeException to be found. I crash my phone quite often and there is always a nice little stack trace for me to look at and fix with, but I was puzzled by this. Here is the pertinent section of my logcat (which contains no stack trace for a runtimeexception), following a debug statement right before the line of code that was causing the crash:
W/dalvikvm(25643): threadid=11: thread exiting with uncaught exception (group=0x40c281f8)
D/dalvikvm(25643): GC_CONCURRENT freed 1249K, 25% free 12433K/16455K, paused 2ms+6ms
W/dalvikvm(25643): threadid=15: thread exiting with uncaught exception (group=0x40c281f8)
I/Process (25643): Sending signal. PID: 25643 SIG: 9
I/ActivityManager( 5905): Process com.trade.nav.ges (pid 25643) has died.
W/ActivityManager( 5905): Force removing r: app died, no saved state
I/WindowManager( 5905): WIN DEATH: win
I/WindowManager( 5905): WIN DEATH: win
I/SurfaceFlinger( 1746): id=3848 Removed idx=2 Map Size=4
I/SurfaceFlinger( 1746): id=3848 Removed idx=-2 Map Size=4
I/WindowManager( 5905): WIN DEATH: win
I/power ( 5905): *** acquire_dvfs_lock : lockType : 1 freq : 1000000
D/PowerManagerService( 5905): acquireDVFSLockLocked : type : DVFS_MIN_LIMIT frequency : 1000000 uid : 1000 pid : 5905 tag : ActivityManager
W/ActivityManager( 5905): mDVFSLock.acquire()
And after that, another activity starts.
For reference, here is the code that caused the crash:
private class LoadImage extends AsyncTask<String, Integer, Bitmap> {
String url = "";
//...
public LoadImage(ImageView iv, Context c) {
//...
}
protected Bitmap doInBackground(String... urls) {
// urls has one element
url = urls[1];
//...
}
//...
}
Any insight into what is happening would please me greatly, as I am curious about having never seen anything like this on the internet.
Thanks.
Edit: I have no filter set
Your threads are clearly crashing (note the thread exiting with uncaught exception on two different threads in the same process). The process is cleaning up after itself -- Sending signal indicates the process is sending a fatal signal to itself. So the question is why you aren't seeing a stack dump between these two.
The stack dump comes from RuntimeInit$UncaughtHandler, which is the framework-provided global uncaught exception handler. The process self-annihilation happens in the finally block. It's hard to see a way to get out of this without logging "FATAL EXCEPTION", unless something in Slog.e fails and throws.
I would guess that either something is failing in Slog.e, or somebody has replaced the framework's uncaught exception handler. The latter could happen if you've incorporated some external library into your app, such as a crash log catcher or an ad network, and the new handler doesn't log the exception but does kill the process.
You can track it down by attaching a Java-language debugger (e.g. Eclipse). By default it will stop on uncaught exceptions. From there you can trace it around, set breakpoints and single-step through the uncaught exception handler (if you have full sources), and so on.
As per fadden's suspect that external library could override uncaught exception handler, I started to investigate any possible libs. Turned out that GoogleAnalytics throttles crashes and prevents the stack trace from being displayed in logcat if you turn on enableExceptionReporting. I remove this line of code then everything gets back on track!! That could be the first time I was so happy to see crashes!!

Android - java.lang.VerifyError on SDK 2.2

I recently launched my application to the Market and I've been in contact with a user who is reporting that when he launches my app, it display the Force Close/Report dialog. I asked the user to report the error so I could see the stack trace of what's happening and I'm getting the java.lang.VerifyError.
From what I've read, this has either something to do with an external library or an incompatibility in some method in java.lang with the targeted Android SDK version.
The user is on Android 2.2.1, but the app currently works on many other 2.2 devices, so I'm trying to figure out where to start digging.
Question:
Does anybody have suggestions as to what would be the best thing to start looking into to find the issue? I can provide code or more information if needed, so please let me know.
Here's the Stack Trace:
java.lang.VerifyError: com.app.myapp.MainActivity
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1429)
at android.app.Instrumentation.newActivity(Instrumentation.java:1034)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2749)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2866)
at android.app.ActivityThread.access$2300(ActivityThread.java:140)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2181)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:143)
at android.app.ActivityThread.main(ActivityThread.java:5097)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
at dalvik.system.NativeStart.main(Native Method)
Thanks in advance!
EDIT
Added per request of Konstantin
MainActivity.java
package com.app.myapp;
//Imports removed
public class MainActivity extends BaseActivity implements Runnable {
private LayoutInflater mInflater;
private SharedPreferences prefs;
private SharedPreferences.Editor prefsEditor;
....
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
loadActivity(savedInstanceState);
}
private void loadActivity(Bundle savedInstanceState) {
setContentView(R.layout.mainlayout);
ActionBar actionBar = (ActionBar)findViewById(R.id.actionbar);
actionBar.setTitle("My App");
actionBar.setHomeAction(new IntentAction(this, null, R.drawable.ic_actionbar_home));
actionBar.addAction(new SearchAction(this, R.drawable.ic_actionbar_search));
weatherThread = new Thread(this);
try {
....Unrelated Code....
//****HERE WAS THE PROBLEM****//
Gson gson = new Gson();
....More Unrelated Code....
} catch (JsonSyntaxException ex) { }
initMembers();
initControls();
if (savedInstanceState != null) {
mSelectedLayout = savedInstanceState.getInt("CURRENT_TAB");
setCurrentTab();
}
else
loadMainLayout();
}
....Other unrelated code....
}
There are a few devices which are using GSON internally, but made the library public, causing a namespace conflict when the application attempts to reference its packaged version of gson. A possible workaround is changing the namespace of the gson jar you have included using jarjar.
Heres a thread on the issue - The thread contains a description of at least one workaround supplied by another developer who encountered the same issue.
there could be mismatch with the libs like Gson you have compiled and libs which are used in run time.
Ref - Causes of getting a java.lang.VerifyError
It looks like ActionBar was released since API level 11 only, while android 2.2 is somewhat older (API level 8). So try it without the action bar. I do not know if the view was backported to 2.2 platform, but even if it was, your user can still have old 2.2 version..
Check that you are compiling against the correct Android SDK version. What is minSDK in your AndroidManifest.xml?

Categories

Resources