Find manifest file android

Файл манифеста AndroidManifest.xml

Файл манифеста AndroidManifest.xml предоставляет основную информацию о программе системе. Каждое приложение должно иметь свой файл AndroidManifest.xml. Редактировать файл манифеста можно вручную, изменяя XML-код или через визуальный редактор Manifest Editor (Редактор файла манифеста), который позволяет осуществлять визуальное и текстовое редактирование файла манифеста приложения.

Назначение файла

  • объявляет имя Java-пакета приложения, который служит уникальным идентификатором;
  • описывает компоненты приложения — деятельности, службы, приемники широковещательных намерений и контент-провайдеры, что позволяет вызывать классы, которые реализуют каждый из компонентов, и объявляет их намерения;
  • содержит список необходимых разрешений для обращения к защищенным частям API и взаимодействия с другими приложениями;
  • объявляет разрешения, которые сторонние приложения обязаны иметь для взаимодействия с компонентами данного приложения;
  • объявляет минимальный уровень API Android, необходимый для работы приложения;
  • перечисляет связанные библиотеки;

Общая структура манифеста

Файл манифеста инкапсулирует всю архитектуру Android-приложения, его функциональные возможности и конфигурацию. В процессе разработки приложения вам придется постоянно редактировать данный файл, изменяя его структуру и дополняя новыми элементами и атрибутами.

Корневым элементом манифеста является . Помимо данного элемента обязательными элементами является теги и . Элемент является основным элементом манифеста и содержит множество дочерних элементов, определяющих структуру и работу приложения. Порядок расположения элементов, находящихся на одном уровне, произвольный. Все значения устанавливаются через атрибуты элементов. Кроме обязательных элементов, упомянутых выше, в манифесте по мере необходимости используются другие элементы.

Описание

Элемент является корневым элементом манифеста. По умолчанию Eclipse создает элемент с четырьмя атрибутами:

Атрибуты

объявляет разрешение, которое используется для ограничения доступа к определенным компонентам или функциональности данного приложения. В этой секции описываются права, которые должны запросить другие приложения для получения доступа к вашему приложению. Приложение может также защитить свои собственные компоненты (деятельности, службы, приемники широковещательных намерений и контент-провайдеры) разрешениями. Оно может использовать любое из системных разрешений, определенных Android или объявленных другими приложениями, а также может определить свои собственные разрешения.

android:name название разрешения android:label имя разрешения, отображаемое пользователю android:description описание разрешения android:icon значок разрешения android:permissionGroup определяет принадлежность к группе разрешений android:protectionLevel уровень защиты

Элемент запрашивает разрешение, которые приложению должны быть предоставлены системой для его нормального функционирования. Разрешения предоставляются во время установки приложения, а не во время его работы.

android:name имеет единственный атрибут с именем разрешения android:name. Это может быть разрешение, определенное в элементе

данного приложения, разрешение, определенное в другом приложении или одно из стандартных системных разрешений, например: android:name=»android.permission.CAMERA» или android:name=»»android.permission.READ_CONTACTS»

Наиболее распространенные разрешения

  • INTERNET — доступ к интернету
  • READ_CONTACTS — чтение (но не запись) данных из адресной книги пользователя
  • WRITE_CONTACTS — запись (но не чтение) данных из адресной книги пользователя
  • RECEIVE_SMS — обработка входящих SMS
  • ACCESS_COARSE_LOCATION — использование приблизительного определения местонахождения при помощи вышек сотовой связи или точек доступа Wi-Fi
  • ACCESS_FINE_LOCATION — точное определение местонахождения при помощи GPS

объявляет базовое имя для дерева разрешений. Этот элемент объявляет не само разрешение, а только пространство имен, в которое могут быть помещены дальнейшие разрешения.

определяет имя для набора логически связанных разрешений. Это могут быть как объявленные в этом же манифесте с элементом

разрешения, так и объявленные в другом месте. Этот элемент не объявляет разрешение непосредственно, только категорию, в которую могут быть помещены разрешения. Разрешение можно поместить в группу, назначив имя группы в атрибуте permissionGroup элемента

Источник

The Application Manifest File | Android

Every project in Android includes a manifest file, which is AndroidManifest.xml, stored in the root directory of its project hierarchy. The manifest file is an important part of our app because it defines the structure and metadata of our application, its components, and its requirements. This file includes nodes for each of the Activities, Services, Content Providers, and Broadcast Receiver that make the application and using Intent Filters and Permissions determines how they co-ordinate with each other and other applications.

The manifest file also specifies the application metadata, which includes its icon, version number, themes, etc., and additional top-level nodes can specify any required permissions, unit tests, and define hardware, screen, or platform requirements. The manifest comprises a root manifest tag with a package attribute set to the project’s package. It should also include an xmls:android attribute that will supply several system attributes used within the file. We use the versionCode attribute is used to define the current application version in the form of an integer that increments itself with the iteration of the version due to update. Also, the versionName attribute is used to specify a public version that will be displayed to the users.

Читайте также:  Android phone one hand

We can also specify whether our app should install on an SD card of the internal memory using the installLocation attribute. A typical manifest node looks as:

Источник

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:

  1. 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
  2. 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
    • initial window size
    • ability to resize the window

