- Android Manifest
- How Unity produces the Android Manifest
- Overriding the Android Manifest
- Permissions
- Runtime permissions in Android 6.0 (Marshmallow)
- Examining the resulting Android Manifest
- Android Manifest
- How Unity produces the Android Manifest
- Overriding the Android Manifest
- Permissions
- Runtime permissions in Android 6.0 (Marshmallow)
- Examining the resulting Android Manifest
- Android Manifest
- How Unity produces the Android Manifest
- Overriding the Android manifest
- Permissions
- Runtime permissions in Android 6.0 (Marshmallow)
- Examining the resulting Android manifest
Android Manifest
The Android Manifest is an XML file which contains important metadata about the Android app. This includes the package name, activity names, main activity (the entry point to the app), configurations, Android version support, hardware features support, and permissions.
For more information about the Android Manifest file, refer to the Android Developer documentation on Android Manifests.
How Unity produces the Android Manifest
When building your app, Unity automatically generates the Android Manifest, following the steps below:
Unity takes the main Android Manifest.
Unity finds all the Android Manifests of your plug-ins (AARs and Android Libraries).
Manifests from plug-ins are merged into the main Manifest using Google’s manifmerger class.
Unity modifies the Manifest, automatically adding permissions, configuration options, features used, and other information to the Manifest.
Overriding the Android Manifest
Although Unity generates a correct Manifest for you, in some cases you might want direct control over its contents.
To use an Android Manifest that you have created outside of Unity, import your Android Manifest file to the following location: Assets/Plugins/Android/AndroidManifest.xml. This overrides the default Unity-created Manifest.
In this situation, Android Libraries’ Manifests are later merged into your main Manifest, and the resulting Manifest is still tweaked by Unity to make sure the configuration is correct. For full control of the Manifest, including permissions, you need to export the Project and modify the final Manifest in Android Studio.
Permissions
Unity automatically adds the necessary permissions to the Manifest based on the Player Settings and Unity APIs that your app calls from the script. For example:
Network classes add the INTERNET permission
Using vibration (such as Handheld.Vibrate) adds VIBRATE
The InternetReachability property adds ACCESS_NETWORK_STATE
Location APIs (such as LocationService) adds ACCESS_FINE_LOCATION
WebCamTexture APIs add CAMERA permission
The Microphone class adds RECORD_AUDIO
For more information about permissions, see the Android Manifest Permissions page of the Android Developer documentation.
Note that if your plug-ins require a permission by declaring it in their Manifests, the permission is automatically be added to the resulting Android Manifest during the merge stage. Any Unity APIs called by the plug-ins also contribute to the permission list.
Runtime permissions in Android 6.0 (Marshmallow)
If your app is running on a device with Android 6.0 (Marshmallow) or later and also targets Android API level 23 or higher, your app uses the Android Runtime Permission System.
The Android Runtime Permission System asks the app’s user to grant permissions while the app is running, instead of when the app is first installed. App users can usually grant or deny each permission when the app needs them while the app is running (for example, requesting camera permission before taking a picture). This allows an app to run with limited functionality without permissions.
Unity does not support the Runtime Permission System, so your app prompts the user to allow what Android calls “dangerous” permissions on startup. See Android’s documentation on dangerous permissions for more information.
Prompting your user to allow dangerous permissions is the only way to ensure plug-ins don’t cause crashes when they are missing a permission. However, if you don’t want your Unity Android app to ask for permissions on startup, you can add the following to your Manifest in either the Application or Activity sections.
Adding this completely suppresses the permission dialog shown on startup, but you must handle runtime permissions carefully to avoid crashes. This method is only recommended for advanced Android app developers.
For further information about the Runtime Permission System and handling permissions, see the Requesting Permissions section of the Android Developer documentation.
Examining the resulting Android Manifest
To examine the final Android Manifest that Unity has generated for your app, open the Temp/StagingArea/AndroidManifest.xml file after you have built your Project but before exiting the Unity Editor.
The Manifest is stored in binary format in the output package (APK). To check the contents of a Manifest inside an APK, you can use the Android Studio APK Analyzer or another third-party tool (such as Apktool).
Источник
Android Manifest
The Android Manifest is an XML file which contains important metadata about the Android app. This includes the package name, activity names, main activity (the entry point to the app), configurations, Android version support, hardware features support, and permissions.
For more information about the Android Manifest file, refer to the Android Developer documentation on Android Manifests.
How Unity produces the Android Manifest
When building your app, Unity automatically generates the Android Manifest, following the steps below:
Unity takes the main Android Manifest.
Unity finds all the Android Manifests of your plug-ins A set of code created outside of Unity that creates functionality in Unity. There are two kinds of plug-ins you can use in Unity: Managed plug-ins (managed .NET assemblies created with tools like Visual Studio) and Native plug-ins (platform-specific native code libraries). More info
See in Glossary (AARs and Android Libraries).
Manifests from plug-ins are merged into the main Manifest using Google’s manifmerger class.
Unity modifies the Manifest, automatically adding permissions, configuration options, features used, and other information to the Manifest.
Overriding the Android Manifest
Although Unity generates a correct Manifest for you, in some cases you might want direct control over its contents.
To use an Android Manifest that you have created outside of Unity, import your Android Manifest file to the following location: Assets/Plugins/Android/AndroidManifest.xml. This overrides the default Unity-created Manifest.
In this situation, Android Libraries’ Manifests are later merged into your main Manifest, and the resulting Manifest is still tweaked by Unity to make sure the configuration is correct. For full control of the Manifest, including permissions, you need to export the Project and modify the final Manifest in Android Studio. Please note that we only support launchMode — singleTask.
Permissions
Unity automatically adds the necessary permissions to the Manifest based on the Android Player settings and Unity APIs that your app calls from the script. For example:
Network classes add the INTERNET permission
Using vibration (such as Handheld.Vibrate) adds VIBRATE
The InternetReachability property adds ACCESS_NETWORK_STATE
Location APIs (such as LocationService) adds ACCESS_FINE_LOCATION
WebCamTexture APIs add CAMERA permission
The Microphone class adds RECORD_AUDIO
For more information about permissions, see the Android Manifest Permissions page of the Android Developer documentation.
Note that if your plug-ins require a permission by declaring it in their Manifests, the permission is automatically be added to the resulting Android Manifest during the merge stage. Any Unity APIs called by the plug-ins also contribute to the permission list.
Runtime permissions in Android 6.0 (Marshmallow)
If your app is running on a device with Android 6.0 (Marshmallow) or later and also targets Android API level 23 or higher, your app uses the Android Runtime Permission System.
The Android Runtime Permission System asks the app’s user to grant permissions while the app is running, instead of when the app is first installed. App users can usually grant or deny each permission when the app needs them while the app is running (for example, requesting camera permission before taking a picture). This allows an app to run with limited functionality without permissions. The Android.Permission class allows you to check whether specific permissions have been granted or denied. If a permission your app relies upon has been denied, you can inform the user why you need it and ask them to approve the permission. See Requesting Permissions.
Normally, your app prompts the user to allow what Android calls “dangerous” permissions on startup. See Android’s documentation on dangerous permissions for more information. However, if you don’t want your Unity Android app to ask for permissions on startup, you can add the following to your Manifest in either the Application or Activity sections.
Adding this completely suppresses the permission dialog shown on startup, but you must handle runtime permissions carefully to avoid crashes. This method is only recommended for advanced Android app developers.
For further information about the Runtime Permission System and handling permissions, see the Requesting Permissions section of the Android Developer documentation.
Examining the resulting Android Manifest
To examine the final Android Manifest that Unity has generated for your app, open the Temp/StagingArea/AndroidManifest.xml file after you have built your Project but before exiting the Unity Editor.
The Manifest is stored in binary format in the output package (APK). To check the contents of a Manifest inside an APK The Android Package format output by Unity. An APK is automatically deployed to your device when you select File > Build & Run. More info
See in Glossary , you can use the Android Studio APK Analyzer or another third-party tool (such as Apktool).
2018–10–05 Page published
Updated functionality in 5.5
Added support for Android Runtime Permissions in 2018.3.
Источник
Android Manifest
The Android Manifest is an XML file which contains important metadata about the Android app. This includes the package name, activity names, main activity (the entry point to the app), Android version support, hardware features support, permissions, and other configurations.
For more information about the Android Manifest file, see the Android Developer documentation on Android Manifests.
How Unity produces the Android Manifest
In Unity 2019.3 and newer versions, the Android Gradle An Android build system that automates several build processes. This automation means that many common build errors are less likely to occur. More info
See in Glossary project that Unity generates has two template manifest files:
- LauncherManifest.xml — Located in the exported project, at root/launcher/src/main/AndroidManifest.xml. This file contains the app’s:
- icons
- name
- starting activity and its Intents
- install location
- supported screen sizes
- isGame setting
- LibraryManifest.xml — Located in the exported project at root/unityLibrary/src/main/AndroidManifest.xml. You can override this manifest with a custom_ AndroidManifest.xml_ that you add in the Plugins/Android folder. This file declares the:
- Unity activity
- permissions
- theme used by the Unity activity
- VR modes
- VR performance
- making the activity non-resizable (for VR)
- setting max aspect ratio
- reacting to configuration changes
- orientations
- launch modes
- Android UI (User Interface) Allows a user to interact with your application. More info
See in Glossary hardware acceleration - used features (like gamepad or graphics API)
- notch support
When Unity builds your app, it automatically generates the Android manifest files, following the steps below:
- Unity uses LibraryManifest.xml or AndroidManifest.xml as the main manifest.
- It then finds all of the Android manifests of your plug-ins A set of code created outside of Unity that creates functionality in Unity. There are two kinds of plug-ins you can use in Unity: Managed plug-ins (managed .NET assemblies created with tools like Visual Studio) and Native plug-ins (platform-specific native code libraries). More info
See in Glossary (.aar files and Android Libraries). - It uses Google’s manifmerger class to merge plug-in manifests into the main manifest.
- Unity modifies the manifest files in the launcher and library modules. It automatically adds permissions, configuration options, features used, and other information.
Overriding the Android manifest
Although Unity generates a correct manifest for your app, you might want direct control over its contents.
To use an Android manifest you created outside of Unity, import your Android Manifest file to the following location: Assets/Plugins/Android/AndroidManifest.xml. This overrides the default LibraryManifest.xml.
In this situation, Unity merges the manifests of your Android libraries into your main manifest, and ensures that the resulting manifest’s configuration is correct. For full control of the manifest, including permissions, you must export the Project and modify the final manifest in Android Studio.
Note: Unity only supports the [launchMode — singleTask](https://developer.android.com/guide/topics/manifest/activity-element.html#lmode) launch mode.
Permissions
Unity automatically adds the necessary permissions to the manifest based on the Android Player Settings and Unity APIs that your app calls from the script. For example:
- Network classes add the INTERNET permission
- Using vibration (such as Handheld.Vibrate ) adds VIBRATE
- The InternetReachability ] property adds ACCESS_NETWORK_STATE
- Location APIs (such as LocationService ) adds ACCESS_FINE_LOCATION
- WebCamTexture APIs add CAMERA A component which creates an image of a particular viewpoint in your scene. The output is either drawn to the screen or captured as a texture. More info
See in Glossary permission - The Microphone class adds RECORD_AUDIO
- NetworkDiscovery and NetworkTransport.SetMulticastLock add CHANGE_WIFI_MULTICAST_STATE
For more information about permissions, see Android developer documentation on Android Manifest Permissions.
If your plug-ins require a permission by declaring it in their manifests, Unity automatically adds the permission to the resulting Android manifest during the merge stage. All Unity APIs that plug-ins call also contribute to the permissions list.
Runtime permissions in Android 6.0 (Marshmallow)
If your app is running on a device with Android 6.0 (Marshmallow) or later and also targets Android API level 23 or higher, your app uses the Android Runtime Permission System.
The Android Runtime Permission System asks the user to grant permissions while the app is running, instead of when they first install the app. App users can usually grant or deny each permission when the app needs it while the app is running (for example, requesting camera permission before taking a picture). This allows an app to run with limited functionality without permissions. You can use the Android.Permission class in Unity to check whether the user granted or denied specific permissions. If a permission your app needs has been denied, you can inform the user why the app needs it and ask them to approve the permission. For more information, see documentation on Requesting Permissions.
Your app normally prompts the user to allow what Android calls “dangerous” permissions on its startup. For more information, see Android developer documentation on dangerous permissions. If you don’t want your app to ask for permissions on startup, you can add the following code to your manifest, in either the Application or Activity sections:
Note: This code suppresses the permission dialog the app shows on startup, but you must handle runtime permissions carefully to avoid crashes. This is an advanced method of dealing with runtime permissions.
For more information about the Runtime Permission System and handling permissions, see Android developer documentation on Requesting Permissions.
Examining the resulting Android manifest
To examine the final Android manifest that Unity generates for your app, open the Temp/StagingArea/AndroidManifest.xml file after you build your Project but before you close the Unity Editor.
The Manifest is stored in binary format in the output package (.apk). To check the contents of a Manifest inside an . apk The Android Package format output by Unity. An APK is automatically deployed to your device when you select File > Build & Run. More info
See in Glossary , you can use the Android Studio APK Analyzer, or another third-party tool such as Apktool.
- Unity as a Library for Android added in 2019.3. NewIn20193
- Added support for Android Runtime Permissions in 2018.3.
- Updated functionality in 5.5
Источник