Enable Proguard error 'C:\Program Files (Access is Denied)'

GeraldVersluisGeraldVersluis ✭✭✭✭NLUniversity ✭✭✭✭
edited July 2015 in Xamarin.Android

In an attempt to size down my APK package I noticed that Xamarin now has built-in support for Proguard, awesome!

However I can't get it to work, which is not so awesome.

While building it gives me the error 'C:\Program Files (Access is Denied)'. It looks to me like an error because of the fact that the path contains spaces.
I've tried to edit my Java SDK path to the 8.3 notation but looking at the Output Window (see below), Xamarin still uses some other paths which I can't influence (at least not that I know of).

Running from a separate command-line with all 'Program Files (x86)' replaced by 'Progra~2', produces a valid error message which probably is because it isn't part of the build process anymore.

Anyone came across this or has any idea how to make it work?

I'm running;

  • Windows 10
  • Visual Studio 2015
  • Xamarin.Android 5.1.4.16

--- Output Window --> -

3>Using "Proguard" task from assembly "C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Build.Tasks.dll".
3>Task "Proguard"
3> Proguard
3> JavaPlatformJarPath: C:\Progra~2\Android\android-sdk\platforms\android-22\android.jar
3> MonoPlatformJarPath: C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\MonoAndroid\v5.0\mono.android.jar
3> ClassesOutputDirectory: obj\Release\android\bin\classes
3> ProguardGeneratedApplicationConfiguration: obj\Release\proguard\proguard_project_primary.cfg
3> ProguardJarInput: obj\Release\proguard__proguard_input__.jar
3> ProguardJarOutput: obj\Release\proguard__proguard_output__.jar
3> ProguardConfigurationFiles:
3>
3> {sdk.dir}tools\proguard\proguard-android.txt;
3> {intermediate.common.xamarin};
3> {intermediate.references};
3> {intermediate.application};
3> ;
3>
3> JavaSourceFiles:
3> JavaLibraries:
3> ExternalJavaLibraries:
3> DoNotPackageJavaLibraries:
3> LibraryProjectJars:
3> obj\Release__library_projects__\FormsViewGroup\library_project_imports\formsviewgroup.jar
3> UseProguard: False
3> EnableLogging: False
3> DumpOutput: obj\Release\proguard\dump.txt
3> PrintSeedsOutput: obj\Release\proguard\seeds.txt
3> PrintMappingOutput: obj\Release\proguard\mapping.txt
3> Environment Variables passed to tool:
3> java_tool_options= -Dfile.encoding=UTF8
3> proguard_home=C:\Program Files (x86)\Android\android-sdk\tools\proguard
3> C:\Progra~2\Java\jdk1.7.0_55\bin\java.exe -jar "C:\Progra~2\Android\android-sdk\tools\proguard\lib\proguard.jar" -include "C:\Program Files (x86)\Android\android-sdk\tools\proguard\proguard-android.txt" -include obj\Release\proguard\proguard_xamarin.cfg -include obj\Release\proguard\proguard_project_references.cfg -include obj\Release\proguard\proguard_project_primary.cfg "-injars 'obj\Release\proguard__proguard_input__.jar';'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\MonoAndroid\v5.0\mono.android.jar';'obj\Release__library_projects__\FormsViewGroup\library_project_imports\formsviewgroup.jar';'C:\Users\Gerald\Source\Workspaces\FourDotNet\FourDotNet\packages\Xamarin.GooglePlayServices.22.0.0.2\lib\MonoAndroid41\22.0.0\embedded\classes.jar';'C:\Users\Gerald\AppData\Local\Xamarin\Android.Support.v4\22.2.0\embedded\classes.jar';'C:\Users\Gerald\AppData\Local\Xamarin\Android.Support.v4\22.2.0\embedded\libs\internal_impl-22.2.0.jar';'C:\Users\Gerald\AppData\Local\Xamarin\Android.Support.v7.AppCompat\22.2.0\embedded\classes.jar';'C:\Users\Gerald\AppData\Local\Xamarin\Android.Support.v7.MediaRouter\22.2.0\embedded\classes.jar';'C:\Users\Gerald\AppData\Local\Xamarin\Android.Support.v7.MediaRouter\22.2.0\embedded\libs\internal_impl-22.2.0.jar'" "-libraryjars 'C:\Progra~2\Android\android-sdk\platforms\android-22\android.jar'" -outjars "obj\Release\proguard__proguard_output__.jar"
3>PROGUARD : error : C:\Program Files (Access is denied)
3> Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF8
3> The command exited with code 1.
3>Done executing task "Proguard" -- FAILED.

