java.lang.IllegalStateException crash only on Android TV devices - androidx

I see quite a few crashes of the following only on Android TV devices:
java.lang.IllegalStateException
androidx.appcompat.app.AppCompatViewInflater$DeclaredOnClickListener.resolveMethod
java.lang.IllegalStateException:
at androidx.appcompat.app.AppCompatViewInflater$DeclaredOnClickListener.resolveMethod (AppCompatViewInflater.java:479)
at androidx.appcompat.app.AppCompatViewInflater$DeclaredOnClickListener.onClick (AppCompatViewInflater.java:437)
at android.view.View.performClick (View.java:6597)
at android.view.View.performClickInternal (View.java:6574)
at android.view.View.onKeyUp (View.java:13216)
at android.view.KeyEvent.dispatch (KeyEvent.java:2734)
at android.view.View.dispatchKeyEvent (View.java:12450)
at android.view.ViewGroup.dispatchKeyEvent (ViewGroup.java:1896)
at android.view.ViewGroup.dispatchKeyEvent (ViewGroup.java:1896)
at android.view.ViewGroup.dispatchKeyEvent (ViewGroup.java:1896)
at android.view.ViewGroup.dispatchKeyEvent (ViewGroup.java:1896)
at android.view.ViewGroup.dispatchKeyEvent (ViewGroup.java:1896)
at android.view.ViewGroup.dispatchKeyEvent (ViewGroup.java:1896)
at android.view.ViewGroup.dispatchKeyEvent (ViewGroup.java:1896)
at android.view.ViewGroup.dispatchKeyEvent (ViewGroup.java:1896)
at android.view.ViewGroup.dispatchKeyEvent (ViewGroup.java:1896)
at android.view.ViewGroup.dispatchKeyEvent (ViewGroup.java:1896)
at com.android.internal.policy.DecorView.superDispatchKeyEvent (DecorView.java:428)
at com.android.internal.policy.PhoneWindow.superDispatchKeyEvent (PhoneWindow.java:1820)
at android.app.Activity.dispatchKeyEvent (Activity.java:3361)
at androidx.core.app.ComponentActivity.superDispatchKeyEvent (ComponentActivity.java:122)
at androidx.core.view.KeyEventDispatcher.dispatchKeyEvent (KeyEventDispatcher.java:84)
at androidx.core.app.ComponentActivity.dispatchKeyEvent (ComponentActivity.java:140)
at androidx.appcompat.app.AppCompatActivity.dispatchKeyEvent (AppCompatActivity.java:599)
at androidx.appcompat.view.WindowCallbackWrapper.dispatchKeyEvent (WindowCallbackWrapper.java:59)
at androidx.appcompat.app.AppCompatDelegateImpl$AppCompatWindowCallback.dispatchKeyEvent (AppCompatDelegateImpl.java:3090)
at com.android.internal.policy.DecorView.dispatchKeyEvent (DecorView.java:342)
at android.view.ViewRootImpl$ViewPostImeInputStage.processKeyEvent (ViewRootImpl.java:5045)
at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess (ViewRootImpl.java:4913)
at android.view.ViewRootImpl$InputStage.deliver (ViewRootImpl.java:4434)
at android.view.ViewRootImpl$InputStage.onDeliverToNext (ViewRootImpl.java:4487)
at android.view.ViewRootImpl$InputStage.forward (ViewRootImpl.java:4453)
at android.view.ViewRootImpl$AsyncInputStage.forward (ViewRootImpl.java:4593)
at android.view.ViewRootImpl$InputStage.apply (ViewRootImpl.java:4461)
at android.view.ViewRootImpl$AsyncInputStage.apply (ViewRootImpl.java:4650)
at android.view.ViewRootImpl$InputStage.deliver (ViewRootImpl.java:4434)
at android.view.ViewRootImpl$InputStage.onDeliverToNext (ViewRootImpl.java:4487)
at android.view.ViewRootImpl$InputStage.forward (ViewRootImpl.java:4453)
at android.view.ViewRootImpl$InputStage.apply (ViewRootImpl.java:4461)
at android.view.ViewRootImpl$InputStage.deliver (ViewRootImpl.java:4434)
at android.view.ViewRootImpl$InputStage.onDeliverToNext (ViewRootImpl.java:4487)
at android.view.ViewRootImpl$InputStage.forward (ViewRootImpl.java:4453)
at android.view.ViewRootImpl$AsyncInputStage.forward (ViewRootImpl.java:4626)
at android.view.ViewRootImpl$ImeInputStage.onFinishedInputEvent (ViewRootImpl.java:4787)
at android.view.inputmethod.InputMethodManager$PendingEvent.run (InputMethodManager.java:2571)
at android.view.inputmethod.InputMethodManager.invokeFinishedInputEventCallback (InputMethodManager.java:2081)
at android.view.inputmethod.InputMethodManager.finishedInputEvent (InputMethodManager.java:2072)
at android.view.inputmethod.InputMethodManager$ImeInputEventSender.onInputEventFinished (InputMethodManager.java:2548)
at android.view.InputEventSender.dispatchInputEventFinished (InputEventSender.java:141)
at android.os.MessageQueue.nativePollOnce (Native Method)
at android.os.MessageQueue.next (MessageQueue.java:326)
at android.os.Looper.loop (Looper.java:160)
at android.app.ActivityThread.main (ActivityThread.java:6718)
at java.lang.reflect.Method.invoke (Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:858)
Since there are a lot of Android TV devices running the app, the crash is still rare. The stack trace does in indicate any app's source code, so I am clueless about the crash now.
I wonder if anyone could shed some light on this crash to point me in the right direction in searching for the culprit.
The following charts show the devices with this crash:

