Ranorex command line instrumentation on emulator

Mobile Testing, Android App Testing.
tomwolf
Posts: 18
Joined: Tue Feb 26, 2019 9:04 am

Ranorex command line instrumentation on emulator

Post by tomwolf » Fri Jun 28, 2019 8:13 am

Hello everyone,

I've been testing on Android emulators for some time and I would really like to automate instrumenting APK's on Android emulators. By using this site: 'https://www.ranorex.com/help/latest/int ... g-started/' I've been able to create this file:

Code: Select all

"C:\Program Files (x86)\Ranorex 8.3\Bin\Ranorex.Instrumentation.exe" /p:"android" /d:"emulator-5554" /a:"S:\TestSet\Ranorex\Live\FINAL\Algemeen\AFASPocket\Android APK\New\AFAS_Pocket.apk"
After launching this file as a batch file it does nothing. With a 'pause' at the end it gives the following error: 'Device 'emulator-5554' couldn't be found. Please use the devices dialog to configure your devices.'

So does Ranorex support instrumentation on emulators using command line? And if it does why doesn't it work in my case?

Detailed description of my system:
Windows 10 Enterprise
Ranorex 8.3.3
RxServiceApp Distributable 3.0.3 on iOS

If there is anymore information needed, I would like to hear!
Regards,

Tom Wolf

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 5353
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Ranorex command line instrumentation on emulator

Post by odklizec » Fri Jun 28, 2019 8:52 am

Hi,

It sounds like you have not added the device as an endpoint, which I believe is a must for instrumentation, no matter if done manually or from command line? I also found this post, where you already discussed a possibility of automatic creation of mobile endpoints?...
https://www.ranorex.com/forum/viewtopic ... 465#p54606
Are you using the code suggested by McTurtle (prior command line instrumentation)?
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

tomwolf
Posts: 18
Joined: Tue Feb 26, 2019 9:04 am

Re: Ranorex command line instrumentation on emulator

Post by tomwolf » Fri Jun 28, 2019 11:01 am

Hello Pavel,

No I've added the device manually and automated and tested on both. I've even performed the action inside Ranorex itself by performing the action 'Run application' with the arguments, but everytime I got the same result. After your post I've tried to start the emulator with the Ranorex ADB file. This gave me the samen results.

After that I've also tried to connect a real device to Ranorex, but Ranorex wasn't able to find my device. Following this 'https://stackoverflow.com/questions/230 ... authorized' post turned out that my device was unauthorized even if I was able to look inside my phone files from my computer. So I even tried 'kill-server' and 'start-server' in the ADB, but this changed nothing. Could this cause my problem or would it be something else?
Regards,

Tom Wolf

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 5353
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Ranorex command line instrumentation on emulator

Post by odklizec » Fri Jun 28, 2019 11:20 am

Hi,

I'm afraid, I don't have such experience, so I don't have a clue. 'Unauthorized' sounds definitely bad and from the comments in that stackoverflow post it seems, as if it blocks USB debugging? Have you revoked USB debugging authorization, before killing and restarting server? Eventually, have you checked the rest of suggestions in that post?
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

dominik_F
Posts: 15
Joined: Thu May 09, 2019 10:03 am

Re: Ranorex command line instrumentation on emulator

Post by dominik_F » Fri Jul 19, 2019 10:51 am

Hi,
i add my issue to this thread as it is quite similar.
I have an Android Endpoint (Samsung Galaxy S7 edge) which is recognized and everything within ranorex studio.
For human readability i changed its endpoint name from "USB-xxxxxx" to "GalaxyS7".
Within Ranorex studio it is fine (connected, i can manually push and instrumentize my apk), but when trying to deploy an app via the ranorex.Instrumentation.exe it shows me the same Error:

Code: Select all

Error: Device 'GalaxyS7' couldn't be found. Please use the devices dialog to configure your devices.
My command line call ist:
"C:\Program Files (x86)\Ranorex\Studio\Bin\Ranorex.Instrumentation.exe" /p:android /device:GalaxyS7 /apkfile:"C:\DEV\Artefakte\run\and-festnetz\app-unicope-releaseDontObfuscate.apk" /InstrumentationFlags:-static-multidex"

Or did i specify the device somehow wrong?

best regards Dominik

User avatar
Support Team
Site Admin
Site Admin
Posts: 12003
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Ranorex command line instrumentation on emulator

Post by Support Team » Fri Jul 19, 2019 7:14 pm

Hello All,

