GithubHelp home page GithubHelp logo

Comments (10)

dtmilano avatar dtmilano commented on June 3, 2024

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.

kapilreddy avatar kapilreddy commented on June 3, 2024

Thanks! Works for me now.

from androidviewclient.

scheler avatar scheler commented on June 3, 2024

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.

elbajo avatar elbajo commented on June 3, 2024

I had a "NameError: global name 'bytearray' is not defined" error because of my python version, which one are you using?

from androidviewclient.

scheler avatar scheler commented on June 3, 2024

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.

dtmilano avatar dtmilano commented on June 3, 2024

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.

elbajo avatar elbajo commented on June 3, 2024

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.

scheler avatar scheler commented on June 3, 2024

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.

dtmilano avatar dtmilano commented on June 3, 2024

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.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 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.

burcuku avatar burcuku commented on June 3, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.