# Installation and Configuration

This tutorial guides you through the process of integrating the `PeripheralsLib` library into your Android Studio project. You will learn how to import the library file, configure your build dependencies, and update your application manifest to support Android 12 and higher.

## Prerequisites

* An existing Android Studio project.  
* The `peripheralslib.jar` file provided with the integration package.

## Step 1: Import the Library

1. Open your project in **Android Studio**.  
2. Navigate to the **Project** view (not Android view) in the "Project Explorer".  
3. Locate your application module (usually named `app`).  
4. Expand the module and look for a folder named `libs`.  
   * If the folder does not exist, right-click on the `app` folder, select **New > Directory**, and name it `libs`.  
5. Copy the `peripheralslib.jar` file and paste it into the `libs` directory.

## Step 2: Configure Gradle Dependencies

To make the library classes available to your code, you must add it as a dependency in your build configuration.

1. Open the `build.gradle` file for your application module (often labeled `Module: app`).  
2. Locate the `dependencies` block.  
3. Add the following line to include the JAR file: 
   
   ```gradle
   implementation files('libs/peripheralslib.jar')
   ```

4. Sync your project with Gradle files.

## Step 3: Configure Android Manifest (Android 12+)

Devices running **Android 12 (API level 31)** or higher require specific permissions to interact with the system services used by PeripheralsLib. You must declare these permissions in your `AndroidManifest.xml`.

1. Open `app/src/main/AndroidManifest.xml`.  
2. Add the `QUERY_ALL_PACKAGES` permission and the required `<queries>` block inside the `<manifest>` tag, but outside the `<application>` tag.  
   
   ```xml
   <manifest xmlns:android="http://schemas.android.com/apk/res/android"
       xmlns:tools="http://schemas.android.com/tools"
       package="com.your.package">

       <!-- Required for Android 12+ visibility -->
       <uses-permission
           android:name="android.permission.QUERY_ALL_PACKAGES"
           tools:ignore="QueryAllPackagesPermission" />

       <queries>
           <package android:name="com.redsys.t_android.appservice" />
       </queries>

       <application ...>
           ...
       </application>

   </manifest>
   ```

<Callout type="note">

The `<queries>` block ensures your application can detect and communicate with the underlying service (`com.redsys.t_android.appservice`) on newer Android versions.

</Callout>

## Summary

You have successfully imported the library and configured the necessary permissions. Your project is now ready to instantiate the `PeripheralsManager`.