xamarin / Xamarin.Forms

Xamarin.Forms is no longer supported. Migrate your apps to .NET MAUI.
https://aka.ms/xamarin-upgrade
Other
5.62k stars 1.87k forks source link

[Bug] [Android] DeepLinking registration is crashing every time in Android with Custom ROMs #6622

Open JTOne123 opened 5 years ago

JTOne123 commented 5 years ago

Description

The issue occurred in AndroidActionFailureListener class in https://github.com/xamarin/Xamarin.Forms/blob/master/Xamarin.Forms.Platform.Android.AppLinks/AndroidAppLinks.cs file

There is no way to catch or override the throwing exception

AndroidAppLinks+AndroidActionFailureListener.OnFailure (Java.Lang.Exception e)
IOnFailureListenerInvoker.n_OnFailure_Ljava_lang_Exception_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_e)
(wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.103(intptr,intptr,intptr)
com.google.firebase.FirebaseApiNotAvailableException: API: AppDataSearch.LIGHTWEIGHT_API is not available on this device.
com.google.firebase.zzb.zzs(Unknown Source:24)
com.google.android.gms.common.api.internal.zze.zzr(Unknown Source:4)
com.google.android.gms.common.api.internal.zzbr.zzv(Unknown Source:27)
com.google.android.gms.common.api.internal.zzbr.onConnectionFailed(Unknown Source:203)
com.google.android.gms.common.internal.zzac.onConnectionFailed(Unknown Source:2)
com.google.android.gms.common.internal.zzn.zzj(Unknown Source:14)
com.google.android.gms.common.internal.zze.zzs(Unknown Source:43)
com.google.android.gms.common.internal.zzi.zzajo(Unknown Source:54)
com.google.android.gms.common.internal.zzh.handleMessage(Unknown Source:275)
android.os.Handler.dispatchMessage(Handler.java:106)
android.os.Looper.loop(Looper.java:164)
android.os.HandlerThread.run(HandlerThread.java:65)

Do we need to extend current AndroidAppLinks.Init method with IOnFailureListener parameter? Maybe you'll suggest another option to fix it?

The same issue in StackOverflow https://stackoverflow.com/questions/54310097/androidapplinks-firebase-firebaseapinotavailableexception-api-appdatasearch/54323277

samhouts commented 5 years ago

@JTOne123 Can you please attach a small project that demonstrates this issue? Thanks!

JTOne123 commented 5 years ago

I guess the project does not have the sense. And I'm not able to reproduce it by myself. I got the error in the AppCenter.

The issue happens on specific devices Here is a list of them

Impress Forest Android 8.1.0 HUAWEI Y3 2018 Android 8.1.0 Galaxy J2 Core Android 8.1.0 Luck Android 8.1.0 Nokia 1 Android 8.1.0 BQ-6010G Android 8.1.0 HUAWEI Y5 lite Android 8.1.0 Galaxy J2 Core Android 8.1.0 Nokia 2.1 Android 9 A15 Android 8.1.0 Redmi Go Android 8.1.0 INNOSR545 Android 8.1.0 Nokia 1 Android 8.1.0 8067 Android 8.1.0 POP 2 Android 8.1.0 Ulefone_S1 Android 8.1.0 Impress_Zeon3G Android 8.1.0 G355 Android 8.1.0 Galaxy J2 Core Android 8.1.0 X50 Android 8.1.0 Voyager Android 8.1.0 Life Play Android 8.1.0 A20 Android 8.1.0 HUAWEI Y5 lite Android 8.1.0

AndroidAppLinks+AndroidActionFailureListener.OnFailure (Java.Lang.Exception e) Firebase.FirebaseApiNotAvailableException: API: AppDataSearch.LIGHTWEIGHT_API is not available on this device.

AndroidAppLinks+AndroidActionFailureListener.OnFailure (Java.Lang.Exception e) IOnFailureListenerInvoker.n_OnFailure_Ljava_lang_Exception_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_e) (wrapper dynamic-method) System.Object.39(intptr,intptr,intptr) com.google.firebase.FirebaseApiNotAvailableException: API: AppDataSearch.LIGHTWEIGHT_API is not available on this device. com.google.firebase.zzb.zzs(Unknown Source:24) com.google.android.gms.common.api.internal.zze.zzr(Unknown Source:4) com.google.android.gms.common.api.internal.zzbr.zzv(Unknown Source:27) com.google.android.gms.common.api.internal.zzbr.onConnectionFailed(Unknown Source:203) com.google.android.gms.common.internal.zzac.onConnectionFailed(Unknown Source:2) com.google.android.gms.common.internal.zzn.zzj(Unknown Source:14) com.google.android.gms.common.internal.zze.zzs(Unknown Source:43) com.google.android.gms.common.internal.zzi.zzajo(Unknown Source:54) com.google.android.gms.common.internal.zzh.handleMessage(Unknown Source:275) android.os.Handler.dispatchMessage(Handler.java:106) android.os.Looper.loop(Looper.java:164) android.os.HandlerThread.run(HandlerThread.java:65)

