Page 1 of 1

Failed to recompile the instrumented code

Posted: Tue May 07, 2019 3:58 pm
by alexkz
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

Re: Failed to recompile the instrumented code

Posted: Tue May 07, 2019 7:40 pm
by Support Team
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
  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
  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

Re: Failed to recompile the instrumented code

Posted: Wed May 08, 2019 8:57 am
by alexkz
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)

Re: Failed to recompile the instrumented code

Posted: Wed May 08, 2019 12:55 pm
by McTurtle
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

Re: Failed to recompile the instrumented code

Posted: Wed May 08, 2019 1:11 pm
by alexkz
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

Re: Failed to recompile the instrumented code

Posted: Wed May 08, 2019 1:40 pm
by McTurtle
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

Re: Failed to recompile the instrumented code

Posted: Wed May 08, 2019 1:51 pm
by alexkz
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)

Re: Failed to recompile the instrumented code

Posted: Wed May 08, 2019 2:39 pm
by McTurtle
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
Enable the file extensions and then make sure the file does not have two extensions. Does it work now?

Regards,
McTurtle