Although the devices are added as endpoints within Ranorex Studio, you will need to add them as endpoints globally. When using command line to instrument it will not pick up the device if it was just added as an endpoint within Ranorex Studio. You can add the endpoint one of two ways which I have listed below.

Instrumentation Wizard - Open the standalone Instrumentation Wizard and select Android > Endpoints and add the desired device. The device is now a global endpoint ready for use.

Ranorex Spy - Open the standalone Ranorex Spy application and add Endpoint in the endpoint section to add a device which will also add it globally.

By adding my device globally I was able to instrument and deploy my APK using command line.

Regards,
Sean
.
Image

tomwolf
Posts: 18
Joined: Tue Feb 26, 2019 9:04 am

Re: Ranorex command line instrumentation on emulator

Post by tomwolf » Fri Jul 26, 2019 12:54 pm

Hi everyone,

With the new Ranorex 9.1 version I was not able to instrument any application using the Instrumentation Wizard. After doing some research I found this solution: 'https://www.ranorex.com/forum/failed-to ... 13913.html' and after following those steps I was able to instrument a application via the (standalone) Instrumentation Wizard.

So my commandline instrumentation file was still not working, till I saw the solution of Sean. This solution has definitily worked for me, because my .bat file is now able to find my endpoint. The instrumentation is after all still not working and it's giving me an error.

These are the arguments I'm using in my .bat file:

Code: Select all