I'm not sure what logging system you're using to aggregate the crashes, but if you are able to look at a single instance of it, the IllegalStateException should tell you the method name, view type, and ID where this is happening.
If that's not available to you, you'll want to look for instances of android:onClick in your XML files. AppCompatViewInflater uses reflection to find the method to trigger, but this is done lazily since reflection is expensive. In other words, you'll have something like android:onClick="handleMyClick" in an XML layout. When the user triggers the click, AppCompatViewInflater attempts to find a handleMyClick(view) method with the given Context, working through any ContextWrappers until it finds a matching method. If it doesn't find one that matches, it throws the exception you're seeing.
The most likely culprit is that there is an Activity for mobile that implements the onClick method declared in the XML layout and an Activity for TV that does not. Another option is that the View with the onClick attribute is only easily/obviously accessible via a dpad.

Related

Saucelabs session is not closing properly

Even though my test script has run successfully, I'm getting an error saying Error closing result stream.
Below is the body of error:
com.saucelabs.saucerest.SauceREST closeInputStream
WARNING: Error closing result stream
java.io.FileNotFoundException: https://saucelabs.com/rest/v1/myuser/jobs/ef4505aca4cf4c32a08d5d6c425fbf57
at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1915)
at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1515)
at java.base/sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:251)
at com.saucelabs.saucerest.SauceREST.closeInputStream(SauceREST.java:700)
at com.saucelabs.saucerest.SauceREST.updateJobInfo(SauceREST.java:643)
at com.saucelabs.junit.SauceOnDemandTestWatcher.succeeded(SauceOnDemandTestWatcher.java:95)
at org.junit.rules.TestWatcher.succeededQuietly(TestWatcher.java:75)
at org.junit.rules.TestWatcher.access$100(TestWatcher.java:46)
at org.junit.rules.TestWatcher$1.evaluate(TestWatcher.java:56)
at org.junit.rules.RunRules.evaluate(RunRules.java:20)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at com.saucelabs.junit.ConcurrentParameterized$SauceClassRunnerForParameters.access$300(ConcurrentParameterized.java:166)
at com.saucelabs.junit.ConcurrentParameterized$SauceClassRunnerForParameters$2.run(ConcurrentParameterized.java:283)
at com.saucelabs.junit.ConcurrentParameterized$NonBlockingAsynchronousRunner$1.call(ConcurrentParameterized.java:308)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:835)
The most common reason for this is when you're changing job status while it's still running (or has just been closed).
Does it happen consistently? If you add a pause before calling the API or a single retry, do you still see this happen?