EmilAlipiev commented 5 years ago

Repro is the Code in the stackoverflow issue. It is also not possible to reproduce is on any device or emulator because with official android releases it works fine but if you use any custom rom like mentioned in the SO, carbonrom this issue occurs. You may claim that we dont need to consider custom roms but yes we must. Many people use custom rom and we can't just ignore them. As mentioned in the SO issue, I would just ignore those custom roms with a simple try catch but it doesnt work. Crash is not possible to handle, it crashes the application and exists. Just because of this problem, I had to remove deeplinking from my app.

samhouts commented 5 years ago

We'll mark this as a verified issue, but we'll also mark it as up-for-grabs. We'll need someone with a custom rom to help us implement the fix. Thanks!

sereoja commented 4 years ago

any solution on this issue? just got similar crash in AppCenter

Android: 9 Android Build: P00610 Manufacturer: TINNO Model: U304AA Start Date: 2020-05-18T17:04:00.818Z Date: 2020-05-18T17:04:47.65Z

Xamarin Exception Stack: Java.Lang.Exception: API: AppDataSearch.LIGHTWEIGHT_API is not available on this device. at Xamarin.Forms.Platform.Android.AppLinks.AndroidAppLinks+AndroidActionFailureListener.OnFailure (Java.Lang.Exception e) [0x0002c] in <5355c1ce136e42b1b38816d063c1c041>:0 at Android.Gms.Tasks.IOnFailureListenerInvoker.n_OnFailure_Ljava_langException (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_e) [0x0000f] in <49003930fe3b4401afa0c27d7130d13d>:0 at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.140(intptr,intptr,intptr) at com.google.firebase.FirebaseApiNotAvailableException: API: AppDataSearch.LIGHTWEIGHT_API is not available on this device. at com.google.firebase.FirebaseExceptionMapper.getException(Unknown Source:4) at com.google.android.gms.common.api.internal.zag.zaa(Unknown Source:15) at com.google.android.gms.common.api.internal.GoogleApiManager$zaa.zac(Unknown Source:175) at com.google.android.gms.common.api.internal.GoogleApiManager$zaa.onConnectionFailed(Unknown Source:95) at com.google.android.gms.common.internal.zag.onConnectionFailed(Unknown Source:2) at com.google.android.gms.common.internal.BaseGmsClient$zzf.zza(Unknown Source:6) at com.google.android.gms.common.internal.BaseGmsClient$zza.zza(Unknown Source:25) at com.google.android.gms.common.internal.BaseGmsClient$zzc.zzo(Unknown Source:11) at com.google.android.gms.common.internal.BaseGmsClient$zzb.handleMessage(Unknown Source:49) at android.os.Handler.dispatchMessage(Handler.java:106) at com.google.android.gms.internal.common.zze.dispatchMessage(Unknown Source:8) at android.os.Looper.loop(Looper.java:193) at android.os.HandlerThread.run(HandlerThread.java:65)

