{"title":"Install and integrate the Android library","category":"default","creationDate":1776961627,"content":"<p>This guide will help you integrate your existing POS system, which runs on Android, with the plataforma de pagamentos da Adyen.<\/p>\n<div class=\"sc-notice info\"><div>\n<p>Before you begin to integrate, make sure you have followed the <a href=\"\/pt\/get-started-with-adyen\">Get started with Adyen guide<\/a> to:<\/p>\n<ul>\n<li>Get an overview of the steps needed to accept live payments.<\/li>\n<li>Create your test account.<\/li>\n<\/ul>\n<\/div><\/div>\n<h2 id=\"add-the-adyen-library-module-as-a-dependency-to-your-app-module\">Add the Adyen library module as a dependency to your app module<\/h2>\n<ol>\n<li>\n<p>Import the new Adyen Android Library module.<\/p>\n<ol>\n<li>Go to\u00a0<span translate=\"no\"><strong>File<\/strong><\/span>\u00a0&gt;\u00a0<span translate=\"no\"><strong>Project Structure<\/strong><\/span>\u00a0in Android Studio.<\/li>\n<li>Press the\u00a0<span translate=\"no\"><strong>+<\/strong><\/span>\u00a0button on the upper-left corner of the\u00a0<span translate=\"no\"><strong>Project Structure<\/strong><\/span>\u00a0window\u00a0to\u00a0add a new\u00a0module.\u00a0<\/li>\n<li>\n<p>In the\u00a0<span translate=\"no\"><strong>Create new module<\/strong><\/span>\u00a0screen:\u00a0<\/p>\n<ol>\n<li>Select\u00a0<span translate=\"no\"><strong>Import .JAR\/.AAR\u00a0Package<\/strong><\/span>\u00a0and click\u00a0<span translate=\"no\"><strong>Next<\/strong><\/span>.<\/li>\n<li>In the file selector, browse to the\u00a0unzipped\u00a0<span translate=\"no\"><strong>adyen-android-library-{version}.aar<\/strong><\/span>\u00a0file.<\/li>\n<\/ol>\n<!-- list separator -->\n<\/li>\n<\/ol>\n<!-- list separator -->\n<\/li>\n<li>\n<p>Add a dependency in the app module\u00a0to the Adyen library module.<\/p>\n<ol>\n<li>\n<p>Go to\u00a0<span translate=\"no\"><strong>File<\/strong><\/span>\u00a0&gt;\u00a0<span translate=\"no\"><strong>Project structure<\/strong><\/span>\u00a0in Android Studio.<\/p>\n<\/li>\n<li>\n<p>Select the app module in the\u00a0<span translate=\"no\"><strong>Modules<\/strong><\/span>\u00a0list on the left.<\/p>\n<\/li>\n<li>\n<p>Select the\u00a0<span translate=\"no\"><strong>Dependencies<\/strong><\/span>\u00a0tab.\u00a0<\/p>\n<\/li>\n<li>\n<p>Add dependency on the\u00a0<span translate=\"no\"><strong>+<\/strong><\/span>\u00a0button on the lower left corner.\u00a0<\/p>\n<\/li>\n<li>\n<p>Select\u00a0<span translate=\"no\"><strong>3.Module dependency<\/strong><\/span>\u00a0in the drop down menu.\u00a0<\/p>\n<\/li>\n<li>\n<p>Select the Adyen library module you have previously added in step 3.<\/p>\n<\/li>\n<\/ol>\n<!-- list separator -->\n<\/li>\n<li>\n<p>\u00a0Add dependency for\u00a0<span translate=\"no\"><strong>appcompat-v7.<\/strong><\/span><\/p>\n<ol>\n<li>\n<p>Go to\u00a0<span translate=\"no\"><strong>File<\/strong><\/span>\u00a0&gt;\u00a0<span translate=\"no\"><strong>Project Structure<\/strong><\/span>\u00a0in Android Studio.<\/p>\n<\/li>\n<li>\n<p>Select the app module in the\u00a0<span translate=\"no\"><strong>Modules<\/strong><\/span>\u00a0list on the left.<\/p>\n<\/li>\n<li>\n<p>Select the\u00a0<span translate=\"no\"><strong>Dependencies<\/strong><\/span>\u00a0tab.\u00a0<\/p>\n<\/li>\n<li>\n<p>Click the\u00a0<span translate=\"no\"><strong>+<\/strong><\/span>\u00a0button on the lower left to add the dependency.<\/p>\n<\/li>\n<li>\n<p>Select<strong>\u00a0<span translate=\"no\"><\/strong>1. Library dependency**<\/span>\u00a0in the drop down menu.<\/p>\n<\/li>\n<li>\n<p>From the\u00a0<span translate=\"no\"><strong>Choose Library Dependency<\/strong><\/span>\u00a0screen choose the\u00a0<span translate=\"no\"><strong>com.android.support:appcompat-v7:{version}.<\/strong><\/span><\/p>\n<\/li>\n<li>\n<p>Click\u00a0<span translate=\"no\"><strong>OK<\/strong><\/span>.<\/p>\n<\/li>\n<\/ol>\n<!-- list separator -->\n<\/li>\n<li>\n<p>Sync project with gradle files.<\/p>\n<\/li>\n<\/ol>\n<p>You can now use the Adyen library in your Android application.\u00a0<\/p>\n<h2 id=\"register-your-app-module\">Register your app module<\/h2>\n<ul>\n<li>\n<p>Register your app module with the Adyen library module.<\/p>\n<pre><code class=\"language-java\">public class App extends Application {\n\n    @Override\n    public void onCreate() {\n        super.onCreate();\n\n        try {\n            LibraryReal.registerLib(getApplicationContext(), getString(R.string.app_name));\n        } catch (final AlreadyRegisteredException e) {\n            \/\/ Do nothing.\n        }\n    }\n}<\/code><\/pre>\n<div class=\"sc-notice note\"><div>\n<p><code>app_name<\/code> - Format this value like so: <strong>Cash register company and product<\/strong>\u00a0\/<strong>\u00a0Cash register product version<\/strong>\u00a0\/ <strong>Adyen integration name<\/strong>\u00a0\/ <strong>Adyen integration version<\/strong>. For example,\u00a0 <strong>Acme Corp POS<\/strong> \/ <strong>1.2.1<\/strong> \/ <strong>Acme Adyen connector<\/strong> \/ <strong>0.1\u00a0<\/strong><\/p>\n<\/div><\/div>\n<\/li>\n<\/ul>\n<h2 id=\"get-an-instance-of-the-adyen-library\">Get an instance of the Adyen library<\/h2>\n<ul>\n<li>\n<p>Once the Adyen library is registered, you can use functionality from the Adyen library instance.<\/p>\n<pre><code class=\"language-java\">@Nullable\npublic AdyenLibraryInterface getAdyenLibrary() {\n    if (mAdyenLibrary == null) {\n        try {\n            mAdyenLibrary = LibraryReal.getLib();\n        } catch (NotYetRegisteredException e) {\n            Log.e(TAG, \"Failed to get AdyenLibraryInterface, the library must be registered first\", e);\n        }\n    }\n\n    return mAdyenLibrary;\n}<\/code><\/pre>\n<\/li>\n<\/ul>\n<h2 id=\"register-the-merchant-credentials-with-the-adyen-library\">Register the merchant credentials with the Adyen library<\/h2>\n<ol>\n<li>\n<p>Register merchant credentials (merchant, username, password) with the Adyen library, and set the desired ServerMode [DEV\/TEST\/BETA\/LIVE].<\/p>\n<pre><code class=\"language-java\">AdyenLibraryInterface adyenLibrary = getAdyenLibrary();\nadyenLibrary.setServerMode(ServerMode.TEST);\ntry {\n    adyenLibrary.registerApp(merchant, username, password, createRegistrationCompleteListener());\n} catch (AppAlreadyRegisteredException e) {\n    e.printStackTrace();\n} catch (AlreadyRegisteringAppException e) {\n    e.printStackTrace();\n} catch (InvalidRequestException e) {\n    e.printStackTrace();<\/code><\/pre>\n<\/li>\n<li>\n<p>Implement the <code>RegistrationCompleteListener<\/code> to handle the response from registration of merchant credentials.<\/p>\n<pre><code class=\"language-java\">private RegistrationCompleteListener createRegistrationCompleteListener() {\n    return (statusCode, appInfo, statusMessage) -&gt; {\n        Log.i(TAG, \"statusCode: \" + statusCode + \", statusMessage: \" + statusMessage);\n\n        switch (statusCode) {\n            case OK:\n                \/\/ Redirect from the LoginActivity to your HomeActivity\n                Intent intent = HomeActivity.getIntent(LoginActivity.this);\n                startActivity(intent);\n                finish();\n                break;\n            case ERROR_NONETWORK:\n                \/\/ Failed to register the app, network issues.\n                break;\n            case ERROR_BADCREDENTIALS:\n                \/\/ Failed to register the app, bad merchant credentials.\n                break;\n            case ERROR_NOROUTE:\n                \/\/ Failed to register the app, network issues.\n                \/\/ The phone cannot connect to the Adyen backend (even if there is internet connection)\n            case ERROR:\n                \/\/ Failed to register the app, general error look at the statusMessage.\n            default:\n                Log.e(TAG, \"statusCode: \" + statusCode + \", statusMessage: \" + statusMessage);\n                break;\n        }\n    };\n}<\/code><\/pre>\n<\/li>\n<\/ol>\n<h2 id=\"register-a-payment-terminal\">Register a payment\u00a0terminal<\/h2>\n<ol>\n<li>\n<p>Create a new DeviceInfo instance:<br \/>\nWi-Fi devices:<\/p>\n<pre><code class=\"language-java\">DeviceInfo deviceInfo = new DeviceInfo();\ndeviceInfo.setConnectionType(DeviceInfo.TYPE_WIFI);\ndeviceInfo.setDeviceId(mDeviceIpAddressEditText.getText().toString());\ndeviceInfo.setFriendlyName(\"Cash register 1\");\nonAddDevice(deviceInfo);<\/code><\/pre>\n<p>Bluetooth devices:<\/p>\n<pre><code class=\"language-java\">DeviceInfo deviceInfo = new DeviceInfo();\ndeviceInfo.setConnectionType(DeviceInfo.TYPE_BT);\ndeviceInfo.setFriendlyName(device.getName());\ndeviceInfo.setDeviceId(device.getAddress());\nonAddDevice(deviceInfo);<\/code><\/pre>\n<\/li>\n<li>\n<p>Add the device to the Adyen library:<\/p>\n<pre><code class=\"language-java\">private void addDevice(@NonNull DeviceInfo deviceInfo) {\n    Log.d(TAG, \"addDevice() called with: deviceInfo = [\" + deviceInfo + \"]\");\n\n    try {\n        getAdyenLibrary().addDevice(createAddDeviceListener(), deviceInfo);\n    } catch (DeviceAlreadyAddedException e) {\n        e.printStackTrace();\n    } catch (AlreadyAddingDeviceException e) {\n        e.printStackTrace();\n    } catch (AppNotRegisteredException e) {\n        e.printStackTrace();\n    } catch (Exception e) {\n        e.printStackTrace();\n    }\n}<\/code><\/pre>\n<\/li>\n<li>\n<p>Implement the <code>AddDeviceListener<\/code>\u00a0to handle adding devices to the Adyen library:<\/p>\n<pre><code class=\"language-java\">private AddDeviceListener createAddDeviceListener() {\n    return new AddDeviceListener() {\n        @Override\n        public void onAddDeviceComplete(CompletedStatus completedStatus, String statusMessage, DeviceData deviceData) {\n            Log.d(TAG, \"onAddDeviceComplete() called with: completedStatus = [\" + completedStatus + \"], statusMessage = [\" + statusMessage + \"], deviceData = [\" + deviceData + \"]\");\n\n            switch (completedStatus) {\n                case OK:\n                    \/\/ Boarding the device succeeded\n                    break;\n\n                case TIMEOUT:\n                    \/\/ Failed to board the device, connection timeout.\n                    break;\n\n                case ERROR:\n                    \/\/ Failed to board the device, general error look at the status message.\n                    break;\n\n                case ERROR_SYNCACTION:\n                    \/\/ Failed to board the device, ???\n                    break;\n\n                case ERROR_VERIFY:\n                    \/\/ Failed to board the device, couldn't verify ???\n                    break;\n\n                case ERROR_NOROUTE:\n                    \/\/ Failed to board the device,\n                    \/\/ The phone cannot connect to the Adyen backend (even if there is internet connection)\n                    break;\n\n                case ERROR_IDENTIFY:\n                    \/\/ Failed to board the device, couldn't identify terminal device with Adyen backend.\n                    break;\n\n                case ERROR_REGISTER:\n                    \/\/ Failed to board the device, couldn't register the teminal device with Adyen backend.\n                    break;\n\n                case ERROR_NONETWORK:\n                    \/\/ Failed to board the device, network issues.\n                    break;\n\n                case ERROR_SYNCDEVICE:\n                    \/\/ Failed to board the device. failed to sync device with Adyen backend.\n                    break;\n\n                case ERROR_CONFLICTING_SERVER_MODE:\n                    \/\/ Failed to board the device, due to server mode try to register the Adyen library with a different server mode.\n                    break;\n            }\n        }\n\n        @Override\n        public void onProgress(ProcessStatus processStatus, String message) {\n            Log.d(TAG, \"onProgress() called with: processStatus = [\" + processStatus + \"], message = [\" + message + \"]\");\n\n            switch (processStatus) {\n                case PREPARING:\n                    break;\n                case IDENTIFY:\n                    break;\n                case REGISTER:\n                    break;\n                case SYNCACTION:\n                    break;\n                case SYNCDEVICE:\n                    break;\n                case VERIFY:\n                    break;\n                case RUNNING_TRANSACTION:\n                    break;\n                case STEP_4_OK:\n                    break;\n                case NONETWORK:\n                    break;\n                case NOROUTE:\n                    break;\n            }\n\n            if (!TextUtils.isEmpty(message)) {\n                \/\/ Notify the user with the progress status message.\n                mStatusTextView.setText(message);\n            }\n        }\n    };\n}<\/code><\/pre>\n<\/li>\n<\/ol>\n<h2 id=\"connect-to-the-registered-payment-terminal\">Connect to the registered payment terminal<\/h2>\n<ul>\n<li>\n<p>Once the payment terminal is added, you can connect it by using the <code>connectDevice<\/code> method:<\/p>\n<pre><code class=\"language-java\">private void connectDevice(@NonNull DeviceInfo deviceInfo) {\n    try {\n        getAdyenLibrary().connectDevice(deviceInfo, true, true);\n        getAdyenLibrary().setDefaultDeviceInfo(deviceInfo);\n    } catch (UnknownDeviceIdException e) {\n        Log.e(TAG, \"Failed to connect to device, first add the device to the Adyen library: \", e);\n    } catch (IOException e) {\n        Log.e(TAG, \"Failed to connect to device, network issues: \", e);\n    }\n}\u00a0<\/code><\/pre>\n<\/li>\n<\/ul>\n<h2 id=\"accept-payments\">Accept payments<\/h2>\n<p>\u00a0Once the terminal device is added and connected to the Adyen library. You can start making payment requests:<\/p>\n<ol>\n<li>\n<p>Create new <code>TransactionRequest<\/code> instance (This is the most basic transaction request):<\/p>\n<pre><code class=\"language-java\">transactionRequest = new TransactionRequest();\ntransactionRequest.setValue(value);\ntransactionRequest.setCurrencyCode(currency);\ntransactionRequest.setVendorDescription(description);\ntransactionRequest.setTransactionType(transactionType);\ntransactionRequest.setShopperLocale(Locale.getDefault().toString());\n\nArrayList&lt;TenderOptions&gt; tenderOptions = new ArrayList&lt;&gt;();\ntransactionRequest.setTenderOptions(tenderOptions);<\/code><\/pre>\n<\/li>\n<li>\n<p>Initiate a transaction with the previously created <code>TransactionRequest<\/code> instance.<\/p>\n<pre><code class=\"language-java\">\u00a0private void initiateTransaction(@NonNull TransactionRequest transactionRequest) {\n    try {\n        getAdyenLibrary().initiateTransaction(transactionRequest, createTransactionListener());\n    } catch (InvalidTransactionRequestException e) {\n        Log.e(TAG, \"Invalid transaction request: \", e);\n    } catch (AlreadyProcessingTransactionException e) {\n        Log.e(TAG, \"Transaction failed, that transaction already processed: \", e);\n    } catch (NoDefaultDeviceException e) {\n        Log.e(TAG, \"Transaction failed, first set default terminal device, then try again: \", e);\n    } catch (IOException e) {\n        Log.e(TAG, \"Transaction failed, network issues: \", e);\n    }\n}<\/code><\/pre>\n<\/li>\n<li>\n<p>Implement a <code>TransactionListener<\/code> to handle transaction responses as follows:<\/p>\n<pre><code class=\"language-java\">\u00a0private TransactionListener createTransactionListener() {\n    return new TransactionListener() {\n        @Override\n        public void onTransactionComplete(CompletedStatus completedStatus, String statusMessage, Integer code, Map&lt;String, String&gt; additionalData) {\n            Log.d(TAG, \"onTransactionComplete() called with: completedStatus = [\" + completedStatus + \"], statusMessage = [\" + statusMessage + \"], code = [\" + code + \"], additionalData = [\" + additionalData + \"]\");\n\n            switch (completedStatus) {\n                case APPROVED:\n                    \/\/ Transaction succeeded.\n                    break;\n                case DECLINED:\n                    \/\/ Declined because:\n                    \/\/ The amount too low or other card reasons.\n                    \/\/ Transaction was canceled by getAdyenLibrary().cancelTransaction().\n                    \/\/ etc.\n                    break;\n                case CANCELLED:\n                    \/\/ Transaction was cancel:\n                    \/\/ By the merchant from the Android app.\n                    \/\/ By the shopper from the Terminal device.\n                    break;\n                case ERROR:\n                    \/\/ My be because network issues, communication is lost.\n                    break;\n            }\n        }\n\n        @Override\n        public void onProgress(ProcessStatus processStatus, String message) {\n            Log.d(TAG, \"onProgress() called with: processStatus = [\" + processStatus + \"], message = [\" + message + \"]\");\n\n            switch (processStatus) {\n                case CONNECTING:\n                    \/\/ App is connecting to the terminal - just starts a connection\n                    break;\n                case IDENTIFYING:\n                    \/\/ Identifying the terminal - the connection was established and now the terminal is been identified\n                    break;\n                case PROCESSING:\n                    \/\/ The terminal is processing the payment\n                    break;\n                case NONETWORK:\n                    \/\/ The phone doesn't have internet connection\n                    break;\n                case NOROUTE:\n                    \/\/ The phone cannot connect to the Adyen backend (even if there is internet connection)\n                    break;\n                case CANCELLING:\n                    \/\/ The merchant or the shopper cancelled the transaction\n                    break;\n            }\n        }\n\n        @Override\n        public void onStateChanged(TenderStates tenderStates, String s, Map&lt;String, String&gt; map) {\n            Log.d(TAG, \"onStateChanged() called with: tenderStates = [\" + tenderStates + \"], s = [\" + s + \"], map = [\" + map + \"]\");\n\n            switch (tenderStates) {\n                case PIN_DIGIT_ENTERED:\n                    \/\/ pin digits was entered in the terminal device\n                    break;\n                case INITIAL:\n                    \/\/ transaction was initiated\n                    break;\n                case TENDER_CREATED:\n                    \/\/ a new tender was created\n                    break;\n                case CARD_INSERTED:\n                    \/\/ the card was inserted\n                    break;\n                case CARD_SWIPED:\n                    \/\/ the card was swiped\n                    break;\n                case WAIT_FOR_APP_SELECTION:\n                    \/\/ waiting for some input from the customer on the terminal\n                    break;\n                case APPLICATION_SELECTED:\n                    \/\/ the customer selected something from the previous step\n                    break;\n                case WAIT_FOR_AMOUNT_ADJUSTMENT:\n                    \/\/ waiting for an amount to be adjusted based on the gratuity\n                    break;\n                case ASK_GRATUITY:\n                    \/\/ gratuity option was selected in tender options and the shuttle requests for it\n                    break;\n                case GRATUITY_ENTERED:\n                    \/\/ gratuity amount was entered\n                    break;\n                case ASK_DCC:\n                    \/\/ dynamic currency conversion was selected in tender options\n                    break;\n                case DCC_ACCEPTED:\n                    \/\/ the conversion amount was accepted\n                    break;\n                case DCC_REJECTED:\n                    \/\/ the conversion amount was rejected\n                    break;\n                case PROCESSING_TENDER:\n                    \/\/ the payment is being processed (on the terminal you can see the progress bar)\n                    break;\n                case WAIT_FOR_PIN:\n                    \/\/ pin is being requested on the terminal\n                    break;\n                case PIN_ENTERED:\n                    \/\/ the user accepted the pin\n                    break;\n                case PROVIDE_CARD_DETAILS:\n                    \/\/ for MKE the card details are requested\n                    break;\n                case CARD_DETAILS_PROVIDED:\n                    \/\/ for MKE the card details were provided\n                    break;\n                case PRINT_RECEIPT:\n                    \/\/ starting printing the receipt (receipt generation)\n                    break;\n                case RECEIPT_PRINTED:\n                    \/\/ the receipt printing was finished\n                    break;\n                case REFERRAL:\n                    \/\/ the acquirer sends a referral status\n                    break;\n                case REFERRAL_CHECKED:\n                    \/\/ the referral code was checked\n                    break;\n                case CHECK_SIGNATURE:\n                    \/\/ after the user has entered the signature, there's a check between the signature on the card and the one on the screen\/receipt\n                    break;\n                case SIGNATURE_CHECKED:\n                    \/\/ the signature matched the one on the card\n                    break;\n                case ADDITIONAL_DATA_AVAILABLE:\n                    \/\/ additional data (like currency conversion rate, adjusted amount for gratuity and others) are available\n                    break;\n                case ERROR:\n                    \/\/ final states of a transaction\n                    break;\n                case APPROVED:\n                    \/\/ transaction was approved\n                    break;\n                case DECLINED:\n                    \/\/ transaction was declined\n                    break;\n                case CANCELLED:\n                    \/\/ transaction was cancelled\n                    break;\n                case UNKNOWN:\n                    break;\n                case ACKNOWLEDGED:\n                    break;\n            }\n        }\n    };\n}<\/code><\/pre>\n<\/li>\n<\/ol>","url":"https:\/\/docs.adyen.com\/pt\/point-of-sale\/classic-library-deprecation\/classic-library-integrations\/android-integration\/install-and-integrate-the-android-library","articleFields":{"id":"25145976","type":"page","_expandable":{"operations":""},"status":"current"},"algolia":{"url":"https:\/\/docs.adyen.com\/pt\/point-of-sale\/classic-library-deprecation\/classic-library-integrations\/android-integration\/install-and-integrate-the-android-library","title":"Install and integrate the Android library","content":"This guide will help you integrate your existing POS system, which runs on Android, with the plataforma de pagamentos da Adyen.\n\nBefore you begin to integrate, make sure you have followed the Get started with Adyen guide to:\n\nGet an overview of the steps needed to accept live payments.\nCreate your test account.\n\n\nAdd the Adyen library module as a dependency to your app module\n\n\nImport the new Adyen Android Library module.\n\nGo to\u00a0File\u00a0&gt;\u00a0Project Structure\u00a0in Android Studio.\nPress the\u00a0+\u00a0button on the upper-left corner of the\u00a0Project Structure\u00a0window\u00a0to\u00a0add a new\u00a0module.\u00a0\n\nIn the\u00a0Create new module\u00a0screen:\u00a0\n\nSelect\u00a0Import .JAR\/.AAR\u00a0Package\u00a0and click\u00a0Next.\nIn the file selector, browse to the\u00a0unzipped\u00a0adyen-android-library-{version}.aar\u00a0file.\n\n\n\n\n\n\n\nAdd a dependency in the app module\u00a0to the Adyen library module.\n\n\nGo to\u00a0File\u00a0&gt;\u00a0Project structure\u00a0in Android Studio.\n\n\nSelect the app module in the\u00a0Modules\u00a0list on the left.\n\n\nSelect the\u00a0Dependencies\u00a0tab.\u00a0\n\n\nAdd dependency on the\u00a0+\u00a0button on the lower left corner.\u00a0\n\n\nSelect\u00a03.Module dependency\u00a0in the drop down menu.\u00a0\n\n\nSelect the Adyen library module you have previously added in step 3.\n\n\n\n\n\n\u00a0Add dependency for\u00a0appcompat-v7.\n\n\nGo to\u00a0File\u00a0&gt;\u00a0Project Structure\u00a0in Android Studio.\n\n\nSelect the app module in the\u00a0Modules\u00a0list on the left.\n\n\nSelect the\u00a0Dependencies\u00a0tab.\u00a0\n\n\nClick the\u00a0+\u00a0button on the lower left to add the dependency.\n\n\nSelect\u00a01. Library dependency**\u00a0in the drop down menu.\n\n\nFrom the\u00a0Choose Library Dependency\u00a0screen choose the\u00a0com.android.support:appcompat-v7:{version}.\n\n\nClick\u00a0OK.\n\n\n\n\n\nSync project with gradle files.\n\n\nYou can now use the Adyen library in your Android application.\u00a0\nRegister your app module\n\n\nRegister your app module with the Adyen library module.\npublic class App extends Application {\n\n    @Override\n    public void onCreate() {\n        super.onCreate();\n\n        try {\n            LibraryReal.registerLib(getApplicationContext(), getString(R.string.app_name));\n        } catch (final AlreadyRegisteredException e) {\n            \/\/ Do nothing.\n        }\n    }\n}\n\napp_name - Format this value like so: Cash register company and product\u00a0\/\u00a0Cash register product version\u00a0\/ Adyen integration name\u00a0\/ Adyen integration version. For example,\u00a0 Acme Corp POS \/ 1.2.1 \/ Acme Adyen connector \/ 0.1\u00a0\n\n\n\nGet an instance of the Adyen library\n\n\nOnce the Adyen library is registered, you can use functionality from the Adyen library instance.\n@Nullable\npublic AdyenLibraryInterface getAdyenLibrary() {\n    if (mAdyenLibrary == null) {\n        try {\n            mAdyenLibrary = LibraryReal.getLib();\n        } catch (NotYetRegisteredException e) {\n            Log.e(TAG, \"Failed to get AdyenLibraryInterface, the library must be registered first\", e);\n        }\n    }\n\n    return mAdyenLibrary;\n}\n\n\nRegister the merchant credentials with the Adyen library\n\n\nRegister merchant credentials (merchant, username, password) with the Adyen library, and set the desired ServerMode [DEV\/TEST\/BETA\/LIVE].\nAdyenLibraryInterface adyenLibrary = getAdyenLibrary();\nadyenLibrary.setServerMode(ServerMode.TEST);\ntry {\n    adyenLibrary.registerApp(merchant, username, password, createRegistrationCompleteListener());\n} catch (AppAlreadyRegisteredException e) {\n    e.printStackTrace();\n} catch (AlreadyRegisteringAppException e) {\n    e.printStackTrace();\n} catch (InvalidRequestException e) {\n    e.printStackTrace();\n\n\nImplement the RegistrationCompleteListener to handle the response from registration of merchant credentials.\nprivate RegistrationCompleteListener createRegistrationCompleteListener() {\n    return (statusCode, appInfo, statusMessage) -&gt; {\n        Log.i(TAG, \"statusCode: \" + statusCode + \", statusMessage: \" + statusMessage);\n\n        switch (statusCode) {\n            case OK:\n                \/\/ Redirect from the LoginActivity to your HomeActivity\n                Intent intent = HomeActivity.getIntent(LoginActivity.this);\n                startActivity(intent);\n                finish();\n                break;\n            case ERROR_NONETWORK:\n                \/\/ Failed to register the app, network issues.\n                break;\n            case ERROR_BADCREDENTIALS:\n                \/\/ Failed to register the app, bad merchant credentials.\n                break;\n            case ERROR_NOROUTE:\n                \/\/ Failed to register the app, network issues.\n                \/\/ The phone cannot connect to the Adyen backend (even if there is internet connection)\n            case ERROR:\n                \/\/ Failed to register the app, general error look at the statusMessage.\n            default:\n                Log.e(TAG, \"statusCode: \" + statusCode + \", statusMessage: \" + statusMessage);\n                break;\n        }\n    };\n}\n\n\nRegister a payment\u00a0terminal\n\n\nCreate a new DeviceInfo instance:\nWi-Fi devices:\nDeviceInfo deviceInfo = new DeviceInfo();\ndeviceInfo.setConnectionType(DeviceInfo.TYPE_WIFI);\ndeviceInfo.setDeviceId(mDeviceIpAddressEditText.getText().toString());\ndeviceInfo.setFriendlyName(\"Cash register 1\");\nonAddDevice(deviceInfo);\nBluetooth devices:\nDeviceInfo deviceInfo = new DeviceInfo();\ndeviceInfo.setConnectionType(DeviceInfo.TYPE_BT);\ndeviceInfo.setFriendlyName(device.getName());\ndeviceInfo.setDeviceId(device.getAddress());\nonAddDevice(deviceInfo);\n\n\nAdd the device to the Adyen library:\nprivate void addDevice(@NonNull DeviceInfo deviceInfo) {\n    Log.d(TAG, \"addDevice() called with: deviceInfo = [\" + deviceInfo + \"]\");\n\n    try {\n        getAdyenLibrary().addDevice(createAddDeviceListener(), deviceInfo);\n    } catch (DeviceAlreadyAddedException e) {\n        e.printStackTrace();\n    } catch (AlreadyAddingDeviceException e) {\n        e.printStackTrace();\n    } catch (AppNotRegisteredException e) {\n        e.printStackTrace();\n    } catch (Exception e) {\n        e.printStackTrace();\n    }\n}\n\n\nImplement the AddDeviceListener\u00a0to handle adding devices to the Adyen library:\nprivate AddDeviceListener createAddDeviceListener() {\n    return new AddDeviceListener() {\n        @Override\n        public void onAddDeviceComplete(CompletedStatus completedStatus, String statusMessage, DeviceData deviceData) {\n            Log.d(TAG, \"onAddDeviceComplete() called with: completedStatus = [\" + completedStatus + \"], statusMessage = [\" + statusMessage + \"], deviceData = [\" + deviceData + \"]\");\n\n            switch (completedStatus) {\n                case OK:\n                    \/\/ Boarding the device succeeded\n                    break;\n\n                case TIMEOUT:\n                    \/\/ Failed to board the device, connection timeout.\n                    break;\n\n                case ERROR:\n                    \/\/ Failed to board the device, general error look at the status message.\n                    break;\n\n                case ERROR_SYNCACTION:\n                    \/\/ Failed to board the device, ???\n                    break;\n\n                case ERROR_VERIFY:\n                    \/\/ Failed to board the device, couldn't verify ???\n                    break;\n\n                case ERROR_NOROUTE:\n                    \/\/ Failed to board the device,\n                    \/\/ The phone cannot connect to the Adyen backend (even if there is internet connection)\n                    break;\n\n                case ERROR_IDENTIFY:\n                    \/\/ Failed to board the device, couldn't identify terminal device with Adyen backend.\n                    break;\n\n                case ERROR_REGISTER:\n                    \/\/ Failed to board the device, couldn't register the teminal device with Adyen backend.\n                    break;\n\n                case ERROR_NONETWORK:\n                    \/\/ Failed to board the device, network issues.\n                    break;\n\n                case ERROR_SYNCDEVICE:\n                    \/\/ Failed to board the device. failed to sync device with Adyen backend.\n                    break;\n\n                case ERROR_CONFLICTING_SERVER_MODE:\n                    \/\/ Failed to board the device, due to server mode try to register the Adyen library with a different server mode.\n                    break;\n            }\n        }\n\n        @Override\n        public void onProgress(ProcessStatus processStatus, String message) {\n            Log.d(TAG, \"onProgress() called with: processStatus = [\" + processStatus + \"], message = [\" + message + \"]\");\n\n            switch (processStatus) {\n                case PREPARING:\n                    break;\n                case IDENTIFY:\n                    break;\n                case REGISTER:\n                    break;\n                case SYNCACTION:\n                    break;\n                case SYNCDEVICE:\n                    break;\n                case VERIFY:\n                    break;\n                case RUNNING_TRANSACTION:\n                    break;\n                case STEP_4_OK:\n                    break;\n                case NONETWORK:\n                    break;\n                case NOROUTE:\n                    break;\n            }\n\n            if (!TextUtils.isEmpty(message)) {\n                \/\/ Notify the user with the progress status message.\n                mStatusTextView.setText(message);\n            }\n        }\n    };\n}\n\n\nConnect to the registered payment terminal\n\n\nOnce the payment terminal is added, you can connect it by using the connectDevice method:\nprivate void connectDevice(@NonNull DeviceInfo deviceInfo) {\n    try {\n        getAdyenLibrary().connectDevice(deviceInfo, true, true);\n        getAdyenLibrary().setDefaultDeviceInfo(deviceInfo);\n    } catch (UnknownDeviceIdException e) {\n        Log.e(TAG, \"Failed to connect to device, first add the device to the Adyen library: \", e);\n    } catch (IOException e) {\n        Log.e(TAG, \"Failed to connect to device, network issues: \", e);\n    }\n}\u00a0\n\n\nAccept payments\n\u00a0Once the terminal device is added and connected to the Adyen library. You can start making payment requests:\n\n\nCreate new TransactionRequest instance (This is the most basic transaction request):\ntransactionRequest = new TransactionRequest();\ntransactionRequest.setValue(value);\ntransactionRequest.setCurrencyCode(currency);\ntransactionRequest.setVendorDescription(description);\ntransactionRequest.setTransactionType(transactionType);\ntransactionRequest.setShopperLocale(Locale.getDefault().toString());\n\nArrayList&lt;TenderOptions&gt; tenderOptions = new ArrayList&lt;&gt;();\ntransactionRequest.setTenderOptions(tenderOptions);\n\n\nInitiate a transaction with the previously created TransactionRequest instance.\n\u00a0private void initiateTransaction(@NonNull TransactionRequest transactionRequest) {\n    try {\n        getAdyenLibrary().initiateTransaction(transactionRequest, createTransactionListener());\n    } catch (InvalidTransactionRequestException e) {\n        Log.e(TAG, \"Invalid transaction request: \", e);\n    } catch (AlreadyProcessingTransactionException e) {\n        Log.e(TAG, \"Transaction failed, that transaction already processed: \", e);\n    } catch (NoDefaultDeviceException e) {\n        Log.e(TAG, \"Transaction failed, first set default terminal device, then try again: \", e);\n    } catch (IOException e) {\n        Log.e(TAG, \"Transaction failed, network issues: \", e);\n    }\n}\n\n\nImplement a TransactionListener to handle transaction responses as follows:\n\u00a0private TransactionListener createTransactionListener() {\n    return new TransactionListener() {\n        @Override\n        public void onTransactionComplete(CompletedStatus completedStatus, String statusMessage, Integer code, Map&lt;String, String&gt; additionalData) {\n            Log.d(TAG, \"onTransactionComplete() called with: completedStatus = [\" + completedStatus + \"], statusMessage = [\" + statusMessage + \"], code = [\" + code + \"], additionalData = [\" + additionalData + \"]\");\n\n            switch (completedStatus) {\n                case APPROVED:\n                    \/\/ Transaction succeeded.\n                    break;\n                case DECLINED:\n                    \/\/ Declined because:\n                    \/\/ The amount too low or other card reasons.\n                    \/\/ Transaction was canceled by getAdyenLibrary().cancelTransaction().\n                    \/\/ etc.\n                    break;\n                case CANCELLED:\n                    \/\/ Transaction was cancel:\n                    \/\/ By the merchant from the Android app.\n                    \/\/ By the shopper from the Terminal device.\n                    break;\n                case ERROR:\n                    \/\/ My be because network issues, communication is lost.\n                    break;\n            }\n        }\n\n        @Override\n        public void onProgress(ProcessStatus processStatus, String message) {\n            Log.d(TAG, \"onProgress() called with: processStatus = [\" + processStatus + \"], message = [\" + message + \"]\");\n\n            switch (processStatus) {\n                case CONNECTING:\n                    \/\/ App is connecting to the terminal - just starts a connection\n                    break;\n                case IDENTIFYING:\n                    \/\/ Identifying the terminal - the connection was established and now the terminal is been identified\n                    break;\n                case PROCESSING:\n                    \/\/ The terminal is processing the payment\n                    break;\n                case NONETWORK:\n                    \/\/ The phone doesn't have internet connection\n                    break;\n                case NOROUTE:\n                    \/\/ The phone cannot connect to the Adyen backend (even if there is internet connection)\n                    break;\n                case CANCELLING:\n                    \/\/ The merchant or the shopper cancelled the transaction\n                    break;\n            }\n        }\n\n        @Override\n        public void onStateChanged(TenderStates tenderStates, String s, Map&lt;String, String&gt; map) {\n            Log.d(TAG, \"onStateChanged() called with: tenderStates = [\" + tenderStates + \"], s = [\" + s + \"], map = [\" + map + \"]\");\n\n            switch (tenderStates) {\n                case PIN_DIGIT_ENTERED:\n                    \/\/ pin digits was entered in the terminal device\n                    break;\n                case INITIAL:\n                    \/\/ transaction was initiated\n                    break;\n                case TENDER_CREATED:\n                    \/\/ a new tender was created\n                    break;\n                case CARD_INSERTED:\n                    \/\/ the card was inserted\n                    break;\n                case CARD_SWIPED:\n                    \/\/ the card was swiped\n                    break;\n                case WAIT_FOR_APP_SELECTION:\n                    \/\/ waiting for some input from the customer on the terminal\n                    break;\n                case APPLICATION_SELECTED:\n                    \/\/ the customer selected something from the previous step\n                    break;\n                case WAIT_FOR_AMOUNT_ADJUSTMENT:\n                    \/\/ waiting for an amount to be adjusted based on the gratuity\n                    break;\n                case ASK_GRATUITY:\n                    \/\/ gratuity option was selected in tender options and the shuttle requests for it\n                    break;\n                case GRATUITY_ENTERED:\n                    \/\/ gratuity amount was entered\n                    break;\n                case ASK_DCC:\n                    \/\/ dynamic currency conversion was selected in tender options\n                    break;\n                case DCC_ACCEPTED:\n                    \/\/ the conversion amount was accepted\n                    break;\n                case DCC_REJECTED:\n                    \/\/ the conversion amount was rejected\n                    break;\n                case PROCESSING_TENDER:\n                    \/\/ the payment is being processed (on the terminal you can see the progress bar)\n                    break;\n                case WAIT_FOR_PIN:\n                    \/\/ pin is being requested on the terminal\n                    break;\n                case PIN_ENTERED:\n                    \/\/ the user accepted the pin\n                    break;\n                case PROVIDE_CARD_DETAILS:\n                    \/\/ for MKE the card details are requested\n                    break;\n                case CARD_DETAILS_PROVIDED:\n                    \/\/ for MKE the card details were provided\n                    break;\n                case PRINT_RECEIPT:\n                    \/\/ starting printing the receipt (receipt generation)\n                    break;\n                case RECEIPT_PRINTED:\n                    \/\/ the receipt printing was finished\n                    break;\n                case REFERRAL:\n                    \/\/ the acquirer sends a referral status\n                    break;\n                case REFERRAL_CHECKED:\n                    \/\/ the referral code was checked\n                    break;\n                case CHECK_SIGNATURE:\n                    \/\/ after the user has entered the signature, there's a check between the signature on the card and the one on the screen\/receipt\n                    break;\n                case SIGNATURE_CHECKED:\n                    \/\/ the signature matched the one on the card\n                    break;\n                case ADDITIONAL_DATA_AVAILABLE:\n                    \/\/ additional data (like currency conversion rate, adjusted amount for gratuity and others) are available\n                    break;\n                case ERROR:\n                    \/\/ final states of a transaction\n                    break;\n                case APPROVED:\n                    \/\/ transaction was approved\n                    break;\n                case DECLINED:\n                    \/\/ transaction was declined\n                    break;\n                case CANCELLED:\n                    \/\/ transaction was cancelled\n                    break;\n                case UNKNOWN:\n                    break;\n                case ACKNOWLEDGED:\n                    break;\n            }\n        }\n    };\n}\n\n","type":"page","locale":"pt","boost":15,"hierarchy":{"lvl0":"Home","lvl1":"Terminais","lvl2":"Deprecation of classic libraries","lvl3":"Library integrations","lvl4":"Android integration","lvl5":"Install and integrate the Android library"},"hierarchy_url":{"lvl0":"https:\/\/docs.adyen.com\/pt","lvl1":"https:\/\/docs.adyen.com\/pt\/point-of-sale","lvl2":"https:\/\/docs.adyen.com\/pt\/point-of-sale\/classic-library-deprecation","lvl3":"https:\/\/docs.adyen.com\/pt\/point-of-sale\/classic-library-deprecation\/classic-library-integrations","lvl4":"https:\/\/docs.adyen.com\/pt\/point-of-sale\/classic-library-deprecation\/classic-library-integrations\/android-integration","lvl5":"\/pt\/point-of-sale\/classic-library-deprecation\/classic-library-integrations\/android-integration\/install-and-integrate-the-android-library"},"levels":6,"category":"In-person payments","category_color":"green","tags":["Install","integrate","Android","library"]}}
