Instrumentation failed... Error deploying .apk

Mobile Testing, Android App Testing.
Posts: 2
Joined: Tue Oct 25, 2016 2:08 pm

Instrumentation failed... Error deploying .apk

Post by Tomek » Wed Oct 26, 2016 2:33 pm

I'm new to Ranorex and I had a problem recently trying to deploy .apk file to Android device.

Here are the screenshots from Ranorex Instrumentation Wizard:
Ranorex_instrumentation_Wizard_Error.png (46.28 KiB) Viewed 1776 times
Also screen with Android SDK Manager Info installed on my PC:
Android_SDK_Manager.png (26.3 KiB) Viewed 1776 times
Detailed info concerning error:

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: 66637
at org.jf.dexlib2.writer.DexDataWriter.writeUshort(
at org.jf.dexlib2.writer.InstructionWriter.write(
at org.jf.dexlib2.writer.DexWriter.writeCodeItem(
at org.jf.dexlib2.writer.DexWriter.writeDebugAndCodeItems(
at org.jf.dexlib2.writer.DexWriter.writeTo(
at org.jf.dexlib2.writer.DexWriter.writeTo(
at brut.androlib.Androlib.buildSourcesSmali(
at brut.androlib.Androlib.buildSources(
at brut.apktool.Main.cmdBuild(
at brut.apktool.Main.main(

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)

System info:

Ranorex version 6.1.1,
Ms Windows 7 64-bit,

Considering making sure of potential reasons of the problem which are mentioned on screen,
1. The APK is not obfuscated,
2. The API are using is 17 (Android 4.2.2)
3. No other version on APK is not installed on the device.

Please, help overcome this problem since we are about to decide whether or not moving to Ranorex for mobile automate testing.


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

Re: Instrumentation failed... Error deploying .apk

Post by asdf » Thu Oct 27, 2016 3:17 pm

Hi Tomek,

Please try to set the instrumentation flag "-multidex" in the instrumentation wizard's settings.
Therefore, go to the instrumentation wizard and click on "Settings".
Ranorex Instrumentation Wizard.png
Ranorex Instrumentation Wizard.png (9.76 KiB) Viewed 1761 times
Afterwards, add "-multidex" to the field "Instrumentation Flags".
Settings.png (11.18 KiB) Viewed 1761 times
Hope this helps.

Kind regards,

Posts: 2
Joined: Tue Oct 25, 2016 2:08 pm

Re: Instrumentation failed... Error deploying .apk

Post by Tomek » Fri Oct 28, 2016 10:05 am

Thanks asdf, it helps.:).
Although there was another problem with timeout's , but I overcome this with settings in Ranorex Recorder package.