Thread 2: 0 dalvik.system.VMStack.getThreadStackTrace(VMStack.java:-2) 1 java.lang.Thread.getStackTrace(Thread.java:1538) 2 java.lang.Thread.getAllStackTraces(Thread.java:1588) 3 com.microsoft.appcenter.crashes.Crashes.saveUncaughtException(Crashes.java:1137) 4 com.microsoft.appcenter.crashes.WrapperSdkExceptionManager.saveWrapperException(WrapperSdkExceptionManager.java:58) 5 crc64cc97b39ab5a7447d.AndroidAppLinks_AndroidActionFailureListener.n_onFailure(AndroidAppLinks_AndroidActionFailureListener.java:-2) 6 crc64cc97b39ab5a7447d.AndroidAppLinks_AndroidActionFailureListener.onFailure(AndroidAppLinks_AndroidActionFailureListener.java:30) 7 com.google.android.gms.tasks.zzl.run 8 android.os.Handler.handleCallback(Handler.java:873) 9 android.os.Handler.dispatchMessage(Handler.java:99) 10 android.os.Looper.loop(Looper.java:193) 11 android.app.ActivityThread.main(ActivityThread.java:6725) 12 java.lang.reflect.Method.invoke(Method.java:-2) 13 com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) 14 com.android.internal.os.ZygoteInit.main(ZygoteInit.java:911)

Thread 978: 0 java.lang.Object.wait(Object.java:-2) 1 java.lang.Daemons$ReferenceQueueDaemon.runInternal(Daemons.java:180) 2 java.lang.Daemons$Daemon.run(Daemons.java:105) 3 java.lang.Thread.run(Thread.java:764)

Thread 979: 0 java.lang.Object.wait(Object.java:-2) 1 java.lang.Object.wait(Object.java:422) 2 java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:188) 3 java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:209) 4 java.lang.Daemons$FinalizerDaemon.runInternal(Daemons.java:234) 5 java.lang.Daemons$Daemon.run(Daemons.java:105) 6 java.lang.Thread.run(Thread.java:764)

Thread 980: 0 java.lang.Thread.sleep(Thread.java:-2) 1 java.lang.Thread.sleep(Thread.java:373) 2 java.lang.Thread.sleep(Thread.java:314) 3 java.lang.Daemons$FinalizerWatchdogDaemon.sleepFor(Daemons.java:344) 4 java.lang.Daemons$FinalizerWatchdogDaemon.waitForFinalization(Daemons.java:366) 5 java.lang.Daemons$FinalizerWatchdogDaemon.runInternal(Daemons.java:283) 6 java.lang.Daemons$Daemon.run(Daemons.java:105) 7 java.lang.Thread.run(Thread.java:764)

Thread 989: 0 java.lang.Object.wait(Object.java:-2) 1 java.lang.Object.wait(Object.java:422) 2 com.google.android.gms.measurement.internal.zzbv.run

Thread 992: 0 java.lang.Object.wait(Object.java:-2) 1 java.lang.Thread.parkFor$(Thread.java:2137) 2 sun.misc.Unsafe.park(Unsafe.java:358) 3 java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:230) 4 java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2101) 5 java.util.concurrent.LinkedBlockingQueue.poll(LinkedBlockingQueue.java:467) 6 java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1091) 7 java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1152) 8 java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) 9 java.lang.Thread.run(Thread.java:764)

Thread 994: 0 java.lang.Object.wait(Object.java:-2) 1 java.lang.Thread.parkFor$(Thread.java:2137) 2 sun.misc.Unsafe.park(Unsafe.java:358) 3 java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:230) 4 java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2101) 5 java.util.concurrent.LinkedBlockingQueue.poll(LinkedBlockingQueue.java:467) 6 java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1091) 7 java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1152) 8 java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) 9 java.lang.Thread.run(Thread.java:764)

Thread 995: 0 java.lang.Object.wait(Object.java:-2) 1 java.lang.Thread.parkFor$(Thread.java:2137) 2 sun.misc.Unsafe.park(Unsafe.java:358) 3 java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:230) 4 java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2101) 5 java.util.concurrent.LinkedBlockingQueue.poll(LinkedBlockingQueue.java:467) 6 java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1091) 7 java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1152) 8 java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) 9 java.lang.Thread.run(Thread.java:764)

