Stuck manifest permissions

Environment: Windows 8.1, Visual Studio 2013 Update 2 RC, Target:Android 17, Xamarin.Android 4.12.03003

My android projects now always have at minimum the INTERNET, WRITE_EXTERNAL_STORAGE permissions set in the output manifest (obj//AndroidManifest.xml). Setting additional permissions will add to them, but clearing INTERNET or WRITE_EXTERNAL_STORAGE has no effect on the output manifest.

Things I've tried:

  • Checking both debug and release builds
  • Creating a brand new default (honeycomb) project and building with no code changes
  • Checking my 3 other android projects
  • Rebooting

Suggestions?

Posts

  • JGoldbergerJGoldberger USMember, Forum Administrator, Xamarin Team, University Xamurai

    HI @DanTra‌,

    I am looking into this issue. I verified the behavior in Xamarin Studio on a Mac as well, but only the INTERNET permission was added, not both.

    I, or someone, will post back here when we have more information.

    Thanks for reporting this!

    All the best

    Jon

  • JGoldbergerJGoldberger USMember, Forum Administrator, Xamarin Team, University Xamurai
    edited May 2014

    @DanTra‌

    OK, so it seems that the INTERNET permission is added in Debug builds and that this is on purpose so the debugger can connect, otherwise no debugger. It should not be added to release builds unless you specifically add the permission to your project.

    As for the WRITE_EXTERNAL_STORAGE, which is only added in Visual Studio and not Xamarin Studio, this is due to a difference in the templates. In the Visual Studio template these is an entry in Properties\AssemblyInfo.cs that adds the WRITE_EXTERNAL_STORAGE permission. At present we, meaning myself and the Android engineer I consulted with, do not know why this permission is in the AssemblyInfo.cs in the Visual Studio Android template and not in the Xamarin Studio Android template. You can delete these items from the AssemblyInfo.cs file and that should resolve the issue... although for debug builds you will still likely, and hopefully, have the INTERNET permission added automatically even if you remove it from the AssemblyInfo.cs file.

    Entries to remove:

    [assembly: UsesPermission(Android.Manifest.Permission.Internet)]
    [assembly: UsesPermission(Android.Manifest.Permission.WriteExternalStorage)]
    

    It shouldn't be an issue to remove them as the comment above them says:

    // Add some common permissions, these can be removed if not needed
    

    I hope this helps!

    All the best

    Jon

  • DanTraDanTra USMember

    You are correct, both permissions were added to the assemblyinfo.cs file. However, removing them and rebuilding (after a clean) did not change the results - both debug and release builds generate the permissions regardless. I could arguably live with debug, but I really need a way to control which permissions are in the release without building the apk myself.

    For what it's worth, I'm not wild about defaulting properties into a non-documented/non-obvious file (assemblyinfo). If you really feel strongly about it, why not put them in the manifest?

  • DanTraDanTra USMember

    Can you suggest a short term workaround for a release build?

  • JGoldbergerJGoldberger USMember, Forum Administrator, Xamarin Team, University Xamurai

    @DanTra,

    I was unable to replicate this. To try I:

    1. Created a new Android Honeycomb Application in VS 2013, Win 8.1
    2. Deleted the aforementioned entries in AssemblyInfo.cs (I agree, these should not be in there)
    3. Built for release
    4. Checked the out AndroidManifest.xml file in the obj\release folder
    5. No permissions entries were present.

    Instead of just cleaning, can you delete the actual bin and obj folders from your project folder and try again? I wonder if something is getting cached even after a clean? (If so, not good either)

    Let me know. If you use @jgoldberger in your reply, I will get an email notice that you updated the thread. Otherwise I won't notice unless I check my bookmarked threads when I happen to log in to the forums again, which is usually every weekday but not always.

    Thanks

    Jon

  • DanTraDanTra USMember

    @Jgoldberger‌
    I did in fact delete the obj/bin folders when a "clean" didn't work. I just did a clean install of xamarin on a different machine for verification - same results.

    I'll repeat for clarity, but I believe there is a defect.

    • closed visual studio
    • manually deleted bin/obj folders
    • opened visual studio
    • ensure build set to "release"
    • verified no permissions set in project | properties | manifest
    • verified properties/manifest permissions were deleted
    • build
      • obj/release/android/androidManifest.xml has both INTERNET and WRITE_EXTERNAL_STORAGE set
  • JGoldbergerJGoldberger USMember, Forum Administrator, Xamarin Team, University Xamurai

    @DanTra‌,

    Odd. It might be good for me to see a test project from you that is demonstrating the issue as I have not been able to replicate once those entries were removed from AssemblyInfo.cs. Can you send a test project that is demonstrating this behavior in to [email protected] and reference this forum post in your email?

    Thanks in advance.

    Jon

  • DanTraDanTra USMember

    @Jgoldberger‌
    I believe I've isolated the cause: referencing a library.

    To duplicate:

    • Create a new android app project (ICS template)
      • Set build to release
      • Remove permissions from Properties\AssemblyInfo.cs
    • Add a 2nd project of type android library
      • Add reference to 2nd library to app project
    • Build
      • Verify permissions in obj\release\android\androidManifest.xml

    I would still appreciate workaround documentation. I am at this point unable to publish a release that does not include unnecessary permissions.

  • JGoldbergerJGoldberger USMember, Forum Administrator, Xamarin Team, University Xamurai

    @DanTra,

    It seems that AssemblyInfo.cs in the Android Class Library template also includes those permissions. Deleting those permissions from the Android Library AssemblyInfo.cs file seems to do the trick. I did exactly what you described above with that added step and there were no permissions in the AndroidManifest.xml in obj/release/android/

    Before you say it, I agree that these should be removed from all templates. I have filed a bug report: https://bugzilla.xamarin.com/show_bug.cgi?id=19785

    Thanks for alerting us to this issue!

    All the best

    Jon

Sign In or Register to comment.