Best Answers

Answers

  • EricSchmeckEricSchmeck ✭✭ DEMember ✭✭

    Same error message for me when I enable Proguard
    C:\Program Files (Access is denied)
    Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF8

  • GeraldVersluisGeraldVersluis ✭✭✭✭ NLUniversity ✭✭✭✭

    Yesterday I have tried the exact same project in Xamarin Studio on a Mac, worked perfectly there. So that could be a workaround, nevertheless this should be fixed.

    Think I will have to file a bug report then!

  • zahikramerzahikramer ✭✭✭ ILMember ✭✭✭

    +1 for me. same problem

  • zahikramerzahikramer ✭✭✭ ILMember ✭✭✭
  • GeraldVersluisGeraldVersluis ✭✭✭✭ NLUniversity ✭✭✭✭

    Good! Never got around to opening a bug, sorry.

  • AlexPryiomkaAlexPryiomka USMember

    I did run into same problem. I ran C:\Windows\system32>mklink /J C:\ProgramFiles\Android "C:\Program Files (x86)\An
    droid" to link C:\Program Files (x86)\Android to C:\ProgramFiles\Android, but the build is still looking at the C:\Program Files (x86)\Android\android-sdk\tools\proguard\lib\proguard.jar folder? What did I do wrong. BTW, the provided link to the "fix" is very confusing since it doesn't tell what map to what, it just say "just create a sym-link to a path without spaces". I did exactly that, but no luck... Any advice anyone? I don't have mac to build the app, i need to fix it on windows.

    Thank you for the advice.

    Target _CompileToDalvik:

    C:\Program Files\Java\jdk1.7.0_75\\bin\java.exe -jar "C:\Program Files (x86)\Android\android-sdk\tools\proguard\lib\proguard.jar" -include "C:\Program Files (x86)\Android\android-sdk\tools\proguard\proguard-android.txt" -include obj\Release\proguard\proguard_xamarin.cfg -include obj\Release\proguard\proguard_project_references.cfg -include obj\Release\proguard\proguard_project_primary.cfg "-injars 'obj\Release\proguard\__proguard_input__.jar';'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\MonoAndroid\v5.1\mono.android.jar';'obj\Release\__library_projects__\FloatingActionButton-Xamarin\library_project_imports\bin\classes.jar';'C:\Users\Alex\AppData\Local\Xamarin\Android.Support.v4\22.2.0\embedded\classes.jar';'C:\Users\Alex\AppData\Local\Xamarin\Android.Support.v4\22.2.0\embedded\libs\internal_impl-22.2.0.jar';'C:\Users\Alex\AppData\Local\Xamarin\Android.Support.v7.AppCompat\22.2.0\embedded\classes.jar';'C:\Users\Alex\AppData\Local\Xamarin\Android.Support.v7.CardView\22.2.0\embedded\classes.jar';'C:\Users\Alex\AppData\Local\Xamarin\Android.Support.v7.RecyclerView\22.2.0\embedded\classes.jar';'C:\Users\Alex\AppData\Local\Xamarin\GooglePlayServices.Base\25.0.0\embedded\classes.jar';'C:\Users\Alex\AppData\Local\Xamarin\GooglePlayServices.Maps\25.0.0\embedded\classes.jar'" "-libraryjars 'C:\Program Files (x86)\Android\android-sdk\platforms\android-22\android.jar'" -outjars "obj\Release\proguard\__proguard_output__.jar" 
    
    PROGUARD : error : C:\Program Files (Access is denied)
    
  • AjaySharma.5121AjaySharma.5121 USMember

    Ljusnan: Thank you, its works

  • MarcMagninMarcMagnin ✭✭ FRMember ✭✭

    Same problem as Alex.
    After creating the link I still have the issue. It set the previous path automatically when I start the build process.
    Any other way to set it ?

  • After change the path I had still problem, so I did clean solution and after it build project again.
    Now it is working for me.

  • seattlecreationsseattlecreations USMember

    This should be fixed by now. It's been a year, and most Windows devs trying to use Proguard are going to hit this.

  • MichaelRumplerMichaelRumpler ✭✭✭✭✭ ATMember ✭✭✭✭✭

    The bug is still there. IMHO @zahikramer should reopen it (change the status in bugzilla).
    It's good to have a workaround, but it should work out of the box.

  • zahikramerzahikramer ✭✭✭ ILMember ✭✭✭

    For your request @MichaelRumpler , just reopen it.
    Regards.

  • AngelieriAngelieri ✭✭ USMember ✭✭

    I followed the procedure (mklink, Xamarin Config clear BIN/OBJ) but no success.
    The error changed to:
    "java.exe" exited with code 1. MyApp.Droid

  • AaronClausen.0025AaronClausen.0025 ✭✭ USMember ✭✭

    Yep I just got this error still today. shocking that something this simple doesn't work out of the box. Come on Xamarin!

  • AaronClausen.0025AaronClausen.0025 ✭✭ USMember ✭✭

    What a dodgy, nasty hack to have to do. Xamarin should have this all sorted OOTB.

    I ran this command: mklink /D c:\ProgFiles86 "c:\Program files (x86)"

    And then went into VS -> Settings -> Xamarin -> and changed the Java SDK folder to exactly what it was, but using the new C:\ProgFiles86..... path. Then rebuilt the project, and it now got past the Access Denied error, but is now throwing a new one "java.exe" exited with code 1.

    Overall polishing of Xamarin is still lacking hardcore big time :(

  • DidsDids ✭✭ FIMember ✭✭

    To add to the solution by @JohnOsborn, make sure you adjust your proguard.cfg accordingly.

    In my case, I ended up with this:

    -dontwarn okio.**
    -dontwarn java.nio.**
    -dontwarn java.lang.invoke.**
    

    Not entirely sure if I need to add "-keep" for any of them, but I'm assuming not.

  • JDNickellJDNickell USMember

    This is what worked for me thanks to @JohnOsborn and his listed references:

    • Run in cmd prompt: mklink /j C:\android-sdk "C:\Program Files (x86)\Android\android-sdk"
    • Download newest version of ProGuard https://sourceforge.net/projects/proguard/files/
    • Rename existing ProGuard folder to ProGuard-Old, copy new ProGuard folder to that directory.

      • Mine was at C:\Program Files (x86)\Android\android-sdk\tools\proguard
    • Copy these files from your ProGuard-Old folder to ProGuard (proguard-android.txt, proguard-android-optimize.txt, proguard-project.txt)

    • In Visual Studio Tools>Options>Xamarin>Android Settings, change the AndroidSDK location to the path created in previous step: C:\android-sdk
  • SimonScoffinsSimonScoffins ✭✭ USUniversity ✭✭

    @JohnOsborn, @JDNickell: Worked for me thanks.

  • MaikelTunnissenMaikelTunnissen USMember
    edited April 2017

    .

  • EliasRinconEliasRincon USMember

    @zahikramer said:
    Problem Solved.
    here:
    blog.threescreenstudios.com/publishing-with-xamarin-android-pt-1-build-options/

    proguard doesn't like space in the path, so if you do, add symlink (on windows)

    The link is now broken

  • ShubhraPandeyShubhraPandey ✭✭ USMember ✭✭
    edited August 2017
Sign In or Register to comment.