Bug 27142 - Write External Storage permission added even if not in AndroidManifest
Summary: Write External Storage permission added even if not in AndroidManifest
Status: RESOLVED ANSWERED
Alias: None
Product: Visual Studio Extensions
Classification: Xamarin
Component: Android ()
Version: unspecified
Hardware: PC Windows
: Highest blocker
Target Milestone: ---
Assignee: Dominique Louis
URL:
Depends on:
Blocks:
 
Reported: 2015-02-17 08:51 UTC by Adam Kapos
Modified: 2016-08-03 15:24 UTC (History)
10 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED ANSWERED

Description Adam Kapos 2015-02-17 08:51:29 UTC
I encountered this after updating Xamarin Studio from 3.9.274 (not publicly released build which fixed a VS freeze) to 3.9.289.

Original manifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.something.something" android:versionCode="1" android:versionName="1.0.0.0" android:installLocation="auto">
	<uses-sdk android:minSdkVersion="16" />
	<application android:label="Test" android:icon="@drawable/appicon"></application>
	<uses-permission android:name="android.permission.INTERNET" />
	<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
	<uses-permission android:name="com.android.vending.BILLING" />
</manifest>

Manifest in APK:
u s e s - p e r m i s s i o n    a n d r o i d . p e r m i s s i o n . I N T E R N E T   ( a n d r o i d . p e r m i s s i o n . R E A D _ E X T E R N A L _ S T O R A G E    c o m . a n d r o i d . v e n d i n g . B I L L I N G   ) a n d r o i d . p e r m i s s i o n . W R I T E _ E X T E R N A L _ S T O R A G E 

Google Play also warns me that a new permission has been added.

VS info:
Microsoft Visual Studio Ultimate 2013
Version 12.0.31101.00 Update 4
Microsoft .NET Framework
Version 4.6.00007

Installed Version: Ultimate

Architecture and Modeling Tools   06181-004-0452003-02070
Microsoft Architecture and Modeling Tools
    
UML® and Unified Modeling Language™ are trademarks or registered trademarks of the Object Management Group, Inc. in the United States and other countries.

LightSwitch for Visual Studio 2013   06181-004-0452003-02070
Microsoft LightSwitch for Visual Studio 2013

Team Explorer for Visual Studio 2013   06181-004-0452003-02070
Microsoft Team Explorer for Visual Studio 2013

Visual Basic 2013   06181-004-0452003-02070
Microsoft Visual Basic 2013

Visual C# 2013   06181-004-0452003-02070
Microsoft Visual C# 2013

Visual C++ 2013   06181-004-0452003-02070
Microsoft Visual C++ 2013

Visual F# 2013   06181-004-0452003-02070
Microsoft Visual F# 2013

Visual Studio 2013 Code Analysis Spell Checker   06181-004-0452003-02070
Microsoft® Visual Studio® 2013 Code Analysis Spell Checker

Portions of International CorrectSpell™ spelling correction system © 1993 by Lernout & Hauspie Speech Products N.V. All rights reserved.

The American Heritage® Dictionary of the English Language, Third Edition Copyright © 1992 Houghton Mifflin Company. Electronic version licensed from Lernout & Hauspie Speech Products N.V. All rights reserved.

Windows Phone SDK 8.0 - ENU   06181-004-0452003-02070
Windows Phone SDK 8.0 - ENU

ASP.NET and Web Tools   12.4.51016.0
Microsoft Web Developer Tools contains the following components:
Support for creating and opening ASP.NET web projects
Browser Link: A communication channel between Visual Studio and browsers
Editor extensions for HTML, CSS, and JavaScript
Page Inspector: Inspection tool for ASP.NET web projects
Scaffolding: A framework for building and running code generators
Server Explorer extensions for Microsoft Azure Websites
Web publishing: Extensions for publishing ASP.NET web projects to hosting providers, on-premises servers, or Microsoft Azure

ASP.NET Web Frameworks and Tools 2012.2   4.1.21001.0
For additional information, visit http://go.microsoft.com/fwlink/?LinkID=309563

ASP.NET Web Frameworks and Tools 2013   5.2.21010.0
For additional information, visit http://www.asp.net/

Common Azure Tools   1.3
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

JetBrains ReSharper Platform 6   Build 6.0.20141219.120158 on 2014-12-19 12:56:02Z
JetBrains ReSharper Platform package for Microsoft Visual Studio. For more information about ReSharper Platform, visit http://www.jetbrains.com/resharper. Copyright © 2015 JetBrains, Inc.

Microsoft Advertising SDK for Windows Phone   
Microsoft Advertising SDK for Windows Phone
Build 

Microsoft Azure HDInsight HQL Service   1.0.0000.0
Language service for Hive query

Microsoft Azure HDInsight Tools for Visual Studio   1.0.0000.0
An integrated development environment for HDInsight application development.

Microsoft Azure Mobile Services Tools   1.3
Microsoft Azure Mobile Services Tools

