Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

FormsAppCompatActivity.OnDestroy occasionally throws "No view found for id" exception for Android N devices #1490

Closed
jonpryor opened this issue Jan 2, 2018 · 14 comments
Assignees
Labels
e/7 🕖 7 i/high Completely doesn't work, crashes, or is unusably slow, has no obvious workaround; occurs less often m/high impact ⬛ p/Android s/needs-info ❓ A question has been asked that requires an answer before work can continue on this issue. t/bug 🐛

Comments

@jonpryor
Copy link
Member

jonpryor commented Jan 2, 2018

Bug report best practices: https://github.com/xamarin/Xamarin.Forms/wiki/Submitting-Issues

From: dotnet/android#1143

Description

FormsAppCompatActivity.OnDestroy() occasionally throws "No view found for id" exception for Android N devices

Java.Interop.JniEnvironment No view found for id 0x1 (unknown) for fragment FragmentContainer{460ecc1 #1 id=0x1}
Raw
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()<b5f2483a551b45a99f04c68f14fc2c14>:0
Java.Interop.JniEnvironment.InstanceMethods.CallNonvirtualVoidMethod(JniObjectReference instance, JniObjectReference type, JniMethodInfo method, JniArgumentValue* args)<eba4edc4e27949518f7bf237cb1196cc>:0
Java.Interop.JniPeerMembers.JniInstanceMethods.InvokeVirtualVoidMethod(string encodedMember, IJavaPeerable self, JniArgumentValue* parameters)<eba4edc4e27949518f7bf237cb1196cc>:0
Android.App.Activity.OnDestroy()<bec3773976364d6f966ebdab5e7a8df3>:0
Xamarin.Forms.Platform.Android.FormsAppCompatActivity.OnDestroy()<8d6936257ac5419f8be9df07a9bb5129>:0
iSurvey.Android.MainActivity.OnDestroy()<8d9b18b497204292ba1e24a705032810>:0
Android.App.Activity.n_OnDestroy(IntPtr jnienv, IntPtr native__this)<bec3773976364d6f966ebdab5e7a8df3>:0
at (wrapper dynamic-method) System.Object:ee7a2513-7ba6-47d4-b295-16c9cfe08d94 (intptr,intptr)
--- End of managed Java.Lang.IllegalArgumentException stack trace ---
java.lang.IllegalArgumentException: No view found for id 0x1 (unknown) for fragment FragmentContainer{460ecc1 #1 id=0x1}
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1334)
at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1569)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1636)
at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:758)
at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2415)
at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2201)
at android.support.v4.app.FragmentManagerImpl.optimizeAndExecuteOps(FragmentManager.java:2155)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2064)
at android.support.v4.app.FragmentManagerImpl.dispatchDestroy(FragmentManager.java:3026)
at android.support.v4.app.FragmentController.dispatchDestroy(FragmentController.java:262)
at android.support.v4.app.FragmentActivity.onDestroy(FragmentActivity.java:390)
at android.support.v7.app.AppCompatActivity.onDestroy(AppCompatActivity.java:209)
iSurvey.Android.MainActivity.n_onDestroy(Native Method)
at iSurvey.Android.MainActivity.onDestroy(MainActivity.java:114)
at android.app.Activity.performDestroy(Activity.java:6959)
at android.app.Instrumentation.callActivityOnDestroy(Instrumentation.java:1154)
at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:4289)
at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:4320)
at android.app.ActivityThread.-wrap6(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6310)
java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:872)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:762)

Steps to Reproduce

I could not reproduce this from our development environment. We've received infrequent and non-critical reports from our bug reporting.

Expected Behavior

  • App gracefully closes

Actual Behavior

  • App crashes with the below exception

Basic Information

  • Version with issue: 2.4.0.38779 through 2.5.0.91635
  • Last known good version:
  • IDE:
  • Platform Target Frameworks:
    • Android: N (7.x)
  • Android Support Library Version:
  • Nuget Packages:
  • Affected Devices: Galaxy S7, S7 Edge, S8, S8+, Galaxy Note 5, LG Aristo, G6, Stylo 3
@Kizari
Copy link

