Comments (10)
My fault, the documentation is running behind.
The jar is kept as legacy code and the newer versions (>= 4.0.0) should not use it. These versions are python only and does not require Java nor monkeyrunner.
In your case, because Mac OSX supports shebang you only need to run:
$ ./dump
and if you receive an error like
Traceback (most recent call last):
File "./dump", line 28, in <module>
from com.dtmilano.android.viewclient import ViewClient
ImportError: No module named com.dtmilano.android.viewclient
set
export ANDROID_VIEW_CLIENT_HOME=/path/to/your/AndroidViewClient/AndroidViewClient
export PYTHONPATH=$PYTHONPATH:$ANDROID_VIEW_CLIENT_HOME/src
from androidviewclient.
Thanks! Works for me now.
from androidviewclient.
I still see this with other example scripts, for example ./gallery-select-album.py or ./browser-open-url.py - can you check?
130920 15:31:57.559:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions] Script terminated due to an exception
130920 15:31:57.559:S [MainThread] [com.android.monkeyrunner.MonkeyRunnerOptions]Traceback (most recent call last):
File "/Users/x/Downloads/AndroidViewClient-4.2.1/AndroidViewClient/examples/./browser-open-url.py", line 39, in
device, serialno = ViewClient.connectToDeviceOrExit()
File "/Users/x/Downloads/AndroidViewClient-4.2.1/AndroidViewClient/src/com/dtmilano/android/viewclient.py", line 1376, in connectToDeviceOrExit
device = adbclient.AdbClient(serialno)
File "/Users/x/Downloads/AndroidViewClient-4.2.1/AndroidViewClient/src/com/dtmilano/android/adb/adbclient.py", line 79, in init
self.__setTransport()
File "/Users/x/Downloads/AndroidViewClient-4.2.1/AndroidViewClient/src/com/dtmilano/android/adb/adbclient.py", line 191, in _AdbClient__setTransport
for device in self.getDevices():
File "/Users/x/Downloads/AndroidViewClient-4.2.1/AndroidViewClient/src/com/dtmilano/android/adb/adbclient.py", line 214, in getDevices
for line in self.__receive().splitlines():
File "/Users/x/Downloads/AndroidViewClient-4.2.1/AndroidViewClient/src/com/dtmilano/android/adb/adbclient.py", line 140, in _AdbClient__receive
recv = bytearray()
NameError: global name 'bytearray' is not defined
from androidviewclient.
I had a "NameError: global name 'bytearray' is not defined" error because of my python version, which one are you using?
from androidviewclient.
I am using python 2.7.1 on Mac.
On Sep 20, 2013 7:04 PM, "elbajo" [email protected] wrote:
I had a "NameError: global name 'bytearray' is not defined" error because
of my python version, which one are you using?—
Reply to this email directly or view it on GitHubhttps://github.com//issues/44#issuecomment-24810430
.
from androidviewclient.
You may not be using python
at all if you receive that error:
$ monkeyrunner
Jython 2.5.3 (2.5:c56500f08d34+, Aug 13 2012, 14:54:35)
[Java HotSpot(TM) 64-Bit Server VM (Apple Inc.)] on java1.6.0_51
>>> bytearray()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'bytearray' is not defined
>>>
$ python
Python 2.7.2 (v2.7.2:8527427914a2, Jun 11 2011, 15:22:34)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> bytearray()
bytearray(b'')
>>> ^D
from androidviewclient.
I look at the example files and I think it's because the first line is wrong : it should be "#! /usr/bin/env python" instead of "#! /usr/bin/env monkeyrunner"
from androidviewclient.
Hello,
I changed the first line as you suggested but this time the monkeyrunner
python modules aren't available to the scripts. Here's the error I get:
MacBook-Pro:examples $ ./browser-open-url.py
Traceback (most recent call last):
File "./browser-open-url.py", line 31, in
from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice
ImportError: No module named android.monkeyrunner
Here are the variable I have set:
MacBook-Pro:examples $ echo $ANDROID_VIEW_CLIENT_HOME
/Users/x/Downloads/AndroidViewClient-4.2.1/AndroidViewClient
MacBook-Pro:examples $ echo $PYTHONPATH
/Users/x/Downloads/AndroidViewClient-4.2.1/AndroidViewClient/src
Is there anything else I should be doing?
Thanks.
On Fri, Sep 20, 2013 at 8:47 PM, elbajo [email protected] wrote:
I look at the example files and I think it's because the first line is
wrong : it should be "#! /usr/bin/env python" instead of "#! /usr/bin/env
monkeyrunner"—
Reply to this email directly or view it on GitHubhttps://github.com//issues/44#issuecomment-24817796
.
from androidviewclient.
Monkeyrunner is not used anymore you have to remove theose lines
On Sep 20, 2013 1:13 PM, "scheler" [email protected] wrote:
Hello,
I changed the first line as you suggested but this time the monkeyrunner
python modules aren't available to the scripts. Here's the error I get:MacBook-Pro:examples $ ./browser-open-url.py
Traceback (most recent call last):
File "./browser-open-url.py", line 31, in
from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice
ImportError: No module named android.monkeyrunnerHere are the variable I have set:
MacBook-Pro:examples $ echo $ANDROID_VIEW_CLIENT_HOME
/Users/x/Downloads/AndroidViewClient-4.2.1/AndroidViewClientMacBook-Pro:examples $ echo $PYTHONPATH
/Users/x/Downloads/AndroidViewClient-4.2.1/AndroidViewClient/srcIs there anything else I should be doing?
Thanks.
On Fri, Sep 20, 2013 at 8:47 PM, elbajo [email protected] wrote:
I look at the example files and I think it's because the first line is
wrong : it should be "#! /usr/bin/env python" instead of "#!
/usr/bin/env
monkeyrunner"—
Reply to this email directly or view it on GitHub<
https://github.com/dtmilano/AndroidViewClient/issues/44#issuecomment-24817796>.
—
Reply to this email directly or view it on GitHubhttps://github.com//issues/44#issuecomment-24825792
.
from androidviewclient.
I can successfully run my script I modified from the output of culebra from the commandline, using python. But I want to execute the script from Java and when I execute the same statements using Jython interpreter, I have the same bytearray not found problem:
The part of Java code:
PythonInterpreter python = new PythonInterpreter();
python.exec("import re, sys, os");
python.exec("from com.dtmilano.android.viewclient import ViewClient");
python.exec("kwargs1 = {'verbose': True, 'ignoresecuredevice': False}");
python.exec("device, serialno = ViewClient.connectToDeviceOrExit(**kwargs1)");
...
the command I execute java:
java -cp .:jython-standalone-2.5.3.jar:/Library/Python/2.7/site-packages/androidviewclient-7.1.1-py2.7.egg MyJavaFile
The error I get:
Exception in thread "MainThread" Traceback (most recent call last):
File "", line 1, in
File "pyclasspath/com/dtmilano/android/viewclient.py", line 1436, in connectToDeviceOrExit
File "pyclasspath/com/dtmilano/android/adb/adbclient.py", line 93, in init
File "pyclasspath/com/dtmilano/android/adb/adbclient.py", line 211, in checkVersion
File "pyclasspath/com/dtmilano/android/adb/adbclient.py", line 153, in _AdbClient__send
NameError: global name 'bytearray' is not defined
I am using Python 2.7.5 and Jython-standalone-2.5.3 on Mac OS.
As in the previous comment, I also have the bytearray not found message when I type bytearray() after monkeyrunner command on the command prompt.
Is there an incompatibility between the packages I use or do I miss something?
Thanks.
from androidviewclient.
Related Issues (20)
- Cannot install android-select-device HOT 1
- Find Password flag state in vc.dump() data HOT 1
- [Errno 8] nodename nor servname provided, or not known. HOT 4
- Multi-swipe HOT 2
- startActivity() doesn't work HOT 3
- How to deal with file dialog HOT 1
- Help me with incomplete escape \U at position 2 HOT 14
- please Help me with touch not response HOT 3
- How to get pop-up messages in app HOT 4
- can not use the examples browser-open-url.py HOT 2
- takeSnapshot fails after first time HOT 4
- Can't find or read elements with Unity game HOT 7
- Exception: adb="adb.exe" is not executable. HOT 1
- ValueError: received does not contain valid XML: Killed HOT 7
- Take SnapShot with TimeOutException HOT 15
- 22.3.0 does not support Python 3.7.7 HOT 2
- error using helper HOT 1
- CulebraTester2 backend: error when using findViewWithAttributeThatMatches HOT 4
- ViewClient crash due to __parseTreeFromUiAutomatorDump ? HOT 4
- Example of using Pinch HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from androidviewclient.