"C:\Program Files (x86)\Ranorex\Studio\Bin\Ranorex.Instrumentation.exe" /p:"android" /d:"emulator-5554" /a:"S:\TestSet\Ranorex\Live\FINAL\Algemeen\AFASPocket\AFAS Pocket APK\AfasPocket.apk" /dm:"Auto"
This is the error I'm getting:
Error:
Failed to recompile the instrumented code. See details for more information: S: WARNING: Could not write to (C:\Users\AdminTWO\AppData\Local\apktool\framework), using C:\Users\AdminTWO\AppData\Local\Temp\2\ instead...
S: Please be aware this is a volatile directory and frameworks could go missing, please utilize --frame-path if the default storage directory is unavailable
brut.androlib.AndrolibException: brut.common.BrutException: could not exec (exit code = -1073741515): [C:\Users\AdminTWO\AppData\Local\Temp\2\brut_util_Jar_3522265001963477230.tmp, p, --forced-package-id, 127, --min-sdk-version, 16, --target-sdk-version, 28, --version-code, 1041088, --version-name, 1.4.10, --no-version-vectors, -F, C:\Users\AdminTWO\AppData\Local\Temp\2\APKTOOL2110407068097671432.tmp, -0, arsc, -0, META-INF/android.arch.lifecycle_runtime.version, -0, META-INF/com.android.support_support-compat.version, -0, META-INF/com.android.support_support-core-ui.version, -0, META-INF/com.android.support_support-core-utils.version, -0, META-INF/com.android.support_support-fragment.version, -0, META-INF/com.android.support_support-media-compat.version, -0, META-INF/com.android.support_support-v13.version, -0, META-INF/com.android.support_support-v4.version, -0, png, -0, assets/www/img/cake.png.png, -0, jpg, -0, assets/www/img/delete.png.png, -0, assets/www/img/lockwhite.png.png, -0, assets/www/img/reload.png.png, -0, assets/www/img/splash.png.png, -0, assets/www/img/home/messages.png.png, -0, assets/www/lib/angular/angular.min.js.gzip, -0, res/drawable-hdpi-v4/abc_ab_share_pack_mtrl_alpha.9.png, -0, res/drawable-hdpi-v4/abc_btn_switch_to_on_mtrl_00001.9.png, -0, res/drawable-hdpi-v4/abc_btn_switch_to_on_mtrl_00012.9.png, -0, res/drawable-hdpi-v4/abc_cab_background_top_mtrl_alpha.9.png, -0, res/drawable-hdpi-v4/abc_list_divider_mtrl_alpha.9.png, -0, res/drawable-hdpi-v4/abc_list_focused_holo.9.png, -0, res/drawable-hdpi-v4/abc_list_longpressed_holo.9.png, -0, res/drawable-hdpi-v4/abc_list_pressed_holo_dark.9.png, -0, res/drawable-hdpi-v4/abc_list_pressed_holo_light.9.png, -0, res/drawable-hdpi-v4/abc_list_selector_disabled_holo_dark.9.png, -0, res/drawable-hdpi-v4/abc_list_selector_disabled_holo_light.9.png, -0, res/drawable-hdpi-v4/abc_menu_hardkey_panel_mtrl_mult.9.png, -0, res/drawable-hdpi-v4/abc_popup_background_mtrl_mult.9.png, -0, res/drawable-hdpi-v4/abc_scrubber_primary_mtrl_alpha.9.png, -0, res/drawable-hdpi-v4/abc_scrubber_track_mtrl_alpha.9.png, -0, res/drawable-hdpi-v4/abc_spinner_mtrl_am_alpha.9.png, -0, res/drawable-hdpi-v4/abc_switch_track_mtrl_alpha.9.png, -0, res/drawable-hdpi-v4/abc_tab_indicator_mtrl_alpha.9.png, -0, res/drawable-hdpi-v4/abc_textfield_activated_mtrl_alpha.9.png, -0, res/drawable-hdpi-v4/abc_textfield_default_mtrl_alpha.9.png, -0, res/drawable-hdpi-v4/abc_textfield_search_activated_mtrl_alpha.9.png, -0, res/drawable-hdpi-v4/abc_textfield_search_default_mtrl_alpha.9.png, -0, res/drawable-hdpi-v4/common_google_signin_btn_icon_dark_normal_background.9.png, -0, res/drawable-hdpi-v4/common_google_signin_btn_icon_light_normal_background.9.png, -0, res/drawable-hdpi-v4/common_google_signin_btn_text_dark_normal_background.9.png, -0, res/drawable-hdpi-v4/common_google_signin_btn_text_light_normal_background.9.png, -0, res/drawable-hdpi-v4/notification_bg_low_normal.9.png, -0, res/drawable-hdpi-v4/notification_bg_low_pressed.9.png, -0, res/drawable-hdpi-v4/notification_bg_normal.9.png, -0, res/drawable-hdpi-v4/notification_bg_normal_pressed.9.png, -0, res/drawable-ldrtl-hdpi-v4/abc_spinner_mtrl_am_alpha.9.png, -0, res/drawable-ldrtl-mdpi-v4/abc_spinner_mtrl_am_alpha.9.png, -0, res/drawable-ldrtl-xhdpi-v4/abc_spinner_mtrl_am_alpha.9.png, -0, res/drawable-ldrtl-xxhdpi-v4/abc_spinner_mtrl_am_alpha.9.png, -0, res/drawable-ldrtl-xxxhdpi-v4/abc_spinner_mtrl_am_alpha.9.png, -0, res/drawable-mdpi-v4/abc_ab_share_pack_mtrl_alpha.9.png, -0, res/drawable-mdpi-v4/abc_btn_switch_to_on_mtrl_00001.9.png, -0, res/drawable-mdpi-v4/abc_btn_switch_to_on_mtrl_00012.9.png, -0, res/drawable-mdpi-v4/abc_cab_background_top_mtrl_alpha.9.png, -0, res/drawable-mdpi-v4/abc_list_divider_mtrl_alpha.9.png, -0, res/drawable-mdpi-v4/abc_list_focused_holo.9.png, -0, res/drawable-mdpi-v4/abc_list_longpressed_holo.9.png, -0, res/drawable-mdpi-v4/abc_list_pressed_holo_dark.9.png, -0, res/drawable-mdpi-v4/abc_list_pressed_holo_light.9.png, -0, res/drawable-mdpi-v4/abc_list_selector_disabled_holo_dark.9.png, -0, res/drawable-mdpi-v4/abc_list_selector_disabled_holo_light.9.png, -0, res/drawable-mdpi-v4/abc_menu_hardkey_panel_mtrl_mult.9.png, -0, res/drawable-mdpi-v4/abc_popup_background_mtrl_mult.9.png, -0, res/drawable-mdpi-v4/abc_scrubber_primary_mtrl_alpha.9.png, -0, res/drawable-mdpi-v4/abc_scrubber_track_mtrl_alpha.9.png, -0, res/drawable-mdpi-v4/abc_spinner_mtrl_am_alpha.9.png, -0, res/drawable-mdpi-v4/abc_switch_track_mtrl_alpha.9.png, -0, res/drawable-mdpi-v4/abc_tab_indicator_mtrl_alpha.9.png, -0, res/drawable-mdpi-v4/abc_textfield_activated_mtrl_alpha.9.png, -0, res/drawable-mdpi-v4/abc_textfield_default_mtrl_alpha.9.png, -0, res/drawable-mdpi-v4/abc_textfield_search_activated_mtrl_alpha.9.png, -0, res/drawable-mdpi-v4/abc_textfield_search_default_mtrl_alpha.9.png, -0, res/drawable-mdpi-v4/common_google_signin_btn_icon_dark_normal_background.9.png, -0, res/drawable-mdpi-v4/common_google_signin_btn_icon_light_normal_background.9.png, -0, res/drawable-mdpi-v4/common_google_signin_btn_text_dark_normal_background.9.png, -0, res/drawable-mdpi-v4/common_google_signin_btn_text_light_normal_background.9.png, -0, res/drawable-mdpi-v4/notification_bg_low_normal.9.png, -0, res/drawable-mdpi-v4/notification_bg_low_pressed.9.png, -0, res/drawable-mdpi-v4/notification_bg_normal.9.png, -0, res/drawable-mdpi-v4/notification_bg_normal_pressed.9.png, -0, res/drawable-xhdpi-v4/abc_ab_share_pack_mtrl_alpha.9.png, -0, res/drawable-xhdpi-v4/abc_btn_switch_to_on_mtrl_00001.9.png, -0, res/drawable-xhdpi-v4/abc_btn_switch_to_on_mtrl_00012.9.png, -0, res/drawable-xhdpi-v4/abc_cab_background_top_mtrl_alpha.9.png, -0, res/drawable-xhdpi-v4/abc_list_divider_mtrl_alpha.9.png, -0, res/drawable-xhdpi-v4/abc_list_focused_holo.9.png, -0, res/drawable-xhdpi-v4/abc_list_longpressed_holo.9.png, -0, res/drawable-xhdpi-v4/abc_list_pressed_holo_dark.9.png, -0, res/drawable-xhdpi-v4/abc_list_pressed_holo_light.9.png, -0, res/drawable-xhdpi-v4/abc_list_selector_disabled_holo_dark.9.png, -0, res/drawable-xhdpi-v4/abc_list_selector_disabled_holo_light.9.png, -0, res/drawable-xhdpi-v4/abc_menu_hardkey_panel_mtrl_mult.9.png, -0, res/drawable-xhdpi-v4/abc_popup_background_mtrl_mult.9.png, -0, res/drawable-xhdpi-v4/abc_scrubber_primary_mtrl_alpha.9.png, -0, res/drawable-xhdpi-v4/abc_scrubber_track_mtrl_alpha.9.png, -0, res/drawable-xhdpi-v4/abc_spinner_mtrl_am_alpha.9.png, -0, res/drawable-xhdpi-v4/abc_switch_track_mtrl_alpha.9.png, -0, res/drawable-xhdpi-v4/abc_tab_indicator_mtrl_alpha.9.png, -0, res/drawable-xhdpi-v4/abc_textfield_activated_mtrl_alpha.9.png, -0, res/drawable-xhdpi-v4/abc_textfield_default_mtrl_alpha.9.png, -0, res/drawable-xhdpi-v4/abc_textfield_search_activated_mtrl_alpha.9.png, -0, res/drawable-xhdpi-v4/abc_textfield_search_default_mtrl_alpha.9.png, -0, res/drawable-xhdpi-v4/common_google_signin_btn_icon_dark_normal_background.9.png, -0, res/drawable-xhdpi-v4/common_google_signin_btn_icon_light_normal_background.9.png, -0, res/drawable-xhdpi-v4/common_google_signin_btn_text_dark_normal_background.9.png, -0, res/drawable-xhdpi-v4/common_google_signin_btn_text_light_normal_background.9.png, -0, res/drawable-xhdpi-v4/notification_bg_low_normal.9.png, -0, res/drawable-xhdpi-v4/notification_bg_low_pressed.9.png, -0, res/drawable-xhdpi-v4/notification_bg_normal.9.png, -0, res/drawable-xhdpi-v4/notification_bg_normal_pressed.9.png, -0, res/drawable-xxhdpi-v4/abc_ab_share_pack_mtrl_alpha.9.png, -0, res/drawable-xxhdpi-v4/abc_btn_switch_to_on_mtrl_00001.9.png, -0, res/drawable-xxhdpi-v4/abc_btn_switch_to_on_mtrl_00012.9.png, -0, res/drawable-xxhdpi-v4/abc_cab_background_top_mtrl_alpha.9.png, -0, res/drawable-xxhdpi-v4/abc_list_divider_mtrl_alpha.9.png, -0, res/drawable-xxhdpi-v4/abc_list_focused_holo.9.png, -0, res/drawable-xxhdpi-v4/abc_list_longpressed_holo.9.png, -0, res/drawable-xxhdpi-v4/abc_list_pressed_holo_dark.9.png, -0, res/drawable-xxhdpi-v4/abc_list_pressed_holo_light.9.png, -0, res/drawable-xxhdpi-v4/abc_list_selector_disabled_holo_dark.9.png, -0, res/drawable-xxhdpi-v4/abc_list_selector_disabled_holo_light.9.png, -0, res/drawable-xxhdpi-v4/abc_menu_hardkey_panel_mtrl_mult.9.png, -0, res/drawable-xxhdpi-v4/abc_popup_background_mtrl_mult.9.png, -0, res/drawable-xxhdpi-v4/abc_scrubber_primary_mtrl_alpha.9.png, -0, res/drawable-xxhdpi-v4/abc_scrubber_track_mtrl_alpha.9.png, -0, res/drawable-xxhdpi-v4/abc_spinner_mtrl_am_alpha.9.png, -0, res/drawable-xxhdpi-v4/abc_switch_track_mtrl_alpha.9.png, -0, res/drawable-xxhdpi-v4/abc_tab_indicator_mtrl_alpha.9.png, -0, res/drawable-xxhdpi-v4/abc_textfield_activated_mtrl_alpha.9.png, -0, res/drawable-xxhdpi-v4/abc_textfield_default_mtrl_alpha.9.png, -0, res/drawable-xxhdpi-v4/abc_textfield_search_activated_mtrl_alpha.9.png, -0, res/drawable-xxhdpi-v4/abc_textfield_search_default_mtrl_alpha.9.png, -0, res/drawable-xxhdpi-v4/common_google_signin_btn_icon_dark_normal_background.9.png, -0, res/drawable-xxhdpi-v4/common_google_signin_btn_icon_light_normal_background.9.png, -0, res/drawable-xxhdpi-v4/common_google_signin_btn_text_dark_normal_background.9.png, -0, res/drawable-xxhdpi-v4/common_google_signin_btn_text_light_normal_background.9.png, -0, res/drawable-xxxhdpi-v4/abc_btn_switch_to_on_mtrl_00001.9.png, -0, res/drawable-xxxhdpi-v4/abc_btn_switch_to_on_mtrl_00012.9.png, -0, res/drawable-xxxhdpi-v4/abc_spinner_mtrl_am_alpha.9.png, -0, res/drawable-xxxhdpi-v4/abc_switch_track_mtrl_alpha.9.png, -0, res/drawable-xxxhdpi-v4/abc_tab_indicator_mtrl_alpha.9.png, -0, ogg, -0, arsc, -I, C:\Users\AdminTWO\AppData\Local\Temp\2\1.apk, -S, C:\Users\AdminTWO\AppData\Local\RanorexStudio9\RxEnv\Android\temp\decomp\res, -M, C:\Users\AdminTWO\AppData\Local\RanorexStudio9\RxEnv\Android\temp\decomp\AndroidManifest.xml]
Does anyone have a solution to this error?

