Page 1 of 1

instrumentation fail on time in code ignores limit

Posted: Mon Mar 23, 2015 1:25 pm
by zivshapirawork
I tried to instrument an apk file using Ranorex 5.3.0 and RC4 apktool.

I received the following error that the instrumentation did not complete in the default time (2 min)
System.TimeoutException: Process did not finish within the specified timeout of '00:02:00'.
at Ranorex.Core.ProcessRunner.RunShortProcess(Boolean showWindow, TimeSpan timeout, IList`1 appendToPath)
at Ranorex.Plugin.Mobile.Tools.Android.Instrumentation.ApkFileInstrumenter.CompileApkFile(String sourceApkFilePath, IPathService pathService)
at Ranorex.Plugin.Mobile.Utils.BackgroundWorkerSupported.ExecuteBgwCode[TArg0,TArg1](BgwDelegate`2 methodDelegate, Int32 doneProgress, String progressText, TArg0 arg0, TArg1 arg1, BackgroundWorker bgw)
at Ranorex.Plugin.Mobile.Tools.Android.Instrumentation.ApkFileInstrumenter.Instrument(String apkFilePath, Int32 port, InstrumentApkOptions deployOptions, BackgroundWorker bgw)
at Ranorex.Controls.Instrumentation.Workers.AndroidWorker.Run()
at Ranorex.Controls.AndroidInstrumentProgressPage.bgw_DoWork(Object sender, DoWorkEventArgs e)
I wrote instrumentation code in a recording, so that I can add more time to the default.

Code: Select all

using System.Threading;
using WinForms = System.Windows.Forms;

using Ranorex;
using Ranorex.Core;
using Ranorex.Core.Testing;

namespace ParkinsonAutomation
{
    public partial class DeployAppToDevice
    {
        /// <summary>
        /// This method gets called right after the recording has been started.
        /// It can be used to execute recording specific initialization code.
        /// </summary>
        private void Init()
        {
            // Your recording specific initialization code goes here.
        }

        public void DeployAppToDevice_Deploy_Android_App(string apkname)
        {
        	var _ts = new TimeSpan(0,20,0);
            Report.Log(ReportLevel.Info, "Application", "Deploying android app 'C:\\Users\\user\\Downloads\\" + apkname + ".apk' to device 'automation-android-1'.");

            Host.Local.InstrumentAndDeployAndroidApp("automation-android-1", 
                                                     "C:\\Users\\user\\Downloads\\" + apkname + ".apk", 
                                                     true, 
                                                     Host.DeploymentModes.Usb,
                                                     new Duration(_ts)
                                                    );
        }

    }
}
although I had coded 20 minutes, running the recording still failed after 2 minutes (below) and the error is the same as from the Ranorex IDE instrumentation option.

has anyone encountered the issue of instrumentation code ignoring the allocated duration?
Instrumentation failed. Error:
Process did not finish within the specified timeout of '00:02:00'.

Info: Exec: C:\Program Files\Java\jre7\bin\java.exe -jar "C:\Program Files (x86)\Ranorex 5.3\Bin\RxEnv\Android\tools\apkTool\apktool.jar" d "C:\Users\zshapira\AppData\Local\RanorexStudio5\RxEnv\Android\temp\xxxxxxx.apk" -f -o "C:\Users\zshapira\AppData\Local\RANORE~1\RxEnv\Android\temp\decomp"
Info: Decompiling APK File.
Info: Processing file 'xxxx.smali' (Pass2).
...
...
...
Info: Recompiling APK File.

Ranorex.Instrumentation.exe /help -- Display general help.
Ranorex.Instrumentation.exe /pagename:n /help -- display specific help.

d, device The name of the device to that the APK file shall be
deployed. This parameter is not required if deploymode is set
to 'NoDeploy'.

a, apkfile Required. The path where the APK file resides.

s, skip Default is False. Set this switch to skip APK file
instrumentation prior to deploying.

dm, deploymode Possible Values: WiFi, Usb, NoDeploy, Auto. Default is Auto.
Specifies how the apk file shall be deployed. Set to nodeploy
if the file shall not be deployed to the device. Auto means
the connection mechanism used to configure the device will be
used.

o, outfile Sets a custom output location for the instrumented file. This
can be a directory or a file path. Read/Write permission is
required for this path. If a directory was specified, (to
specify a directory add a trailing '\') the process will
place the APK file in it with the -instrumented suffix added
to the source file name. If the file already exists it will
be overwritten. This option only has a effect if an APK is
instrumented (no skip).

p, pagename Default is UserSelect. Set this option to directly navigate
to a specific page. Is also required for automated command
line based instrumentation. Pages are: android, chrome,
firefox, flex, ios, java, safari. Note: The default 'Select'
is not supported in the command line.

?, help Default is False. Displays command line arguments help.

Re: instrumentation fail on time in code ignores limit

Posted: Mon Mar 23, 2015 2:21 pm
by lucian.teodorescu
Hi Ziv,

Did you try setting the "Instrument timeout" to 20m in Global Settings>Plugins/Mobile?

Give it a try and let us know the results.

Lucian

Re: instrumentation fail on time in code ignores limit

Posted: Mon Mar 23, 2015 3:49 pm
by zivshapirawork
Hi Lucian

Thank you for the guidance. Changing the Global Settings solved the issue both via Ranorex and via code :)

I am leaving this thread open, because it is reporting an issue with the instrumentation via the code, which seems to ignore the given duration in the code and use the global settings instead, unless I am missing something.

/ziv

Re: instrumentation fail on time in code ignores limit

Posted: Thu Mar 26, 2015 2:00 pm
by Support Team
Hello Ziv,

Thank you for reporting this issue, we will analyze it and try to fix it as soon as possible.

Regards,
Robert

Re: instrumentation fail on time in code ignores limit

Posted: Mon Jul 20, 2015 12:05 pm
by zivshapirawork
Hi has anything happened with this? using Ranorex 5.4.0 and getting the issue

Code: Select all

	var _ts = new TimeSpan(0,20,0);

	Host.Local.InstrumentAndDeployAndroidApp(devicename,
			                                         apkname + ".apk",
			                                         true,
			                                         Host.DeploymentModes.Usb,
			                                         new Duration(_ts), 
			                                         o
			                                        );
and the error for fail after 2 min even though the timeout is 20 min. Deployment from the studio is ok.
System.Exception : Instrumentation failed. Error:
Process did not finish within the specified timeout of '00:02:00'.

Re: instrumentation fail on time in code ignores limit

Posted: Tue Jul 21, 2015 8:29 am
by Support Team
Hello Ziv,

We are still working on this known issue. I will update the forum as soon as we found a solution.

Thank you for your patience.

Regards,
Robert