Microsoft Azure Tools   2.4
Microsoft Azure Tools for Microsoft Visual Studio 2013 - v2.4.20730.1601

Microsoft Azure Tools   2.5
Microsoft Azure Tools for Microsoft Visual Studio 2013 - v2.5.21104.1601

Microsoft Team Foundation Server 2013 Power Tools   12.0
Power Tools that extend the Team Foundation Server integration with Visual Studio.

Microsoft Visual Studio Process Editor   1.0
Process Editor for Microsoft Visual Studio Team Foundation Server

Microsoft XNA Game Studio   4.0
Microsoft XNA Game Studio 4.0
Build 4.0.30901.0

NuGet Package Manager   2.8.50926.663
NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.

Office Developer Tools for Visual Studio 2013 ENU   12.0.30626
Microsoft Office Developer Tools for Visual Studio 2013 ENU

PowerShell Tools   1.3
Provides file classification services using PowerShell

PreEmptive Analytics Visualizer   1.2
Microsoft Visual Studio extension to visualize aggregated summaries from the PreEmptive Analytics product.

Release Management for Visual Studio Package   1.0
Release Management for Visual Studio

SQL Server Data Tools   12.0.41012.0
Microsoft SQL Server Data Tools

Windows Azure Tools   2.3
Windows Azure Tools for Microsoft Visual Studio 2013 - v2.3.20320.1602

Windows Phone 8.1 SDK Integration   1.0
This package integrates the tools for the Windows Phone 8.1 SDK into the menus and controls of Visual Studio.

Workflow Manager Tools 1.0   1.0
This package contains the necessary Visual Studio integration components for Workflow Manager.

Xamarin   3.9.289.0 (39a70ae)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin.Android   4.20.0.34 (49a04b966feb40dfdba49d57ba16249b66d606a6)
Visual Studio plugin to enable development for Xamarin.Android.

Xamarin.iOS   8.6.1.0 (3b3ef438017c7ecf486defa9e01567a5f2b3cb2a)
Visual Studio extension to enable development for Xamarin.iOS.

Xamarin.iOS Unified Migration   1.0
Automated migration for Xamarin iOS Classic projects to Unified

XNA Game Studio 4.0   1.0
Information about my package
Comment 1 Shruti 2015-02-17 10:10:54 UTC
I have checked this issue and I am also getting the same behavior.

Screencast: http://www.screencast.com/t/RVEqPVK5H3

IDE logs: https://gist.github.com/RamChBachkheti/89c5c995babff38edbe7

Environment Info:

Microsoft Visual Studio Professional 2013
Version 12.0.30723.00 Update 3
Microsoft .NET Framework
Version 4.5.51641

Installed Version: Professional

LightSwitch for Visual Studio 2013   06177-004-0447006-02641
Microsoft LightSwitch for Visual Studio 2013

Team Explorer for Visual Studio 2013   06177-004-0447006-02641
Microsoft Team Explorer for Visual Studio 2013

Visual Basic 2013   06177-004-0447006-02641
Microsoft Visual Basic 2013

Visual C# 2013   06177-004-0447006-02641
Microsoft Visual C# 2013

Visual C++ 2013   06177-004-0447006-02641
Microsoft Visual C++ 2013

Visual F# 2013   06177-004-0447006-02641
Microsoft Visual F# 2013

Visual Studio 2013 Code Analysis Spell Checker   06177-004-0447006-02641
Microsoft® Visual Studio® 2013 Code Analysis Spell Checker

Portions of International CorrectSpell™ spelling correction system © 1993 by Lernout & Hauspie Speech Products N.V. All rights reserved.

The American Heritage® Dictionary of the English Language, Third Edition Copyright © 1992 Houghton Mifflin Company. Electronic version licensed from Lernout & Hauspie Speech Products N.V. All rights reserved.

Windows Phone SDK 8.0 - ENU   06177-004-0447006-02641
Windows Phone SDK 8.0 - ENU

Application Insights Tools for Visual Studio Package   1.0
Application Insights Tools for Visual Studio

ASP.NET and Web Tools   12.3.50717.0
Microsoft Web Developer Tools contains the following components:
Support for creating and opening ASP.NET web projects
Browser Link: A communication channel between Visual Studio and browsers
Editor extensions for HTML, CSS, and JavaScript
Page Inspector: Inspection tool for ASP.NET web projects
Scaffolding: A framework for building and running code generators
Server Explorer extensions for Microsoft Azure Websites
Web publishing: Extensions for publishing ASP.NET web projects to hosting providers, on-premises servers, or Microsoft Azure

ASP.NET Web Frameworks and Tools 2012.2   4.1.21001.0
For additional information, visit http://go.microsoft.com/fwlink/?LinkID=309563

ASP.NET Web Frameworks and Tools 2013   5.2.20703.0
For additional information, visit http://www.asp.net/

Common Azure Tools   1.2
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

Microsoft Advertising SDK for Windows Phone   
Microsoft Advertising SDK for Windows Phone
Build 

