Error while instrumenting Android Application

Bug reports.
ravikohli2002
Posts: 4
Joined: Mon Dec 19, 2016 8:26 pm

Error while instrumenting Android Application

Post by ravikohli2002 » Tue Dec 20, 2016 5:04 pm

I am facing error when instrumenting apk. Error details:
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: 65752
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:63)
at brut.androlib.src.SmaliBuilder.build(SmaliBuilder.java:38)
at brut.androlib.Androlib.buildSourcesSmali(Androlib.java:405)
at brut.androlib.Androlib.buildSources(Androlib.java:336)
at brut.androlib.Androlib.build(Androlib.java:292)
at brut.androlib.Androlib.build(Androlib.java:264)
at brut.apktool.Main.cmdBuild(Main.java:227)
at brut.apktool.Main.main(Main.java:84)


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)

This blocks from using Ranorex further. Please provide your suggestions. I am using latest version of Ranorex.

Thanks,

Ravi

asdf
Posts: 174
Joined: Mon Mar 21, 2016 3:16 pm

Re: Error while instrumenting Android Application

Post by asdf » Tue Dec 20, 2016 5:18 pm

Hi Ravi,

In order to overcome your issue, please add "-static" and "-multidex" to your instrumentation flags.
Therefore, open the "Settings" dialog in the Ranorex Instrumentation Wizard.
2016-12-20 17_15_28-Ranorex Instrumentation Wizard.png
2016-12-20 17_15_28-Ranorex Instrumentation Wizard.png (9.76 KiB) Viewed 709 times
Afterwards, please add the mentioned flags in the instrumentation options.
2016-12-20 17_16_24-Settings.png
2016-12-20 17_16_24-Settings.png (11.31 KiB) Viewed 709 times
I hope this helps.

Kind regards,
asdf

ravikohli2002
Posts: 4
Joined: Mon Dec 19, 2016 8:26 pm

Re: Error while instrumenting Android Application

Post by ravikohli2002 » Tue Dec 20, 2016 5:45 pm

Thanks asdf. It worked like a charm!!