Instrumentation fails on Android device

Mobile Testing, Android App Testing.
Chris G
Posts: 1
Joined: Thu Nov 25, 2021 9:11 am

Instrumentation fails on Android device

Post by Chris G » Thu Nov 25, 2021 9:31 am


I am currently trying to find out whether Ranorex would be a good addition for or company. I was trying to create some tests on an Android device, but the instrumentation failed unfortunately. I could not find any information regarding this specific topic in the documentation or in the forum. Maybe someone here can help me.

The instrumentation on the device always fails at 70% progress with following error (please see stacktrace below).

Ranorex version: 10.1.3
I made sure that the APK is not obfuscated.

Any help would be highly appreciated, thank you very much!

System.InvalidOperationException: Failed to recompile the instrumented code. See details for more information: Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
at org.jf.smali.smaliFlexLexer.newToken(
at org.jf.smali.smaliFlexLexer.newToken(
at org.jf.smali.smaliFlexLexer.yylex(
at org.jf.smali.smaliFlexLexer.nextToken(
at org.antlr.runtime.BufferedTokenStream.fetch(
at org.antlr.runtime.BufferedTokenStream.sync(
at org.antlr.runtime.CommonTokenStream.consume(
at org.antlr.runtime.BaseRecognizer.match(
at org.jf.smali.smaliParser.register_list(
at org.jf.smali.smaliParser.insn_format35c_method(
at org.jf.smali.smaliParser.instruction(
at org.jf.smali.smaliParser.ordered_method_item(
at org.jf.smali.smaliParser.statements_and_directives(
at org.jf.smali.smaliParser.method(
at org.jf.smali.smaliParser.smali_file(
at brut.androlib.mod.SmaliMod.assembleSmaliFile(
at brut.androlib.src.SmaliBuilder.buildFile(
at brut.androlib.Androlib.buildSourcesSmali(
at brut.androlib.Androlib.buildSources(
at brut.apktool.Main.cmdBuild(
at brut.apktool.Main.main(

bei Ranorex.Plugin.Mobile.Tools.Android.Instrumentation.ApkFileInstrumenter.CompileApkFile(String sourceApkFilePath, IPathService pathService)
bei Ranorex.Plugin.Mobile.Utils.BackgroundWorkerSupported.ExecuteBgwCode[TArg0,TArg1](BgwDelegate`2 methodDelegate, Int32 doneProgress, String progressText, TArg0 arg0, TArg1 arg1, BackgroundWorker bgw)
bei Ranorex.Plugin.Mobile.Tools.Android.Instrumentation.ApkFileInstrumenter.Instrument(String apkFilePath, InstrumentApkOptions deployOptions, BackgroundWorker bgw)
bei Ranorex.Plugin.Mobile.RxIntegration.Instrumentation.AndroidWorker.Run()
bei Ranorex.Controls.Instrumentation.ViewModels.Pages.DeployingAndroidAppPageViewModel.<>c__DisplayClass45_0.<DoAutoAdjustedInstrumentationWork>b__0()

Certified Professional
Certified Professional
Posts: 120
Joined: Mon Mar 22, 2021 10:01 pm

Re: Instrumentation fails on Android device

Post by Jacob » Fri Dec 03, 2021 5:31 pm

Hi Chris,

This error is from from the Java compiler (which recompiles the .apk file). Is it possible to free up or allocate any additional memory on the machine that is performing the instrumentation? From the contents of the error this seems the most likely culprit. If the instrumentation does fail at SMALI every time, it may be worth going into the advanced settings and configuring the SMALI option to the inverse of what is currently set.