Unable to instrument latest apk

Mobile Testing, Android App Testing.
Mflow
Posts: 2
Joined: Wed Mar 07, 2018 10:24 pm

Unable to instrument latest apk

Post by Mflow » Wed Mar 07, 2018 10:54 pm

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.

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

Re: Unable to instrument latest apk

Post by Support Team » Thu Mar 08, 2018 2:51 pm

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
.
Image

Mflow
Posts: 2
Joined: Wed Mar 07, 2018 10:24 pm

Re: Unable to instrument latest apk

Post by Mflow » Tue Mar 13, 2018 4:56 pm

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.

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

Re: Unable to instrument latest apk

Post by Support Team » Tue Mar 13, 2018 9:08 pm

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
.
Image

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

Re: Unable to instrument latest apk

Post by Support Team » Fri May 25, 2018 2:19 pm

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
Instrumentation.png (10.21 KiB) Viewed 422 times
I hope this helps!

Best regards,
Matthias
Ranorex Support Team
.
Image