Page 1 of 1

Unable to instrument latest apk

Posted: Wed Mar 07, 2018 10:54 pm
by Mflow
Ranorex support,

On our latest release we are unable to instrument the apk, we get the following error:
System.Exception: Failed to recompile the instrumented code. See details for more information: Exception in thread "main" org.jf.util.ExceptionWithContext: Exception occurred while writing code_item for method Landroid/support/v4/util/LongSparseArray;->clone()Landroid/support/v4/util/LongSparseArray;
at org.jf.dexlib2.writer.DexWriter.writeDebugAndCodeItems(DexWriter.java:824)
at org.jf.dexlib2.writer.DexWriter.writeTo(DexWriter.java:267)
at org.jf.dexlib2.writer.DexWriter.writeTo(DexWriter.java:245)
at brut.androlib.src.SmaliBuilder.build(SmaliBuilder.java:61)
at brut.androlib.src.SmaliBuilder.build(SmaliBuilder.java:36)
at brut.androlib.Androlib.buildSourcesSmali(Androlib.java:423)
at brut.androlib.Androlib.buildNonDefaultSources(Androlib.java:369)
at brut.androlib.Androlib.build(Androlib.java:311)
at brut.androlib.Androlib.build(Androlib.java:267)
at brut.apktool.Main.cmdBuild(Main.java:230)
at brut.apktool.Main.main(Main.java:83)
Caused by: org.jf.util.ExceptionWithContext: Error while writing instruction at code offset 0x15
at org.jf.dexlib2.writer.DexWriter.writeCodeItem(DexWriter.java:1091)
at org.jf.dexlib2.writer.DexWriter.writeDebugAndCodeItems(DexWriter.java:820)
... 10 more
Caused by: org.jf.util.ExceptionWithContext: Unsigned short value out of range: 65553
at org.jf.dexlib2.writer.DexDataWriter.writeUshort(DexDataWriter.java:116)
at org.jf.dexlib2.writer.InstructionWriter.write(InstructionWriter.java:348)
at org.jf.dexlib2.writer.DexWriter.writeCodeItem(DexWriter.java:1051)
... 11 more


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.Plugin.Mobile.RxIntegration.Instrumentation.AndroidWorker.Run()
at Ranorex.Controls.AndroidInstrumentProgressPage.bgw_DoWork(Object sender, DoWorkEventArgs e)
We are using the following:
Ranorex 8.0.1
apktook - 2.3.1
unobfuscated apk

We've usually instrument using the -static -multidex flags, but that doesn't work this time.
Any help would be very much appreciated.

Re: Unable to instrument latest apk

Posted: Thu Mar 08, 2018 2:51 pm
by Support Team
Hi Mflow,

May I ask you to write an email to [email protected] in order to analyze this issue?
It would be great if you could provide the used *.apk file in this email as well.

Thank you in advance.

Best regards,
Matthias

Re: Unable to instrument latest apk

Posted: Tue Mar 13, 2018 4:56 pm
by Mflow
I have contacted support and sent all the required files, but still haven't gotten a response. This issue is a real problem now and I still don't know why this happened.

Any response would be appreciated, Case-00050628.

Re: Unable to instrument latest apk

Posted: Tue Mar 13, 2018 9:08 pm
by Support Team
Hello MFlow,

I am sorry to hear you are having difficulty instrumenting your APK. Your support query was answered within the expected timeframe for a reply; please let me know if you did not receive the reply as I would be happy to resend it. Of course, we always try to help our customers as quickly as possible, but please know that the standard response time is within 24 to 48 hours. May I ask if you have made any progress since receiving the reply to your support query? If you are still experiencing issues I would be more than happy to help you get this resolved!

I hope this helps!

-Jon

Re: Unable to instrument latest apk

Posted: Fri May 25, 2018 2:19 pm
by Support Team
Hi all,

We've released a fix for this problem in Ranorex 8.1.1. In order to instrument an Android application which fails with this error message, you have to use the instrumentation flags: "-static -multidex -smali_redist"
Instrumentation.png
I hope this helps!

Best regards,
Matthias
Ranorex Support Team