How can I track the execution flow inside Spring using the logs, to understand its inner workings?

I was trying to see the execution flow inside Spring framework, using the logs printed to the console. The aim was to understand the inner working of Spring framework a little bit. I set the logging level to ALL in my application. Following lines are printed in the logs:
2013-07-04 14:46:34 TRACE DispatcherServlet:1018 - Bound request context to thread: org.apache.catalina.connector.RequestFacade#13dd208
2013-07-04 14:46:34 DEBUG DispatcherServlet:823 - DispatcherServlet with name 'web' processing GET request for [/webtemplate/]
2013-07-04 14:46:34 TRACE DispatcherServlet:1088 - Testing handler map [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping#fedfb6] in DispatcherServlet with name 'web'
2013-07-04 14:46:34 DEBUG RequestMappingHandlerMapping:220 - Looking up handler method for path /
2013-07-04 14:46:34 TRACE RequestMappingHandlerMapping:264 - Found 1 matching mapping(s) for [/] : [{[/],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}]
2013-07-04 14:46:34 DEBUG RequestMappingHandlerMapping:227 - Returning handler method [public java.lang.String com.lister.custom.webtemplate.controller.MainController.index(org.springframework.ui.ModelMap)]
2013-07-04 14:46:34 DEBUG DefaultListableBeanFactory:246 - Returning cached instance of singleton bean 'mainController'
2013-07-04 14:46:34 TRACE DispatcherServlet:1122 - Testing handler adapter [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter#771eb1]
I checked the source file(?) and the line number that were printed in all the lines:
DispatcherServlet:823
DispatcherServlet:1018
RequestMappingHandlerMapping:220
etc...
in an effort to see what was going on inside.
But, in most cases, I was not able to find any relevant code in the respective line numbers. Many had just comments at those line numbers.
Of the above log lines, only DispatcherServlet:823 had the actual code that printed the log.
How can I use the logs (DEBUG and TRACE) to track the execution flow inside Spring?
Note:
The versions of both the binary used by my application and the source I am checking are the same - 3.2.3.RELEASE
Following is my logger pattern: log4j.appender.console.layout.ConversionPattern = %d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n if it helps.
You need to check the superclass as well. Eg:
2013-07-04 14:46:34 TRACE DispatcherServlet:1018 - Bound request context to thread: org.apache.catalina.connector.RequestFacade#13dd208
Is actually made by FrameworkServlet class line 1018.
Maybe you should configure your log4j logger to also spit out the fully qualified class name (not just the logger name):
%d{yyyy-MM-dd HH:mm:ss} %-5p %C{1}:%L - %m%n
(notice uppercase C instead of c)

Flying Saucer and CSS

When using flying saucer to convert to xhtml to PDF, I'm getting the following exception:
java.io.IOException: Stream closed
at java.io.BufferedInputStream.getInIfOpen(Unknown Source)
at java.io.BufferedInputStream.read1(Unknown Source)
at java.io.BufferedInputStream.read(Unknown Source)
at sun.nio.cs.StreamDecoder.readBytes(Unknown Source)
at sun.nio.cs.StreamDecoder.implRead(Unknown Source)
at sun.nio.cs.StreamDecoder.read(Unknown Source)
at java.io.InputStreamReader.read(Unknown Source)
at org.xhtmlrenderer.css.parser.Lexer.zzRefill(Lexer.java:1634)
at org.xhtmlrenderer.css.parser.Lexer.yylex(Lexer.java:1865)
at org.xhtmlrenderer.css.parser.CSSParser.next(CSSParser.java:1778)
at org.xhtmlrenderer.css.parser.CSSParser.la(CSSParser.java:1790)
at org.xhtmlrenderer.css.parser.CSSParser.stylesheet(CSSParser.java:157)
at org.xhtmlrenderer.css.parser.CSSParser.parseStylesheet(CSSParser.java:87)
at org.xhtmlrenderer.context.StylesheetFactoryImpl.parse(StylesheetFactoryImpl.java:78)
at org.xhtmlrenderer.context.StylesheetFactoryImpl.parse(StylesheetFactoryImpl.java:95)
atorg.xhtmlrenderer.context.StylesheetFactoryImpl.getStylesheet(StylesheetFactoryImpl.java:174)
at org.xhtmlrenderer.context.StyleReference.readAndParseAll(StyleReference.java:123)
at org.xhtmlrenderer.context.StyleReference.setDocumentContext(StyleReference.java:107)
at org.xhtmlrenderer.pdf.ITextRenderer.setDocument(ITextRenderer.java:175)
at org.xhtmlrenderer.pdf.ITextRenderer.setDocument(ITextRenderer.java:142)
I was able to view the content of the css file through the link: https ://.../file.css and I have create a keystore and certificate in JBOSS server and made sure ssl.conf is pointing to them (redhat). It seems there is an issue maybe with https, but have no idea how to tackle this. Has anyone experienced this issue before?
Thanks,
--Abdul
It's too late, but someone else may found it useful. Here's how I solved my issue:
Turned on the Logging (Turning on Flying Saucer java.util.logging Output)
System.getProperties().setProperty("xr.util-logging.loggingEnabled", "true");
XRLog.setLoggingEnabled(true);
Read the org.xhtmlrenderer.swing.NaiveUserAgent logs for
public String resolveURI (String uri){
/**/
}
(If you can remote debug it/run JBoss locally - put a breakpoint there and you'll see all the font/resource/css loading)
In my case it turned out the baseURL is wrong for the renderer. You can pass it to renderer while parsing document.
renderer.setDocumentFromString(generatedHtml, getBaseUrl());
And to get the valid baseURL on my env I've used:
"jndi:"+servletContext.getResource("/").getPath()
(turned out you actually can access static files in the deployed war with this "jndi:" prefix.)

Android SDK MonkeyRunner broken?

I've been having some troubles gettin MonkeyRunner working. So far, we've tried 3 different computers and every android device we could get our hands on.
the result is the same:
com.android.monkeyrunner.MonkeyRunnerStarter.main(MonkeyRunnerStarter.java:203)
110715 16:59:55.819:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions] Script
terminated due to an exception
110715 16:59:55.819:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions]Traceback
(most recent call last):
File "/Users/lorinbeer/projects/phonegapminer/monkeyrun.py", line 10, in <module>
device = MonkeyRunner.waitForConnection()
at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:182)
at com.android.monkeyrunner.adb.AdbMonkeyDevice.<init>(AdbMonkeyDevice.java:68)
at com.android.monkeyrunner.adb.AdbBackend.waitForConnection(AdbBackend.java:100)
at com.android.monkeyrunner.MonkeyRunner.waitForConnection(MonkeyRunner.java:78)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
java.lang.NullPointerException: java.lang.NullPointerException
This is running on osx, the phone is a Nexus S.
The python looks like:
from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice
device = MonkeyRunner.waitForConnection()
I've tried this from a .py file, as well as from the interactive interpreter. I've also tried calling waitForConnection with the timeout and device id arguments, all with the same results.
Any help is appreciated, thanks!
--UPDATE--
The device is connected, on, and enabled for development. The issue with monkeyrunner seems to be limited to osx, and might have to do with jdk on osx, and might not be an issue with monkeyrunner itself.
Please verify your device 'USB debugging' is set to true.
You would find it under:
settings->application->development
type "adb devices" command in terminal
if it lists any device, then Monkeyrunner.waitForConnection() should not fail.
if device not listed, check if the usb driver is installed properly.