Thread 998: 0 android.os.MessageQueue.nativePollOnce(MessageQueue.java:-2) 1 android.os.MessageQueue.next(MessageQueue.java:326) 2 android.os.Looper.loop(Looper.java:160) 3 android.os.HandlerThread.run(HandlerThread.java:65)

Thread 1000: 0 java.lang.Object.wait(Object.java:-2) 1 com.android.okhttp.ConnectionPool$1.run(ConnectionPool.java:101) 2 java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) 3 java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) 4 java.lang.Thread.run(Thread.java:764)

Thread 1001: 0 java.lang.Object.wait(Object.java:-2) 1 java.lang.Thread.parkFor$(Thread.java:2137) 2 sun.misc.Unsafe.park(Unsafe.java:358) 3 java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:230) 4 java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2101) 5 java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1132) 6 java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:849) 7 java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1092) 8 java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1152) 9 java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) 10 java.lang.Thread.run(Thread.java:764)

Thread 1004: 0 java.lang.Object.wait(Object.java:-2) 1 java.lang.Thread.parkFor$(Thread.java:2137) 2 sun.misc.Unsafe.park(Unsafe.java:358) 3 java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:230) 4 java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2101) 5 java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1132) 6 java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:849) 7 java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1092) 8 java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1152) 9 java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) 10 java.lang.Thread.run(Thread.java:764)

Thread 1005: 0 java.lang.Object.wait(Object.java:-2) 1 java.lang.Thread.parkFor$(Thread.java:2137) 2 sun.misc.Unsafe.park(Unsafe.java:358) 3 java.util.concurrent.locks.LockSupport.park(LockSupport.java:190) 4 java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2059) 5 java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1120) 6 java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:849) 7 java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1092) 8 java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1152) 9 java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) 10 java.lang.Thread.run(Thread.java:764)

Thread 1016: 0 android.os.MessageQueue.nativePollOnce(MessageQueue.java:-2) 1 android.os.MessageQueue.next(MessageQueue.java:326) 2 android.os.Looper.loop(Looper.java:160) 3 android.os.HandlerThread.run(HandlerThread.java:65)

Thread 1018: 0 android.os.MessageQueue.nativePollOnce(MessageQueue.java:-2) 1 android.os.MessageQueue.next(MessageQueue.java:326) 2 android.os.Looper.loop(Looper.java:160) 3 android.os.HandlerThread.run(HandlerThread.java:65)

Thread 1021: 0 java.lang.Object.wait(Object.java:-2) 1 com.android.okhttp.okio.AsyncTimeout.awaitTimeout(AsyncTimeout.java:311) 2 com.android.okhttp.okio.AsyncTimeout.access$000(AsyncTimeout.java:40) 3 com.android.okhttp.okio.AsyncTimeout$Watchdog.run(AsyncTimeout.java:286)

Thread 1023: 0 android.os.MessageQueue.nativePollOnce(MessageQueue.java:-2) 1 android.os.MessageQueue.next(MessageQueue.java:326) 2 android.os.Looper.loop(Looper.java:160) 3 android.os.HandlerThread.run(HandlerThread.java:65)

Thread 1036: 0 android.os.MessageQueue.nativePollOnce(MessageQueue.java:-2) 1 android.os.MessageQueue.next(MessageQueue.java:326) 2 android.os.Looper.loop(Looper.java:160) 3 android.os.HandlerThread.run(HandlerThread.java:65)

EmilAlipiev commented 4 years ago

I think, unfortunately, you will not get a solution here as you can see that it is pretty old issue. Better to remove deeplink in meantime if it is not so important for you. Thats what i have done :(

JTOne123 commented 4 years ago

@sereoja Can you reproduce it on your local devices?

sereoja commented 4 years ago

@sereoja Can you reproduce it on your local devices?

Unfortunately no, The report came from a user via AppCenter.

EmilAlipiev commented 4 years ago

well, as i wrote above, it is only reproducible with the custom Android Rom. I have an old Sony Xperia and installed that CarbonRom (any other customRom works also), i can reproduce it but not with official Roms.

JTOne123 commented 4 years ago

@EmilAlipiev I know it

Maybe can you fix it in Xamarin.Forms?

Did you try download XF repo and run it on your sony device?