Android SDK MonkeyRunner broken? - monkeyrunner

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.

Related

(Gluon) JavaFX17/18 on Raspi (using desktop) not running due libglass.so: undefined symbol g_direct_hash

I have been trying to install/run JavaFX18 from Gluon on my raspberry pi4 and getting the following error message:
Exception in thread "main" java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
(... edited...)
Caused by: java.lang.UnsatisfiedLinkError: /opt/javafx-sdk-18/lib/libglass.so: /opt/javafx-sdk-18/lib/libglass.so: undefined symbol: g_direct_hash
here is my config:
Java: Linux/arm32 jdk-17.0.1+12
JavaFx: Linux/arm32 openjfx-18-ea+7 (also tried 17.0.1 and 17.0.2)
I'm following the instruction per Gluon doc (https://docs.gluonhq.com/#platforms_embedded) using the simple HelloFX example (https://github.com/openjfx/samples).
Here are the commands I'm executing in the HelloFX directory (where src is) on my pi:
sudo /opt/jdk-17.0.1+12/bin/javac -verbose
--module-path=/opt/javafx-sdk-18/lib --add-modules=javafx.controls src/hellofx/HelloFX.java -d dist
sudo /opt/jdk-17.0.1+12/bin/java -Dglass.platform=gtk -Djava.library.path=/usr/java/packages/lib:/lib:/usr/lib:/opt/javafx-sdk-18/lib
--module-path=/opt/javafx-sdk-18/lib --add-modules=javafx.controls -cp dist/. hellofx.HelloFX
[Note this is running with X11, not in Kiosk/CLI mode; the Gluon doc also shows how to run that same example in non-desktop mode with DRM..etc: I have tried this and working reasonably ok; I haven't tried the 64b variant yet]
has anyone stumbled on this issue and able to work around?
FWIW: Certainly not a good solution with unknown side effect: I used the libglass.so from JavaFX11 SDK replacing that same file in JavaFX17.0.1/lib and the HelloFX example works launching from the desktop.
so... either there is a bug in the FX 17.0.1/17.0.2 and 18 Linux/arm32 SDKs with that libglass.so file or some obscure settings are required.

JavaFX deployment: Failed to launch JVM

Greetings
I have deployed a simple JavaFX application using msi installer that was created by jpackage. When double-clicking on the application icon installed in Windows 10 "program files" directory, it displays an error "Failed to launch JVM". Prior to deployment, I tested the application jar file from the command prompt without any problem. When checking the application installation directory (under "C:\Program files") it has all the runtime dlls and so on, so I am not sure what causes this error? Here is the japckage command I used to build the runtime image:
jpackage --type msi --name FileChooser -p "%JAVAFX_HOME%\lib;%M2_REPO%;org\openjfx\mavenfxfilechooser\mavenfxfilechooser.jar" --module "org.openjfx.mavenfxfilechooser/org.openjfx.mavenfxfilechooser.FileChooserApp"
Update
Following the recommendation given in the comment section, I installed the JMODS on my machine and issued a jpackage command line to point to the JMODS files instead of JAVAFX_HOME as follow:
jpackage --type msi --name FileChooser -p "%JMODS_HOME%;%M2_REPO%;C:\Users\hrh74\Downloads\Lib\file\org\openjfx\mavenfxfilechooser" --module "org.openjfx.mavenfxfilechooser/org.openjfx.mavenfxfilechooser.FileChooserApp"
I installed the application using the MSI runtime image and this certainly solved the" Failed to launch JVM" problem. The application started, however, I have a WebView component that should display content from https://us.yahoo.com when the user clicks on a "Yahoo" button and this doesn't seem to be working when the application run as a self-contained app but it works when I run the jar file from the command line. Do I need to add anything to the jpackage?
Please let me know if the source code and FXML file are needed.
Thanks
Your original problem has to do with missing native code. But you appear to have already solved that problem by using the JMOD files for JavaFX provided by Gluon. So I'll try to help solve your other issue regarding https://us.yahoo.com not loading in the WebView once you create a self-contained application.
When trying to load that website myself I was running into the same issue as you. Though sometimes I'd get a "we're working on the problem" page response, other times the entire application would become unresponsive, and yet other times nothing would happen (the load would just seem to fail "gracefully"). This happened with other websites as well, not just Yahoo. After some testing I was finally able to get the following error:
java.lang.Throwable: SSL handshake failed
at javafx.web/javafx.scene.web.WebEngine$LoadWorker.describeError(Unknown Source)
at javafx.web/javafx.scene.web.WebEngine$LoadWorker.dispatchLoadEvent(Unknown Source)
at javafx.web/javafx.scene.web.WebEngine$PageLoadListener.dispatchLoadEvent(Unknown Source)
at javafx.web/com.sun.webkit.WebPage.fireLoadEvent(Unknown Source)
at javafx.web/com.sun.webkit.WebPage.fwkFireLoadEvent(Unknown Source)
at javafx.web/com.sun.webkit.network.URLLoaderBase.twkDidFail(Native Method)
at javafx.web/com.sun.webkit.network.HTTP2Loader.notifyDidFail(Unknown Source)
at javafx.web/com.sun.webkit.network.HTTP2Loader.lambda$didFail$18(Unknown Source)
at javafx.web/com.sun.webkit.network.HTTP2Loader.lambda$callBackIfNotCanceled$10(Unknown Source)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(Unknown Source)
at java.base/java.security.AccessController.doPrivileged(Unknown Source)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(Unknown Source)
at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(Unknown Source)
at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(Unknown Source)
at java.base/java.lang.Thread.run(Unknown Source)
That indicated to me the application created by jpackage was missing some crypto libraries. From here I just guessed, but inclulding:
--add-modules jdk.crypto.cryptoki,jdk.crypto.ec
When running jpackage seemed to solve the problem. I don't know if both modules are needed, or if only one is needed (or if adding either one implicitly adds the other).
Side note: When scrolling through https://us.yahoo.com I would frequently get the following warnings:
Mar 05, 2021 12:10:40 PM com.sun.javafx.webkit.prism.WCMediaPlayerImpl onError
WARNING: onError, errCode=0, msg=Could not create player!
And:
Mar 05, 2021 12:10:41 PM com.sun.javafx.webkit.prism.WCMediaPlayerImpl$CreateThread run
WARNING: CreateThread ERROR: java.lang.UnsupportedOperationException: Unsupported protocol "data"
I would get that warning regardless of how the application was packaged. I don't know how to solve the problem, or if there even is a solution without modifying the JavaFX code itself.
Have you seen running JavaFX application after jpackage? Try to download Gluon jmods and use it instead of %JAVAFX_HOME%

I Cannot run jar file in kubuntu terminal

I thinks it is some problems in my java installation but i don't know what is the problem and how can i fix it
I can run jar file with openjdk in visual mode but in terminal i cannot run jar files
for example you can see this below
root#mohammad-Inspiron-1564:/media/storage/Linux/Freedom# java -jar freedom.jar
No protocol specified
No protocol specified
Exception in thread "main" java.lang.InternalError: Can't connect to X11 window server using ':0' as the value of the DISPLAY variable.
at sun.awt.X11GraphicsEnvironment.initDisplay(Native Method)
at sun.awt.X11GraphicsEnvironment.access$200(X11GraphicsEnvironment.java:65)
at sun.awt.X11GraphicsEnvironment$1.run(X11GraphicsEnvironment.java:110)
at java.security.AccessController.doPrivileged(Native Method)
at sun.awt.X11GraphicsEnvironment.<clinit>(X11GraphicsEnvironment.java:74)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:186)
at java.awt.GraphicsEnvironment.createGE(GraphicsEnvironment.java:102)
at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:81)
at java.awt.Window.initGC(Window.java:466)
at java.awt.Window.init(Window.java:486)
at java.awt.Window.<init>(Window.java:535)
at java.awt.Frame.<init>(Frame.java:420)
at javax.swing.JFrame.<init>(JFrame.java:218)
at de.resolution.emsgui.LanguageSelector.showButtonGrid(LanguageSelector.java:27)
at de.resolution.emsgui.LanguageSelector.<init>(LanguageSelector.java:19)
at emsgui.main(emsgui.java:46)
perhaps i should re-install mu kubuntu :((
thnx
Mohammad
The error message tells you that it cannot connect to the X11 window server. The program in the JAR file uses Swing and needs some way to display the GUI it creates. If you have X11 installed, you can start it from the command-line by typing startx. Otherwise you need to install it or some other system that will allow you to run a Swing-based program.

Having trouble running a custom jar on Amazon AWS

I'm having trouble running a custom jar on Elastic Map-Reduce
I'm using jdk1.6.0_26, Hadoop 0.20.205, and compiling with Eclipse on my computer and everything works perfectly fine
for example if I ran the following on my computer it would be successful
hadoop jar MaxTemperature.jar input/temperature.txt output
I specified the jar as the following on AWS
s3n://chrishadoop/MaxTemperature.jar
and I specified the arguments as
s3n://chrishadoop/input/temperature.txt s3n://chrishadoop/output
I did not specify the main class because I pointed to it in the manifest
Here is the jar I'm using, I will make it public for a little while
https://s3.amazonaws.com/chrishadoop/MaxTemperature.jar
Here is the error I'm getting
2012-07-08 19:31:39,824 INFO com.amazonaws.elasticmapreduce.statepusher.StatePusher (main): Pusher awoke, starting to push data into simpledb...
2012-07-08 19:31:40,552 FATAL com.amazonaws.elasticmapreduce.statepusher.StatePusher (main): Fatal Exception raised while extracting data from hadoop and pushing to simpledb
java.lang.NoClassDefFoundError: org/codehaus/jackson/map/JsonMappingException
at com.amazonaws.elasticmapreduce.statepusher.StatePusher.run(StatePusher.java:65)
at com.amazonaws.elasticmapreduce.statepusher.StatePusher.main(StatePusher.java:205)
Caused by: java.lang.ClassNotFoundException: org.codehaus.jackson.map.JsonMappingException
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
... 2 more
There is a version of Jackson which is installed as part of the AMI, and I'm guessing you're bundling a different version of Jackson? The error seems to be happening in the support code which makes "enable debugging" work.

Android UI automation with Python - Monkeyrunner - Null point exception

Code:
Imports the monkeyrunner modules used by this program
from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice
Connects to the current device, returning a MonkeyDevice object
device = MonkeyRunner.waitForConnection()
print "Hello World!"
Error:
Traceback (most recent call last):
File "D:\AndroidApps\Sample\src\com\android\diagnostics\click\click1.py", line 5, in
device = MonkeyRunner.waitForConnection()
at com.android.monkeyrunner.MonkeyRunner.waitForConnection(MonkeyRunner.java:74)
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)
java.lang.NullPointerException: java.lang.NullPointerException
I am trying to automate the android application by using monkey runner i.e UI testing by using python scripts
Can any body help how to solve the Null point exception for the above code ?
If I look at the stack trace of your error, this looks like there is an issue with your jython library of monkeyrunner.
Because, there is an exception occurring from reflection package which is failing to invoke the native java call. Make sure your monkeyrunner.bat file is referencing the lib folder provided with android SDK.
Updating the android SDK also may help.
I had same issue.At last I found that is a hardware issue, so please ran it on emulator first or another phone.

Resources