StackOverflowError while Refactoring

I'm trying to refactor a package name (pretty near the root of the project hierarchy), and I'm getting the following error (flash builder 4):
A fatal error occurred while performing the refactoring
An unexpected exception occurred while creating a change object. See the error log for more details.
The log file looks like this....
!ENTRY org.eclipse.ltk.ui.refactoring 4 10000 2010-09-30 10:57:25.134
!MESSAGE Internal Error
!STACK 0
java.lang.reflect.InvocationTargetException
at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:421)
at org.eclipse.ltk.internal.ui.refactoring.RefactoringWizardDialog2.run(RefactoringWizardDialog2.java:330)
at org.eclipse.ltk.ui.refactoring.RefactoringWizard.createChange(RefactoringWizard.java:583)
at org.eclipse.ltk.ui.refactoring.RefactoringWizard.computeUserInputSuccessorPage(RefactoringWizard.java:422)
at org.eclipse.ltk.ui.refactoring.UserInputWizardPage.computeSuccessorPage(UserInputWizardPage.java:74)
at org.eclipse.ltk.ui.refactoring.UserInputWizardPage.getNextPage(UserInputWizardPage.java:114)
at org.eclipse.ltk.internal.ui.refactoring.RefactoringWizardDialog2.nextOrPreviewPressed(RefactoringWizardDialog2.java:495)
at org.eclipse.ltk.internal.ui.refactoring.RefactoringWizardDialog2.access$2(RefactoringWizardDialog2.java:492)
at org.eclipse.ltk.internal.ui.refactoring.RefactoringWizardDialog2$1.widgetSelected(RefactoringWizardDialog2.java:691)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:228)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1003)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3880)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3473)
at org.eclipse.jface.window.Window.runEventLoop(Window.java:825)
at org.eclipse.jface.window.Window.open(Window.java:801)
at org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation$1.run(RefactoringWizardOpenOperation.java:143)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
at org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation.run(RefactoringWizardOpenOperation.java:155)
at com.adobe.flexbuilder.as.editor.ui.navigator.FlexPackageExplorerRenameAction.renamePackage(FlexPackageExplorerRenameAction.java:171)
at com.adobe.flexbuilder.as.editor.ui.navigator.FlexPackageExplorerRenameAction.run(FlexPackageExplorerRenameAction.java:143)
at org.eclipse.ui.actions.BaseSelectionListenerAction.runWithEvent(BaseSelectionListenerAction.java:168)
at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:584)
at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:501)
at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:411)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1003)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3880)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3473)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2405)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2369)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2221)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:500)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:493)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at com.adobe.flexbuilder.standalone.FlexBuilderApplication.start(FlexBuilderApplication.java:109)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:194)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:368)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:559)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:514)
at org.eclipse.equinox.launcher.Main.run(Main.java:1311)
Caused by: java.lang.StackOverflowError
at com.adobe.flexbuilder.codemodel.mxml.MXMLData$2.getMXMLVersion(MXMLData.java:501)
<-- snipped 1022 additional identical lines..-->
at com.adobe.flexbuilder.codemodel.mxml.MXMLData$2.getMXMLVersion(MXMLData.java:501)
Root exception:
java.lang.StackOverflowError
at com.adobe.flexbuilder.codemodel.mxml.MXMLData$2.getMXMLVersion(MXMLData.java:501)
<-- snipped 1022 additional identical lines..-->
at com.adobe.flexbuilder.codemodel.mxml.MXMLData$2.getMXMLVersion(MXMLData.java:501)
Any ideas what is wrong...and what I can do to fix it ? I queried google for it, and didn't turn up anything useful with the parameters I tried.
You can try to Restart Eclipse. Oddly that fixes a number of issues in Eclipse that happen all of a sudden with no normal explanation.
Increase the thread size of the JVM you run your IDE in?
I believe in Eclipse you could do it by adding -Xss with some value to eclipse.ini within your Eclipse installation. The setting is a JVM setting so should be added in the -vmargs section, it might be next to -Xmx which is there by default.
This may not be the best answer, but..I recommend you to try a different IDE like IntelliJ.
I've used Flash Builder before. It had always gave me problem. Usually it's because plug-in incompatible. Running tomcat in it sometimes gives me this "undead" java process that just won't die.
I'm using IntelliJ 9 now. It's autocomplete is less complete than Flash Builder, but it has a much better refactoring feature and..much MUCH better integration with other tools (like Maven).

Resources