Failed to recompile the instrumented code

Mobile Testing, Android App Testing.
alexkz
Posts: 4
Joined: Tue May 07, 2019 3:51 pm

Failed to recompile the instrumented code

Post by alexkz » Tue May 07, 2019 3:58 pm

Hi ,
Im Using Ranonex last version 9.0.1 and when im trying to run my apk in order for making test . In the End i received " Instrumentation Failed"
with :

System.Exception: Failed to recompile the instrumented code. See details for more information: S: WARNING: Could not write to (C:\Users\Alex\AppData\Local\apktool\framework), using C:\Users\Alex\AppData\Local\Temp\ instead...
S: Please be aware this is a volatile directory and frameworks could go missing, please utilize --frame-path if the default storage directory is unavailable
W: C:\Users\Alex\AppData\Local\RanorexStudio9\RxEnv\Android\temp\decomp\res\values\public.xml:50: error: Public symbol array/countries declared here is not defined.
W: C:\Users\Alex\AppData\Local\RanorexStudio9\RxEnv\Android\temp\decomp\res\values\public.xml:51: error: Public symbol array/currencies

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, InstrumentApkOptions deployOptions, BackgroundWorker bgw)
at Ranorex.Plugin.Mobile.RxIntegration.Instrumentation.AndroidWorker.Run()
at Ranorex.Controls.AndroidInstrumentProgressPage.bgw_DoWork(Object sender, DoWorkEventArgs e)

Cant run any apk i tried my apktool is last version and the Ranorex 9.0.1

Please help

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

Re: Failed to recompile the instrumented code

Post by Support Team » Tue May 07, 2019 7:40 pm

Hi alexkz,

This appears to be related to an old ApkTool bug. Please follow the steps below to manually update the ApkTool used by Ranorex.
  1. Download the newest version of the ApkTool (2.4.0) - https://bitbucket.org/iBotPeaches/apktool/downloads/
  2. Navigate to the following folder in the Ranorex install directory and rename the current apktool to apktool-old
    1.png
    1.png (10.77 KiB) Viewed 289 times
  3. Copy the downloaded apktool_2.4.0 to the same folder and rename to apktool so the folder should look like the below image
    2.png
    2.png (14.14 KiB) Viewed 289 times
  4. Delete any 1.apk files in your %userprofile%\apktool\framework or %localappdata%\apktool\framework or %temp%
  5. Instrument your APK via the Ranorex instrumentation wizard as usual with the appropriate instrumentation flags
Looking forward to hearing if this resolves the issue!

Regards,
Ned
.
Image

alexkz
Posts: 4
Joined: Tue May 07, 2019 3:51 pm

Re: Failed to recompile the instrumented code

Post by alexkz » Wed May 08, 2019 8:57 am

Hey ,
Thanks for reply , now i receive :

System.Exception: Failed to decompile the APK file. See details for more information: Error: Unable to access jarfile C:\Program Files (x86)\Ranorex\Studio\Bin\RxEnv\Android\tools\apkTool\apktool.jar

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, InstrumentApkOptions deployOptions, BackgroundWorker bgw)
at Ranorex.Plugin.Mobile.RxIntegration.Instrumentation.AndroidWorker.Run()
at Ranorex.Controls.AndroidInstrumentProgressPage.bgw_DoWork(Object sender, DoWorkEventArgs e)

McTurtle
Posts: 255
Joined: Thu Feb 23, 2017 10:37 am
Location: Benedikt, Slovenia

Re: Failed to recompile the instrumented code

Post by McTurtle » Wed May 08, 2019 12:55 pm

Hi alexkz,

Are you sure the "apktool.jar" is still there? While replacing it, you might have named it incorrectly.
Post a screenshot of the folder "C:\Program Files (x86)\Ranorex\Studio\Bin\RxEnv\Android\tools\apkTool". It's very likely that the "apktool.jar" is actually not there anymore or has a different name.

Regards,
McTurtle

alexkz
Posts: 4
Joined: Tue May 07, 2019 3:51 pm

Re: Failed to recompile the instrumented code

Post by alexkz » Wed May 08, 2019 1:11 pm

I have , see attachment . I even download new last version of apktool and rename it .

But maybe the issue also is when im going to cmd and writing : apktool
i have receiving : Unable to access jarfile C:\Windows\\apktool.jar
Attachments
image.PNG
image.PNG (13.86 KiB) Viewed 269 times

McTurtle
Posts: 255
Joined: Thu Feb 23, 2017 10:37 am
Location: Benedikt, Slovenia

Re: Failed to recompile the instrumented code

Post by McTurtle » Wed May 08, 2019 1:40 pm

Hello alexkz,

OK, I am a bit confused :)

Why are you even opening cmd and writing "apktool"? If you only open cmd from the stat menu and type "apktool" then you will get the error that you are getting. You need to navigate to the folder where the apk-tool is located and start it via "java -jar...". But why would you even try to do that?

Secondly, the screenshot in your last post says that the apk-tool is 10.7 MB large. However, apk-tool 2.4 is more than 15 MB large. So it seems that you did not do the steps suggested by Ned correctly :( Can you try again to replace the apk-tool and then use it via the Ranorex instrumentation wizard and not directly via cmd?

Regards,
McTurtle

alexkz
Posts: 4
Joined: Tue May 07, 2019 3:51 pm

Re: Failed to recompile the instrumented code

Post by alexkz » Wed May 08, 2019 1:51 pm

I did it and change to new one 15MB
and then i got too Ranorex Instrumentation Wizard and in the end i get : (the same i think)

System.Exception: Failed to decompile the APK file. See details for more information: Error: Unable to access jarfile C:\Program Files (x86)\Ranorex\Studio\Bin\RxEnv\Android\tools\apkTool\apktool.jar

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, InstrumentApkOptions deployOptions, BackgroundWorker bgw)
at Ranorex.Plugin.Mobile.RxIntegration.Instrumentation.AndroidWorker.Run()
at Ranorex.Controls.AndroidInstrumentProgressPage.bgw_DoWork(Object sender, DoWorkEventArgs e)

McTurtle
Posts: 255
Joined: Thu Feb 23, 2017 10:37 am
Location: Benedikt, Slovenia

Re: Failed to recompile the instrumented code

Post by McTurtle » Wed May 08, 2019 2:39 pm

Hi alexkz,

You also have file extensions disabled, else a *.bat would be visible for the batch file. That means that your apktool.jar is actually apktool.jar.jar.
apkTool.png
apkTool.png (23.04 KiB) Viewed 257 times
Enable the file extensions and then make sure the file does not have two extensions. Does it work now?

Regards,
McTurtle