googlecodelabs / android-perf-testing

Automated Performance Testing on Android
https://codelabs.developers.google.com/codelabs/android-perf-testing/
Apache License 2.0
93 stars 39 forks source link

Monkeyrunner.bat path on Step 6 is wrong (Windows) #41

Open PaulRashidi opened 6 years ago

PaulRashidi commented 6 years ago

gradlew :app:assembleDebug :app:assembleDebugAndroidTest :app:installDebug :app:installDebugAndroidTest

%ANDROID_HOME%\tools\bin\monkeyrunner.bat run_perf_tests.py .\

Even after resolving the ANDROID_SWT variable issue with monkeyrunner with the below command it seems like monkeyrunner.bat is broken for Windows.

set ANDROID_SWT=C:\Users\someone\AppData\Local\Android\sdk\tools\lib\x86_64\swt.jar

baoti commented 5 years ago

This is my local monkeyrunner.bat, it works for me:

rem don't modify the caller's environment
setlocal

rem Set up prog to be the path of this script, including following symlinks,
rem and set up progdir to be the fully-qualified pathname of its directory.
set prog=%~f0

rem Change current directory and drive to where the script is, to avoid
rem issues with directories containing whitespaces.
cd /d %~dp0

rem Check we have a valid Java.exe in the path.
set java_exe=
call ..\lib\find_java.bat
if not defined java_exe goto :EOF

if defined APP_HOME goto AppHomeOk
    set APP_HOME=%ANDROID_HOME%\tools

:AppHomeOk

for /f %%a in ("%APP_HOME%\lib\monkeyrunner-26.0.0-dev.jar") do set jarfile=%%~nxa
set frameworkdir=.
set libdir=

if exist %frameworkdir%\%jarfile% goto JarFileOk
    set frameworkdir=..\lib

if exist %frameworkdir%\%jarfile% goto JarFileOk
    set frameworkdir=..\framework

:JarFileOk

set jarpath=%frameworkdir%\%jarfile%

if not defined ANDROID_SWT goto QueryArch
    set swt_path=%ANDROID_SWT%
    goto SwtDone

:QueryArch

    for /f "delims=" %%a in ('%frameworkdir%\..\bin\archquery') do set swt_path=%frameworkdir%\%%a

:SwtDone

if exist "%swt_path%" goto SetPath
    echo SWT folder '%swt_path%' does not exist.
    echo Please set ANDROID_SWT to point to the folder containing swt.jar for your platform.
    exit /B

:SetPath

call "%java_exe%" -Xmx512m "-Djava.ext.dirs=%frameworkdir%;%swt_path%" -Dcom.android.monkeyrunner.bindir=%ANDROID_HOME%\platform-tools -jar %jarpath% %*