Page 1 of 1

Error while intrumenting

Posted: Wed Jun 08, 2016 3:13 am
by wellingtonsantana
Hello!
While I'm trying to instrument an .APK file, Ranorex returns an error like below and with this description.
Can you help me to fix this problem?

Code: Select all

System.Exception: Failed to recompile the instrumented code. See details for more information: Exception in thread "main" org.jf.util.ExceptionWithContext: Unsigned short value out of range: 65564
	at org.jf.dexlib2.writer.DexDataWriter.writeUshort(DexDataWriter.java:116)
	at org.jf.dexlib2.writer.InstructionWriter.write(InstructionWriter.java:329)
	at org.jf.dexlib2.writer.DexWriter.writeCodeItem(DexWriter.java:1027)
	at org.jf.dexlib2.writer.DexWriter.writeDebugAndCodeItems(DexWriter.java:803)
	at org.jf.dexlib2.writer.DexWriter.writeTo(DexWriter.java:252)
	at org.jf.dexlib2.writer.DexWriter.writeTo(DexWriter.java:230)
	at brut.androlib.src.SmaliBuilder.build(SmaliBuilder.java:57)
	at brut.androlib.src.SmaliBuilder.build(SmaliBuilder.java:41)
	at brut.androlib.Androlib.buildSourcesSmali(Androlib.java:385)
	at brut.androlib.Androlib.buildSources(Androlib.java:312)
	at brut.androlib.Androlib.build(Androlib.java:295)
	at brut.androlib.Androlib.build(Androlib.java:268)
	at brut.apktool.Main.cmdBuild(Main.java:225)
	at brut.apktool.Main.main(Main.java:84)


   em Ranorex.Plugin.Mobile.Tools.Android.Instrumentation.ApkFileInstrumenter.CompileApkFile(String sourceApkFilePath, IPathService pathService)
   em Ranorex.Plugin.Mobile.Utils.BackgroundWorkerSupported.ExecuteBgwCode[TArg0,TArg1](BgwDelegate`2 methodDelegate, Int32 doneProgress, String progressText, TArg0 arg0, TArg1 arg1, BackgroundWorker bgw)
   em Ranorex.Plugin.Mobile.Tools.Android.Instrumentation.ApkFileInstrumenter.Instrument(String apkFilePath, Int32 port, InstrumentApkOptions deployOptions, BackgroundWorker bgw)


   em Ranorex.Controls.Instrumentation.Workers.AndroidWorker.Run()
   em Ranorex.Controls.AndroidInstrumentProgressPage.bgw_DoWork(Object sender, DoWorkEventArgs e)

Re: Error while intrumenting

Posted: Fri Jun 10, 2016 9:10 am
by Support Team
Hello wellingtonsantana,

May I ask which version of Ranorex are you using?
There is a possible workaround for this issue described in the forum post "deployment of apk with instrumentation raises Exception"

I hope this solves your problem.

Regards,
Bernhard

Re: Error while intrumenting

Posted: Mon Jul 04, 2016 8:38 pm
by wellingtonsantana
Hello guys!
My problemn persists :cry: .
I'm using Ranorex 6.0 with Windows 10, smartphone is Android 5.0.2.

Without the tags "-static -multidex", this error is displayed

Code: Select all

System.Exception: Failed to recompile the instrumented code. See details for more information: Exception in thread "main" org.jf.util.ExceptionWithContext: Unsigned short value out of range: 66057
	at org.jf.dexlib2.writer.DexDataWriter.writeUshort(DexDataWriter.java:116)
	at org.jf.dexlib2.writer.InstructionWriter.write(InstructionWriter.java:329)
	at org.jf.dexlib2.writer.DexWriter.writeCodeItem(DexWriter.java:1027)
	at org.jf.dexlib2.writer.DexWriter.writeDebugAndCodeItems(DexWriter.java:803)
	at org.jf.dexlib2.writer.DexWriter.writeTo(DexWriter.java:252)
	at org.jf.dexlib2.writer.DexWriter.writeTo(DexWriter.java:230)
	at brut.androlib.src.SmaliBuilder.build(SmaliBuilder.java:53)
	at brut.androlib.src.SmaliBuilder.build(SmaliBuilder.java:38)
	at brut.androlib.Androlib.buildSourcesSmali(Androlib.java:364)
	at brut.androlib.Androlib.buildSources(Androlib.java:295)
	at brut.androlib.Androlib.build(Androlib.java:278)
	at brut.androlib.Androlib.build(Androlib.java:254)
	at brut.apktool.Main.cmdBuild(Main.java:224)
	at brut.apktool.Main.main(Main.java:84)


   em Ranorex.Plugin.Mobile.Tools.Android.Instrumentation.ApkFileInstrumenter.CompileApkFile(String sourceApkFilePath, IPathService pathService)
   em Ranorex.Plugin.Mobile.Utils.BackgroundWorkerSupported.ExecuteBgwCode[TArg0,TArg1](BgwDelegate`2 methodDelegate, Int32 doneProgress, String progressText, TArg0 arg0, TArg1 arg1, BackgroundWorker bgw)
   em Ranorex.Plugin.Mobile.Tools.Android.Instrumentation.ApkFileInstrumenter.Instrument(String apkFilePath, Int32 port, InstrumentApkOptions deployOptions, BackgroundWorker bgw)
   em Ranorex.Controls.Instrumentation.Workers.AndroidWorker.Run()
   em Ranorex.Controls.AndroidInstrumentProgressPage.bgw_DoWork(Object sender, DoWorkEventArgs e)
With the tags

Code: Select all

System.TimeoutException: Process did not finish within the specified timeout of '00:02:00'.
   em Ranorex.Core.ProcessRunner.RunShortProcess(Boolean showWindow, TimeSpan timeout, IList`1 appendToPath, String workingDir)
   em Ranorex.Plugin.Mobile.Tools.Android.Instrumentation.ApkFileInstrumenter.CompileApkFile(String sourceApkFilePath, IPathService pathService)
   em Ranorex.Plugin.Mobile.Utils.BackgroundWorkerSupported.ExecuteBgwCode[TArg0,TArg1](BgwDelegate`2 methodDelegate, Int32 doneProgress, String progressText, TArg0 arg0, TArg1 arg1, BackgroundWorker bgw)
   em Ranorex.Plugin.Mobile.Tools.Android.Instrumentation.ApkFileInstrumenter.Instrument(String apkFilePath, Int32 port, InstrumentApkOptions deployOptions, BackgroundWorker bgw)
   em Ranorex.Controls.Instrumentation.Workers.AndroidWorker.Run()
   em Ranorex.Controls.AndroidInstrumentProgressPage.bgw_DoWork(Object sender, DoWorkEventArgs e)

Re: Error while intrumenting

Posted: Tue Jul 05, 2016 2:09 pm
by Support Team
Hello wellingtonsantana,

Unfortunately, the "-static -multidex" flag is necessary in order to overcome this type of error. When enabling this flag, Ranorex needs more time deploy the app to the device. Please try to increase the deploy timeout (e.g. to 5 minutes) and check if the issue still persists.

Regards,
Bernhard

Re: Error while intrumenting

Posted: Fri Aug 26, 2016 10:28 pm
by wellingtonsantana
Hello,
Just an update.
After install Ranorex 6.0.1, instrumentation is working fine.
Thanks all.