Microsoft Azure Mobile Services Tools   1.2
Microsoft Azure Mobile Services Tools

NuGet Package Manager   2.8.50926.663
NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.

Office Developer Tools for Visual Studio 2013 ENU   12.0.30626
Microsoft Office Developer Tools for Visual Studio 2013 ENU

PowerShell Tools   1.2
Provides file classification services using PowerShell

PreEmptive Analytics Visualizer   1.2
Microsoft Visual Studio extension to visualize aggregated summaries from the PreEmptive Analytics product.

SQL Server Data Tools   12.0.30919.1
Microsoft SQL Server Data Tools

Windows Phone 8.1 SDK Integration   1.0
This package integrates the tools for the Windows Phone 8.1 SDK into the menus and controls of Visual Studio.

Workflow Manager Tools 1.0   1.0
This package contains the necessary Visual Studio integration components for Workflow Manager.

Xamarin   3.9.296.0 (d66d164)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin.Android   4.20.0.34 (49a04b966feb40dfdba49d57ba16249b66d606a6)
Visual Studio plugin to enable development for Xamarin.Android.

Xamarin.iOS   8.6.1.0 (3b3ef438017c7ecf486defa9e01567a5f2b3cb2a)
Visual Studio extension to enable development for Xamarin.iOS.

Xamarin.iOS Unified Migration   1.0
Automated migration for Xamarin iOS Classic projects to Unified
Comment 2 Adam Kapos 2015-02-19 20:19:15 UTC
Any updates?
Comment 3 Adam Kapos 2015-03-08 19:10:42 UTC
Two weeks and nothing. Seriously?
Comment 4 Adam Kapos 2015-03-23 18:59:05 UTC
Why doesn't anyone care?
Comment 5 D F 2015-06-05 12:08:16 UTC
This also happens for my Android app developed using Xamarin Forms on a Mac. The app in question doesn't use any other permissions that require user confirmation so this makes it look really bad.
Comment 6 Jonathan Pryor 2015-10-21 14:27:58 UTC
This is By Design™, and *only* impacts apps built with the DEBUG configuration.

This does NOT impact apps built in the RELEASE configuration.

By default, the Debug configuration uses "Fast Deployment":

http://developer.xamarin.com/guides/android/under_the_hood/build_process/#Fast_Deployment

Fast deployment works by creating an .apk that does NOT contain any assemblies. Instead, a directory is created on the device, and the assemblies are synchronized to that external directory. This speeds up the Edit/Build/Debug cycle, so long as only assemblies are changed. If Android Resources, Android Assets, Java source code, etc. is modified, then the .apk will need to be recreated and redeployed to the target, which can be a time consuming process, depending on what all is going into the .apk.

A recent Xamarin.Android release (5.1?) changed things so that the assembly synchronization directory was on external storage, in order to support Samsung Galaxy S5 devices. When that change was made, Debug apps needed to have the READ_EXTERNAL_STORAGE permission, or they wouldn't work at all.

Fast deployment CANNOT be used in Release apps, because Release apps are expected to be downloadable from the Google Play Store, and thus must contain all dependencies -- particularly assemblies! -- and thus don't need the READ_EXTERNAL_STORAGE, and won't create the assembly synchronization directory.

If you're building apps for deployment, you should be using the Release configuration.

If your Release configuration app still has the READ_EXTERNAL_STORAGE permission automatically added, it's because we think you're asking for a "Debug-like" configuration. Please set the $(EmbedAssembliesIntoApk) MSBuild property to True to prevent addition of the READ_EXTERNAL_STORAGE permission:

http://developer.xamarin.com/guides/android/under_the_hood/build_process/#EmbedAssembliesIntoApk
Comment 7 Adam Kapos 2015-10-21 14:36:08 UTC
Jonathan, I reported this bug in February, running version 4.20.0.34. It affected release builds, submitted into Google Play.

Also, you are talking about the extra read permission, but the bug report is "Write External Storage permission added even if not in AndroidManifest".
Comment 8 Jonathan Pryor 2015-10-21 15:01:12 UTC
Xamarin.Android has never automatically added the WRITE_EXTERNAL_STORAGE permission, at least as far as I can tell.

However, *referenced assemblies* certainly can, by using the Android.App.UsesPermissionAttribute assembly-level custom attribute:

http://developer.xamarin.com/api/type/Android.App.UsesPermissionAttribute/

For example:

    [assembly:UsesPermission ("android.permission.WRITE_EXTERNAL_STORAGE")]

Reportedly SQLite.Net.Platform.XamarinAndroid.dll contains (contained?) this custom attribute, which would cause the <permission/> to be added to your AndroidManifest.xml.

If you're still observing this behavior, I would suggest grep'ing your entire project -- including assemblies! -- and see which of them contains the WRITE_EXTERNAL_STORAGE string. That should allow you to determine which assembly is adding the permission, and thus what needs to be fixed.