When Unity builds your app, it automatically generates the Android manifest files, following the steps below:

  1. Unity uses LibraryManifest.xml or AndroidManifest.xml as the main manifest.
  2. 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).
  3. It uses Google’s manifmerger class to merge plug-in manifests into the main manifest.
  4. 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

Источник

Working with the Android Manifest

AndroidManifest.xml is a powerful file in the Android platform that allows you to describe the functionality and requirements of your application to Android. However, working with it is not easy. Xamarin.Android helps to minimize this difficulty by allowing you to add custom attributes to your classes, which will then be used to automatically generate the manifest for you. Our goal is that 99% of our users should never need to manually modify AndroidManifest.xml.

AndroidManifest.xml is generated as part of the build process, and the XML found within Properties/AndroidManifest.xml is merged with XML that is generated from custom attributes. The resulting merged AndroidManifest.xml resides in the obj subdirectory; for example, it resides at obj/Debug/android/AndroidManifest.xml for Debug builds. The merging process is trivial: it uses custom attributes within the code to generate XML elements, and inserts those elements into AndroidManifest.xml.

The Basics

At compile time, assemblies are scanned for non- abstract classes that derive from Activity and have the [Activity] attribute declared on them. It then uses these classes and attributes to build the manifest. For example, consider the following code:

This results in nothing being generated in AndroidManifest.xml. If you want an element to be generated, you need to use the [Activity] custom attribute:

This example causes the following xml fragment to be added to AndroidManifest.xml:

The [Activity] attribute has no effect on abstract types; abstract types are ignored.

Activity Name

Beginning with Xamarin.Android 5.1, the type name of an activity is based on the MD5SUM of the assembly-qualified name of the type being exported. This allows the same fully-qualified name to be provided from two different assemblies and not get a packaging error. (Before Xamarin.Android 5.1, the default type name of the activity was created from the lowercased namespace and the class name.)

If you wish to override this default and explicitly specify the name of your activity, use the Name property:

Читайте также:  Hik connect для андроид настройка

This example produces the following xml fragment:

You should use the Name property only for backward-compatibility reasons, as such renaming can slow down type lookup at runtime. If you have legacy code that expects the default type name of the activity to be based on the lowercased namespace and the class name, see Android Callable Wrapper Naming for tips on maintaining compatibility.

Activity Title Bar

By default, Android gives your application a title bar when it is run. The value used for this is /manifest/application/activity/@android:label . In most cases, this value will differ from your class name. To specify your app’s label on the title bar, use the Label property. For example:

This example produces the following xml fragment:

Launchable from Application Chooser

By default, your activity will not show up in Android’s application launcher screen. This is because there will likely be many activities in your application, and you don’t want an icon for every one. To specify which one should be launchable from the application launcher, use the MainLauncher property. For example:

This example produces the following xml fragment:

Activity Icon

By default, your activity will be given the default launcher icon provided by the system. To use a custom icon, first add your .png to Resources/drawable, set its Build Action to AndroidResource, then use the Icon property to specify the icon to use. For example:

This example produces the following xml fragment:

Permissions

When you add permissions to the Android Manifest (as described in Add Permissions to Android Manifest), these permissions are recorded in Properties/AndroidManifest.xml. For example, if you set the INTERNET permission, the following element is added to Properties/AndroidManifest.xml:

Debug builds automatically set some permissions to make debug easier (such as INTERNET and READ_EXTERNAL_STORAGE ) – these settings are set only in the generated obj/Debug/android/AndroidManifest.xml and are not shown as enabled in the Required permissions settings.

For example, if you examine the generated manifest file at obj/Debug/android/AndroidManifest.xml, you may see the following added permission elements:

In the Release build version of the manifest (at obj/Debug/android/AndroidManifest.xml), these permissions are not automatically configured. If you find that switching to a Release build causes your app to lose a permission that was available in the Debug build, verify that you have explicitly set this permission in the Required permissions settings for your app (see Build > Android Application in Visual Studio for Mac; see Properties > Android Manifest in Visual Studio).

Advanced Features

Intent Actions and Features

The Android manifest provides a way for you to describe the capabilities of your activity. This is done via Intents and the [IntentFilter] custom attribute. You can specify which actions are appropriate for your activity with the IntentFilter constructor, and which categories are appropriate with the Categories property. At least one activity must be provided (which is why activities are provided in the constructor). [IntentFilter] can be provided multiple times, and each use results in a separate element within the . For example:

This example produces the following xml fragment:

Application Element

The Android manifest also provides a way for you to declare properties for your entire application. This is done via the element and its counterpart, the Application custom attribute. Note that these are application-wide (assembly-wide) settings rather than per-Activity settings. Typically, you declare properties for your entire application and then override these settings (as needed) on a per-Activity basis.

For example, the following Application attribute is added to AssemblyInfo.cs to indicate that the application can be debugged, that its user-readable name is My App, and that it uses the Theme.Light style as the default theme for all activities:

This declaration causes the following XML fragment to be generated in obj/Debug/android/AndroidManifest.xml:

In this example, all activities in the app will default to the Theme.Light style. If you set an Activity’s theme to Theme.Dialog , only that Activity will use the Theme.Dialog style while all other activities in your app will default to the Theme.Light style as set in the element.

There are many application-wide attributes that you can configure in the element; for more information about these settings, see the Public Properties section of ApplicationAttribute.

Источник

Оцените статью