Kizari commented Feb 27, 2018

Having this issue as well.

Seems to occur consistently when certain devices manually close the app (i.e. open the running processes drawer and swipe the app away), which leads me to believe it is related to OnDestroy in this instance as well. Users have a bad habit of doing this which in turn crashes the app and stops the background work from functioning as expected, leading to a poor user experience.

Fatal Exception: java.lang.IllegalArgumentException: No view found for id 0x16 (unknown) for fragment FragmentContainer{2662dddb #0 id=0x16} at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1413) at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1740) at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1809) at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:799) at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2580) at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2367) at android.support.v4.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2322) at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2229) at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:700) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:145) at android.app.ActivityThread.main(ActivityThread.java:6947) at java.lang.reflect.Method.invoke(Method.java) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)

@jassmith
Copy link

Is anyone able to get this in 3.1.0?

@pgrho
Copy link

pgrho commented Jun 26, 2018

Our application is getting this Exception in 3.1.0 https://github.com/kokoro-io/kokoro-io-app

@PureWeen
Copy link
Contributor

@pgrho I'm able to run your sample but can you tell me a login/pwd I can use or steps I can take to see the exception?

@PureWeen PureWeen assigned PureWeen and unassigned hartez Jun 26, 2018
@PureWeen PureWeen added the s/needs-info ❓ A question has been asked that requires an answer before work can continue on this issue. label Jun 26, 2018
@pgrho
Copy link

pgrho commented Jun 27, 2018

@PureWeen

  1. Log in the app using test@kokoro.io / ItIsATest
  2. Open menu
  3. Choose any channel such as #private/unit-test
  4. Launch another app.
  5. And reactivate the app by home icon (or notification).

The Exception will be thrown in the 5th step, but the frequency depends on the device.

FYI: This app is normally installed from appcenter.ms

@PureWeen PureWeen removed the s/needs-info ❓ A question has been asked that requires an answer before work can continue on this issue. label Jun 27, 2018
@PureWeen
Copy link
Contributor

@pgrho that's not working for me

image

@pgrho
Copy link

pgrho commented Jun 27, 2018

@PureWeen Sorry, it seems to be a unknown server bug. Please retry the steps.

Or use appcenter.ms with following:

  1. Register your account https://purivideo.jp/appcenter
  2. Launch Chrome in Android Device and browse to https://install.appcenter.ms
  3. Install the kokoro.io-Android-app

@PureWeen
Copy link
Contributor

Hmm it's still not quite working for me @pgrho

If you could provide a minimal repro or mod the application in some way where login isn't needed so I can see the exception that would be helpful

@PureWeen PureWeen added the s/needs-info ❓ A question has been asked that requires an answer before work can continue on this issue. label Jun 29, 2018
@PureWeen
Copy link
Contributor

@pgrho if possible can you test against the attached pre-release nuget and let me know if you still see the same problem?

3.3.0.zip

@pgrho
Copy link

pgrho commented Jul 14, 2018

@PureWeen I got IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity on FormsAppCompatActivity#OnCreate(Bundle) and can't launch the app with 3.3.0

@PureWeen
Copy link
Contributor

@pgrho you might need to delete your bin/obj folders after updating and make sure to restart VS

I installed the nuget package into your project and was able to launch it without any issues

@pgrho
Copy link

pgrho commented Jul 15, 2018

@PureWeen 3.3.0 seems to be fine on reactivating the app.

@PureWeen
Copy link
Contributor

@pgrho awesome!!!

@samhouts samhouts added i/high Completely doesn't work, crashes, or is unusably slow, has no obvious workaround; occurs less often m/high impact ⬛ e/7 🕖 7 and removed i/critical labels Jul 23, 2018
@StephaneDelcroix
Copy link
Member

this should have been closed when merging #3187

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
e/7 🕖 7 i/high Completely doesn't work, crashes, or is unusably slow, has no obvious workaround; occurs less often m/high impact ⬛ p/Android s/needs-info ❓ A question has been asked that requires an answer before work can continue on this issue. t/bug 🐛
Projects
None yet
Development

No branches or pull requests

8 participants