Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
15
Question by Jason-RT-Bond · Mar 13, 2014 at 06:17 PM · androidbuildmanifestpermissions

How to Prevent Unity from Adding Permissions to Android Manifest

So I'm ready to release an app to Google Play but it's showing up as requiring permissions I do not want. The app is targeted at children and parents, so it's very important that we include only the permissions necessary. (It's also a requirement not to include position tracking, which is one of the problem permissions, if you want to have the "everyone" rating.)

I've overridden the Android manifest file successfully by placing it under Plugins/Android/AndroidManifest.xml. This appears to work, and I can see my changes in the manifest Unity is using by checking temp/stagingarea/AndroidManifest.xml after running a build.

However, Unity also appends several permission requirements to this file. In my case, they are:

 <uses-permission android:name="android.permission.INTERNET" />
 
   <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
 
   <uses-feature android:name="android.hardware.location.gps" android:required="false" />
 
   <uses-permission android:name="android.permission.CAMERA" />
 
   <uses-feature android:name="android.hardware.camera" android:required="false" />
 
   <uses-feature android:name="android.hardware.camera.autofocus" android:required="false" />
 
   <uses-feature android:name="android.hardware.camera.front" android:required="false" />



We don't need these permissions for our app. I've heard that perhaps Unity is automatically adding permissions based on code references to these features? I'm not sure if this is true, but if so it's very problematic for us. We use several different 3rd-party code libraries with optional features that aren't actually used in the app. Hunting through such libraries and removing the bits we don't use is not a reasonable option for us.

So the question is: How can I prevent Unity from adding these unwanted permissions to the manifest file on build?

Comment
Add comment · Show 5
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image jacobschellenberg · Mar 13, 2014 at 07:12 PM 0
Share

I believe if your project contains it's own $$anonymous$$anifest that you wrote, perhaps in a Plugins folder, than it will use that one, as opposed to the one Unity creates.

I'm not sure exactly where it needs to be, could be or not in the Plugins, but I feel like I've ran into that before.

avatar image Jason-RT-Bond · Mar 13, 2014 at 07:44 PM 0
Share

Yes, you add it to Plugins/Android as I mentioned. This works, BUT Unity continues to append new permissions to it regardless.

avatar image jacobschellenberg · Mar 13, 2014 at 08:28 PM 0
Share

$$anonymous$$aybe you can get to it after the compilation and just delete those things.

avatar image Jason-RT-Bond · Mar 13, 2014 at 08:58 PM 0
Share

I'm looking at that, and it seems possible if you export a Google Android project. But (if that works) I'm left with a really ugly pipeline where I have to re-do work every time I export from Unity. It would be so much nicer if Unity just didn't add problematic content to my manifest file.

avatar image tarasfromlviv · Jun 05, 2014 at 11:08 AM 0
Share

having the same problem. Any progress in solving it?

12 Replies

· Add your reply
  • Sort: 
avatar image
25

Answer by TTG_Seigman · Nov 02, 2015 at 01:55 PM

We had the same issue with Unity adding permissions to our manifest that we did not need/want. In our case a plugin we're using (Fabric) was referencing the Microphone API of Unity, making Unity add the RECORD_AUDIO permission to our manifest.

Now, the way we solved this was to add the RECORD_AUDIO manifest to our own manifest in the Plugins/Android folder, but also specify a maxSdkVersion for the permission that's lower than the minSdkVersion of our app;

 <uses-permission android:name="android.permission.RECORD_AUDIO" android:maxSdkVersion="1" />

The minSdkVersion of our app is set to 16;

 <uses-sdk android:minSdkVersion="16" android:targetSdkVersion="23" />

This makes Unity use that permission in the created manifest, but since the maxSdkVersion is set to 1, users do not have to give that permission when installing because the minSdkVersion of the app i higher.

Quite a workaround, but it works :-)

Comment
Add comment · Show 6 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Jason-RT-Bond · Nov 02, 2015 at 04:42 PM 0
Share

Interesting! Would you $$anonymous$$d sharing what that looks like for those of us who are less Android-manifest savvy?

avatar image TTG_Seigman Jason-RT-Bond · Nov 03, 2015 at 08:03 AM 0
Share

Hm, I included it in the original post, but it somehow got lost in translation...

Here's how to set the maxSdkVersion for a permission;

 <uses-permission android:name="android.permission.RECORD_AUDIO" android:maxSdkVersion="1" />
avatar image Jason-RT-Bond TTG_Seigman · Nov 03, 2015 at 05:37 PM 0
Share

Thanks! I don't know if it wasn't there or just wasn't displaying for me...

I definitely want to try this out!

avatar image jakobBLH · Nov 13, 2015 at 08:26 PM 0
Share

Cool - solved it for me! Unity was adding permissions (INTERNET ACCES, ID, etc.) to my project and now - ahhhh! - all the permissions are gone:) !

avatar image Cat-Beltine · Jan 19, 2016 at 03:26 PM 0
Share