Detailed description of my system:
Microsoft Windows Server 2016 Standard
Ranorex 9.1
Service App 2.0.3 on Android

If there is anymore information needed, I would like to hear!
Regards,

Tom Wolf

User avatar
Support Team
Site Admin
Site Admin
Posts: 12003
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Ranorex command line instrumentation on emulator

Post by Support Team » Fri Jul 26, 2019 8:55 pm

Hello Tomwolf,

I am happy to hear you can now instrument via command line, the error you are receiving is a known issue that is expected to be resolved with the release of 9.2. In the meantime, we do have a workaround which is outlined below.

1. For the workaround, you need the following two files which can be downloaded from https://upload.ranorex.com/s/Y4CXQmSnMpQpixr

2. Rename the apktool_4.2.1.jar to apktool.jar

3. Replace the old apktool.jar from the following folder with the new one: C:\Program Files (x86)\Ranorex <Ranorex Version>\Bin\RxEnv\Android\tools\apkTool

4. Delete the 1.apk file from the following directories (if available)
-%userprofile%\apktool\framework
-%localappdata%\apktool\framework
-%temp%

5. Unzip the appt.zip file and copy the files to:
-%temp%

6. Instrument your app using the Ranorex Instrumentation Wizard

Regards,
Sean
.
Image

tomwolf
Posts: 18
Joined: Tue Feb 26, 2019 9:04 am

Re: Ranorex command line instrumentation on emulator

Post by tomwolf » Mon Jul 29, 2019 2:46 pm

The workarround works.

Thanks for letting me know!
Regards,

Tom Wolf