Instrumention Failed

Mobile Testing, Android App Testing.
Erfan.khan
Posts: 1
Joined: Thu Mar 06, 2014 7:01 am

Instrumention Failed

Post by Erfan.khan » Thu Mar 06, 2014 7:50 am

Hello!

I can't seem to deploy my APK to my android. I'm following the android user guide. I am using latest Ranorex 5.0 and on android 500.apk.

I used the test one they recommend to deploy and that works fine, but when I try one of my own APK's I get the following:

Instrumentation failed...

Please make sure that
- The API is not obfuscated.
- You are using API level 8 or above.
- No uninstrumented APK version is installed on the device.

And the error details are:

System.Exception: Failed to recompile the instrumented code. See details for more information: I: Smaling...
I: Building resources...
libpng error: Not a PNG file
ERROR: Failure processing PNG image C:\Users\abc\AppData\Local\RanorexStudio5\RxEnv\Android\temp\decomp\res\drawable-640dpi\btn_facebook.png
C:\Users\abc\AppData\Local\RanorexStudio5\RxEnv\Android\temp\decomp\res\values\public.xml:70: error: Public symbol drawable/ach_bar_bg declared here is not defined.
C:\Users\abc\AppData\Local\RanorexStudio5\RxEnv\Android\temp\decomp\res\values\public.xml:177: error: Public symbol drawable/achievement1 declared here is not defined.
C:\Users\abc\AppData\Local\RanorexStudio5\RxEnv\Android\temp\decomp\res\values\public.xml:178: error: Public symbol drawable/achievement10 declared here is not defined.
C:\Users\abc\AppData\Local\RanorexStudio5\RxEnv\Android\temp\decomp\res\values\public.xml:179: error: Public symbol drawable/achievement11 declared here is not defined.
C:\Users\abc\AppData\Local\RanorexStudio5\RxEnv\Android\temp\decomp\res\values\public.xml:180: error: Public symbol drawable/achievement12 declared here is not defined.
C:\Users\abc\AppData\Local\RanorexStudio5\RxEnv\Android\temp\decomp\res\values\public.xml:181: error: Public symbol drawable/achievement2 declared here is not defined.

Any help would be great!

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

Re: Instrumention Failed

Post by Support Team » Mon Mar 10, 2014 5:04 pm

Hi Erfan,

Did you try to instrument a specific APK or does the issue occur with more than one APK-file?
Unfortunately we are not able to reproduce such a behavior. I may ask if it is possible for you to provide your APK-file to us. If yes, please send it to: [email protected]

Regards,
Robert
.
Image

lucian.teodorescu
Posts: 82
Joined: Fri Oct 24, 2014 10:58 am
Location: Bucharest

Re: Instrumention Failed

Post by lucian.teodorescu » Fri Dec 12, 2014 2:31 pm

Hi everyone,

I've also faced this issue. As the detailed report states, it was something about a PNG file.
After a few hours of reading forums and blogs, here is how I’ve fixed the problem: I’ve saved a copy of the <myFile>.png and edited 1 pixel. During the instrumentation (before recompilation) I’ve replaced the png from the app with the one edited by me (in \AppData\Local\RanorexStudio5\RxEnv\Android\temp\decomp\res\drawable). And… voila! It worked.

Of course, the easy way should be to remove the file from project, clean and rebuild.

Thanks,
Lucian
Lucian Teodorescu
NetSun Software

mumu
Posts: 8
Joined: Sun Oct 26, 2014 8:02 am

Re: Instrumention Failed

Post by mumu » Tue Jan 06, 2015 10:59 am

Hi guys,
I also face this problem but with different error detail.

System.Exception: Failed to decompile the APK file. See details for more information: Exception in thread "main" brut.androlib.AndrolibException: Could not decode arsc file
at brut.androlib.res.decoder.ARSCDecoder.decode(ARSCDecoder.java:54)
at brut.androlib.res.AndrolibResources.getResPackagesFromApk(AndrolibResources.java:604)
at brut.androlib.res.AndrolibResources.loadMainPkg(AndrolibResources.java:74)
at brut.androlib.res.AndrolibResources.getResTable(AndrolibResources.java:66)
at brut.androlib.Androlib.getResTable(Androlib.java:49)
at brut.androlib.ApkDecoder.decode(ApkDecoder.java:93)
at brut.apktool.Main.cmdDecode(Main.java:169)
at brut.apktool.Main.main(Main.java:85)
Caused by: java.io.IOException: Expected: 0x001c0001, got: 0x00000000
at brut.util.ExtDataInput.skipCheckInt(ExtDataInput.java:48)
at brut.androlib.res.decoder.StringBlock.read(StringBlock.java:43)
at brut.androlib.res.decoder.ARSCDecoder.readPackage(ARSCDecoder.java:95)
at brut.androlib.res.decoder.ARSCDecoder.readTable(ARSCDecoder.java:81)
at brut.androlib.res.decoder.ARSCDecoder.decode(ARSCDecoder.java:49)
... 7 more

at Ranorex.Plugin.Mobile.Tools.Android.Instrumentation.ApkFileInstrumenter.DecompileApkFile(String apkFilePath, Boolean showProcessWindows, IPathService pathService, InstrumentApkOptions deployOptions)
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)


Please help

krstcs
Ranorex Guru
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: Instrumention Failed

Post by krstcs » Tue Jan 06, 2015 2:36 pm

This is not the same error message as above. Yours says it failed to "DEcompile", the original says it failed to "REcompile".

My guess would be that your APK is obfuscated in some way (encrypted, etc.). Ranorex requires that the APK NOT be obfuscated, otherwise it can't de-compile it correctly.
Shortcuts usually aren't...

Tan111
Posts: 1
Joined: Mon Sep 21, 2015 5:02 pm

Re: Instrumention Failed

Post by Tan111 » Tue Jan 19, 2016 9:36 pm

Hello everyone,

I am facing the same problem.
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: 67005
at org.jf.dexlib2.writer.DexDataWriter.writeUshort(DexDataWriter.java:116)
at org.jf.dexlib2.writer.InstructionWriter.write(InstructionWriter.java:312)
at org.jf.dexlib2.writer.DexWriter.writeCodeItem(DexWriter.java:990)
at org.jf.dexlib2.writer.DexWriter.writeDebugAndCodeItems(DexWriter.java:769)
at org.jf.dexlib2.writer.DexWriter.writeTo(DexWriter.java:222)
at org.jf.dexlib2.writer.DexWriter.writeTo(DexWriter.java:200)
at brut.androlib.src.SmaliBuilder.build(SmaliBuilder.java:57)
at brut.androlib.src.SmaliBuilder.build(SmaliBuilder.java:41)
at brut.androlib.Androlib.buildSourcesSmali(Androlib.java:371)
at brut.androlib.Androlib.buildSources(Androlib.java:298)
at brut.androlib.Androlib.build(Androlib.java:282)
at brut.androlib.Androlib.build(Androlib.java:256)
at brut.apktool.Main.cmdBuild(Main.java:225)
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)


Appreciate your help!

Thanks!
Tan

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

Re: Instrumention Failed

Post by Support Team » Thu Jan 21, 2016 3:15 pm

Hello Tan,

Unfortunately, this exception comes from a third-party tool, which is used by Ranorex for the instrumentation process. We can offer you a solution for the issue. Please note that we cannot guarantee that the workaround will work for every APK. Minimum prerequisite for the workaround will be Ranorex 5.4.0.

Please follow the steps below:

1) Open the settings dialog in the Ranorex Android APK Instrumentation Wizard
instrumentation_wizard_settings.png
instrumentation_wizard_settings.png (15.58 KiB) Viewed 1534 times
2) Add "-static -multidex" to the Instrumentation Flags
instrumentation_flags.png
instrumentation_flags.png (13.12 KiB) Viewed 1534 times
If this doesn’t work, please try the same without the option "-static".

Please let us know if the described steps solved your issue.

Sincerely,
Johannes
.
Image

sajidbigler
Posts: 1
Joined: Wed Nov 09, 2016 7:38 am

Re: Instrumention Failed

Post by sajidbigler » Wed Nov 09, 2016 8:02 am

I tried both options
-static -multidex
or
-multidex

same error

please help...

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

Re: Instrumention Failed

Post by Support Team » Fri Nov 11, 2016 11:03 am

Hello sajidbigler,

Welcome to the Ranorex forum!

First, may I ask which version of Ranorex and Android you currently use?
Furthermore, please post the complete error message that you get during instrumentation. This would help us analyzing your issue.

Thank you in advance.

Sincerely,
Johannes
.
Image