Thanks a lot for this solution! Worked for me and was really easy to implement. :D [Edit: Works on device, but Google Play does not accept it and complains about the maxSdkVersion. :(

avatar image Fragmental · Jun 02, 2017 at 02:57 AM 2
Share

I tried this, because my apk started asking the the internet permission even though this is absolutely no reason for it. However, upon the upload to google play failed, because maxSdkVersion has to be 18 or higher(which is Jelly Bean 4.3.1 btw).

avatar image
8

Answer by GreenApple · Nov 15, 2014 at 09:24 AM

Find "Input.location" in all files, if any .cs file contains this code, uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" will be added automatically when building apk.Delete all related files, this issue will be fixed.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image NickLAPC · Nov 13, 2018 at 01:35 AM 0
Share

That worked for me. I found Playmaker has various actions that makes calls to Input.location so removing or commenting out those actions will help if you are using playmaker and are not wanting use location services in your app.

avatar image
2

Answer by Jason-RT-Bond · Mar 13, 2014 at 10:09 PM

One possible solution which appears to work is to export a Google Android project instead of building directly from Unity. Then one can modify the manifest (again) in Google's environment, build and sign.

This does accomplish what I need, but it creates a somewhat hellish workflow for creating publishable builds. It also required learning a set of tools I didn't need for any particular reason other than working around a problem Unity seems to have created.

Comment
Add comment · Show 7 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image andrewow · Aug 01, 2014 at 11:15 PM 0
Share

Do you have any updates on how you solved this? I have the same problem and also don't want to deal with this build flow.

avatar image Jason-RT-Bond · Oct 15, 2014 at 06:52 PM 0
Share

Sorry, forgot to answer your question. In brief, no, Unity doesn't appear to have a work-around. If you don't want those extra permissions, you have to export the Eclipse (Google Android) project and modify the manifest yourself every time.

On the plus side, you get faster at it the more you do this :P

avatar image liortal · Oct 21, 2014 at 08:55 AM 0
Share

You could automate the process by exporting a Google project, and have a post build processor to manipulate the Android$$anonymous$$anifest.xml (it's just an xml file, you could get all Permissions from it and chop off the one you don't need).

After this is done, you could build an AP$$anonymous$$ from the command line (Android has a set of tools for doing that), so effectively you would get an AP$$anonymous$$ at the end of the process.

If you're into that i could post an answer later to describe how this could be done (although there's already an accepted answer for this question here).

avatar image Jason-RT-Bond · Oct 21, 2014 at 09:08 AM 0
Share

liortal, that sounds like a more "proper" solution than the one above, and any details you could provide would be helpful. I personally wouldn't know where to begin doing that.

avatar image DMTSource · Oct 21, 2014 at 01:54 PM 1
Share

Are you using Split Application Binary when building due to a over 50mb app? I found out that doing so will trash your intended post processors AND the Android$$anonymous$$anifest and add permissions like crazy like CHEC$$anonymous$$_LICENSE and WRITE_EXTERNAL and a couple others on top of the 4 I define.

Show more comments
avatar image
1

Answer by booferei · May 19, 2021 at 11:06 AM

Found a way to prevent Unity from adding the permission on stack overflow:

     <manifest xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:tools="http://schemas.android.com/tools">
 ...
     <uses-permission android:name="android.permission.RECORD_AUDIO" tools:node="remove" />
 ...

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by jeremiasz · Jul 29, 2015 at 05:49 PM

Hi I've just found a nice soultion to the manifest permission problem.

  1. Build an .apk file as always. Don't worry about manifest file.

  2. Deploy the app to the android device.

  3. Download permission manager from Google Play store. In my case this was Advanced Permission Manager. Free version will do good. You don't have to root the device.

  4. Remove permissions from apk fie and push th Save and Install button.

  5. Voila! You have New.apk file in PermMaster folder on the device - this is your apk file without unwanted permissions.

Comment
Add comment · Show 5 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Bunny83 · Jul 29, 2015 at 06:12 PM 0
Share

I'm pretty sure that you would need to re-sign your AP$$anonymous$$ with your key, otherwise wou probably can't publish the app to the store.

avatar image Jason-RT-Bond · Jul 31, 2015 at 03:31 PM 0
Share

Hm. Yes, I haven't had time to test this, but I imagine you WOULD have to re-sign the .apk, which is its own finagling.

avatar image jeremiasz · Jul 31, 2015 at 04:47 PM 0
Share

I am just making my first app for Android. Everything is new for me. How to in simplest way test if I had to re-sign the App?

avatar image Jason-RT-Bond · Jul 31, 2015 at 06:08 PM 1
Share

I think you would have to sign it to submit to Google Play...?

avatar image jeremiasz · Aug 01, 2015 at 09:14 AM 0
Share

Oh. That... ;) ;) ;)

  • 1
  • 2
  • 3
  • ›

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

42 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Distribute terrain in zones 3 Answers

Social.localUser.Authenticate((bool success) returns no bool 1 Answer

Avoid android permission prompt when returning to app after changing settings on device? 0 Answers

[Android] Remove READ_PHONE_STATE and READ_EXTERNAL_STORAGE permissions 2 Answers

can't build android app with facebook sdk 5 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges