I am getting crash on this activity when I run the app. This is not due to appcompat as you can see in the stack trace. This is native android ListView class whose method is not found while running the app.
The same app is running properly on other devices. The minSdkVersion = 13 target =23 max =23 and current device of crashing is API 17.
FATAL EXCEPTION: main
java.lang.NoSuchMethodError: android.widget.ListView.setElevation
at com.example.saloni.laughgurumarketingapp.ContentDetails.getValues(ContentDetails.java: 392)
at com.example.saloni.laughgurumarketingapp.ContentDetails.onCreate(ContentDetails.java: 298)
at android.app.Activity.performCreate(Activity.java: 5122)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java: 1081)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java: 2270)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java: 2358)
at android.app.ActivityThread.access$600(ActivityThread.java: 156)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java: 1340)
at android.os.Handler.dispatchMessage(Handler.java: 99)
at android.os.Looper.loop(Looper.java: 153)
at android.app.ActivityThread.main(ActivityThread.java: 5297)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java: 511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java: 833)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java: 600)
at dalvik.system.NativeStart.main(Native Method)
In the code it's just a set elevation method on which it is crashing as you can see in the trace. Similarly it crashed last time on using one of the TextView class method. Why is this happening?
There is no setElevation() method in api 17. You need to only call this on api 21 and higher.
https://developer.android.com/reference/android/view/View.html#setElevation(float)
If you want to call this method on api 21 devices do this:
int currentapiVersion = android.os.Build.VERSION.SDK_INT;
if (currentapiVersion >= android.os.Build.VERSION_CODES.LOLLIPOP){
// Do something for lollipop and above versions
} else{
// do something for phones running an SDK before lollipop
}
You can use ViewCompat.setElevation and your app won't crash on pre-21 systems; however it won't have any effect on those older devices either.
Related
I have an app which streams video and it ensure making photos from another device. It is saving location of device in photo information. It works correctly on older android versions for example 6.0 Unfortunately it doesn't work on android 10 even after updating an app to SDK 29. Do you have any ideas?
When I switch off gps in android 10 phone everything goes well.
Below errors from android studio:
E/i.aoiAgent11EN: Unknown bits set in runtime_flags: 0x8000
I/Perf: Connecting to perf service.
I/FeatureParser: can't find cepheus.xml in assets/device_features/,it may be in /system/etc/device_features
E/libc: Access denied finding property "ro.vendor.df.effect.conflict"
E/Perf: Fail to get file list pl.biz.aoi.aoiAgent11ENG
getFolderSize() : Exception_1 = java.lang.NullPointerException: Attempt to get length of null array
Fail to get file list pl.biz.aoi.aoiAgent11ENG
getFolderSize() : Exception_1 = java.lang.NullPointerException: Attempt to get length of null array
E/AudioPlayer: CPP is working
java.lang.IllegalStateException: Unable to retrieve AudioTrack pointer for getPosition()
at android.media.AudioTrack.native_get_position(Native Method)
at android.media.AudioTrack.getPlaybackHeadPosition(AudioTrack.java:1699)
at pl.biz.aoi.aoiAgent11ENG.media.in.audio.player.SpeakerOutputStream.getPlayed(SpeakerOutputStream.java:46)
at pl.biz.aoi.aoiAgent11ENG.media.in.audio.player.G711AudioPlayer.writeSilenceBufferIfNeeded(G711AudioPlayer.java:136)
at pl.biz.aoi.aoiAgent11ENG.media.in.audio.player.G711AudioPlayer.run(G711AudioPlayer.java:111)
at java.lang.Thread.run(Thread.java:919)
I/chatty: uid=10262(pl.biz.aoi.aoiAgent11ENG) identical 18 lines
E/AudioPlayer: CPP is working
java.lang.IllegalStateException: Unable to retrieve AudioTrack pointer for getPosition()
at android.media.AudioTrack.native_get_position(Native Method)
at android.media.AudioTrack.getPlaybackHeadPosition(AudioTrack.java:1699)
at pl.biz.aoi.aoiAgent11ENG.media.in.audio.player.SpeakerOutputStream.getPlayed(SpeakerOutputStream.java:46)
at pl.biz.aoi.aoiAgent11ENG.media.in.audio.player.G711AudioPlayer.writeSilenceBufferIfNeeded(G711AudioPlayer.java:136)
at pl.biz.aoi.aoiAgent11ENG.media.in.audio.player.G711AudioPlayer.run(G711AudioPlayer.java:111)
at java.lang.Thread.run(Thread.java:919)
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.
If I try to use the following code, I am able to use Truecaller's SDK and fetch the user's profile if he has truecaller installed.
//has_truecaller = TrueSDK.getInstance().isUsable(); //doesnt work before init() methof
TrueSdkScope trueScope;
TrueSdkScope.Builder sdkBuilder = new TrueSdkScope.Builder(this, sdkCallback)
.consentMode(TrueSdkScope.CONSENT_MODE_POPUP )
.consentTitleOption( TrueSdkScope.SDK_CONSENT_TITLE_VERIFY )
.footerType( TrueSdkScope.FOOTER_TYPE_SKIP );
if(has_truecaller) {
trueScope = sdkBuilder.sdkOptions( TrueSdkScope.SDK_OPTION_WITH_OTP ).build();
}else{
//TODO get mobile number
BaseActivity.USER_MOBILE_NUMBER = "12345677";
trueScope = sdkBuilder.sdkOptions( TrueSdkScope.SDK_OPTION_WITH_OTP ).build();
}
TrueSDK.init(trueScope);
However If i remove Truecaller from the device i get the following error:
2-06 10:38:45.437 25694-25694/com.project.xyz.userclientapp E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.project.xyz.userclientapp, PID: 25694 java.lang.NoClassDefFoundError:
Failed resolution of: Lretrofit2/converter/gson/GsonConverterFactory;
at com.truecaller.android.sdk.b.c.a(Unknown Source:9)
at com.truecaller.android.sdk.clients.a.<init>(Unknown Source:10)
at com.truecaller.android.sdk.a.<init>(Unknown Source:46)
at com.truecaller.android.sdk.a.a(Unknown Source:2)
at com.truecaller.android.sdk.TrueSDK.init(Unknown Source:5)
at com.project.xyz.userclientapp.login.LoginActivity.setupTrueSdk(LoginActivity.java:49)
at com.project.xyz.userclientapp.login.LoginActivity.onCreate(LoginActivity.java:30)
at android.app.Activity.performCreate(Activity.java:7149)
at android.app.Activity.performCreate(Activity.java:7140)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1288)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3017)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3172)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
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:1906)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6863)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:537)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
You can check if the Truecaller app is present on the device or not by using the following line -
TrueSDK.getInstance().isUsable()
You do need to initialize the SDK using the init() method before checking for this. It will return a boolean true / false depending on wether Truecaller is installed or not.
Also, the logs what you shared are because of missing a library dependency in your android project. Can you try add the following dependency in your gradle. This should help solve the error -
compile 'com.squareup.retrofit2:retrofit:2.0.0-beta4'
compile 'com.squareup.retrofit2:converter-gson:2.0.0-beta4'
I have built app in which I integrate YouTube API and it is working fine without any crash but on Fabric I checked some crash whis is ipf.onFilterTouchEventForSecurity. Here is the full logs of the crash:
java.lang.NullPointerException:
at ipf.onFilterTouchEventForSecurity(ipf.java:115)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2351)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2844)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2461)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2844)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2461)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2844)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2461)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2876)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2461)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2844)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2519)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2844)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2519)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2844)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2519)
at com.android.internal.policy.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2840)
at com.android.internal.policy.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1853)
at android.app.Activity.dispatchTouchEvent(Activity.java:3061)
at com.android.internal.policy.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2801)
at android.view.View.dispatchPointerEvent(View.java:10246)
at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:5447)
at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:5283)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4721)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4774)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4740)
at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4882)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4748)
at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:4939)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4721)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4774)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4740)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4748)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4721)
at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:7429)
at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:7298)
at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:7259)
at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:7539)
at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:185)
at android.os.MessageQueue.nativePollOnce(MessageQueue.java:0)
at android.os.MessageQueue.next(MessageQueue.java:323)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:7325)
at java.lang.reflect.Method.invoke(Method.java:0)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
I know that this issue is not because of code but I need to prevent crashing.
Here is list of devices on which I am facing issue:
Samsung Galaxy J7 (j7elte), 1536MB RAM, Android 6.0
Xiaomi Redmi Note 3 (kenzo), 2048MB RAM, Android 6.0
Lenovo TB3-710F (TB3-710F), 1024MB RAM, Android 5.0
Xiaomi Redmi 3S (land), 2048MB RAM, Android 6.0
LeTV Le 2 (le_s2_ww), 3072MB RAM, Android 6.0
LGE LG Stylus2 4G (ph2), 2048MB RAM, Android 6.0
Infocus M2_3G (G10), 10124MB RAM, Android 4.4
I am not able to reproduce it but there are several things you can try:
If possible try adding android:filterTouchesWhenObscured=false as pellucide suggested from the docs:
Specifies whether to filter touches when the view's window is obscured
by another visible window. When set to true, the view will not receive
touches whenever a toast, dialog or other window appears above the
view's window. Refer to the View security documentation for more
details.
May be a boolean value, such as "true" or "false".
Otherwise, you can try overriding the dispatch method of your root view and place a try catch there, you can use it as a custom Component if needed.
#Override
void dispatchTouchEvent(MotionEvent event){
try{
super.dispatchTouchEvent(event);
}
catch (Exception e){
e.printStackTrace();
}
}
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