How to Fix Error “C:\Program Files (Access is Denied)” When Proguard has Enabled while Build a Android app

Why ?

When I was trying to build one of my android apps in “Release” mode to deploy, I got and Error that  “C:\Program Files (Access is Denied)” and the File was “PROGUARD”.

2-errror

Then I looked for a solution to avoid the error.

What is Proguard ?

The Reason For The Error

In the Android project, I have set the Proguard Enabled before I build the app.

The reason for the error is there is a space in the path to the PROGUARD. Proguard is in the Android folder in Program Files (x86) and there is a spaces between “Program Files (x86)”.

C:\Program Files (x86)\Android\android-sdk\tools\proguard

0-program-file-spaces

So PROGUARD may unable to find the path..

So How to Fix This ?

What we have to do is Place the android-sdk folder to a path without spaces..

To do that I created a symbolic Link(sym-link) ..

Here are steps to create a symbolic link..

1 .First we have to download and Install the  Link Shell Extension.

To Download the Link Shell Extension , Click Here .. 

2. After Installed the Extension then we are ready to create the sym-link.

How To Create a Symbolic Link, Click Here…

Here are steps How I created according to my Folder structure..

First I create a Folder in C: drive outside of Program Files x86 which is “AndroidSysLink”. So we have to Link the Android-SDK path to this folder.

First Go to Program Files x86 and Right Click on Android Folder and we can see a new context menu “Pick Link Source”. Then Click it..

1-pick

Then Go back and Select “AndroidSysLink” Folder -> Right Click . Then We can see a new context menu “Drop As” . When we click on it and we will see few options in another context menu. Then Select “Junction”. And then The link will be created.

2-drop-symbolic-link

3. Then We have to change the Android SDK path in Visual Studio.

So go to Tools -> Options -> Xamarin and Click the “change” button inside of the Android SDK location…

Then we can see a dialogue to select the sdk path..

3-existing-sdk-path

4. Go to the Linked folder and copy the path in it..

4-select-new-path

5. Paste the Path in the sdk-path selection dialogue box.

5-new-sdk-path

Then Click OK…

6. Now The Path has changed an Click OK to conform the new SDK path..

6-new-sdk-path

7. Now we are ready to release the app. But before Build the app recheck the configuration in properties.

First Verify Target Android versions..

0-selectandroid-versions

Make Sure the Confutation has set to “Release” and Proguard is Enabled..

1-enable-proguard

8. Then Build The app in Release Mode..

The app will build successfully..

3-build-success

9. Now we are ready to Archive the Android App.

Right Click on the Android project and click “Archive“…

4-archieve

We can see Archiving Progress…

5-archieving

We can see a Settings I con with a Green icon when the app has archived successfully and in the bottom of the dialogue we can see build information.

6-archieved-successfully

Click the “Open” folder and the created .apk file will see in that folder.

7-open-the-path

References…

https://developer.xamarin.com/guides/android/deployment,_testing,_and_metrics/publishing_an_application/part_1_-_preparing_an_application_for_release/

https://developer.xamarin.com/guides/android/application_fundamentals/cpu_architectures/

https://developer.xamarin.com/guides/android/deployment,_testing,_and_metrics/proguard/

https://www.howtogeek.com/howto/16226/complete-guide-to-symbolic-links-symlinks-on-windows-or-linux/

http://schinagl.priv.at/nt/hardlinkshellext/linkshellextension.html

https://forums.xamarin.com/discussion/45210/enable-proguard-error-c-program-files-access-is-denied

Thanks !

5 thoughts on “How to Fix Error “C:\Program Files (Access is Denied)” When Proguard has Enabled while Build a Android app

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s