You must install the correct Mobile SDKs in your Android project to call the remote services you need in your app. You should first install Liferay’s prebuilt Mobile SDK. This is required for any app that leverages Liferay. To call your custom portlet’s services, you also need to install the Mobile SDK that you built for it. For instructions on building a Mobile SDK for your custom portlet, see the tutorial Building Mobile SDKs.
This tutorial shows you how to install Liferay’s prebuilt Mobile SDK, and any custom built Mobile SDKs. First, you’ll learn how to use Gradle or Maven to install Liferay’s prebuilt Mobile SDK. You’ll then learn how to install a Mobile SDK manually, which is required for installing any custom built Mobile SDKs. Now go forth and fear no remote service!
If your Android project is using Gradle as the build system, you can add Liferay’s prebuilt Mobile SDK as a dependency to your project. All versions are available at the JCenter and Maven Central repositories. Both repositories are listed here, but you only need to have one in your app:
compile group: 'com.liferay.mobile', name: 'liferay-android-sdk', version: '6.2.0.+'
If you get errors such as
Duplicate files copied in APK META-INF/NOTICE when
building with Gradle, add this to your
That’s all there is to it! When your project syncs with your Gradle files, Liferay’s prebuilt Mobile SDK downloads to your project. The instructions for doing this with Maven are shown next.
You can also add the Liferay’s prebuilt Mobile SDK as a dependency to your
project using Maven. To do so, add the following code to your
Awesome! However, what if you’re not using Gradle or Maven? What if you want to install a custom built Mobile SDK? No problem! The next section shows you how to install a Mobile SDK manually.
Use the following steps to manually set up a Mobile SDK in your Android project:
To install Liferay’s prebuilt Mobile SDK, first download the latest version of
liferay-android-sdk-[version].jar. If you built your own Mobile SDK, find its JAR file on your machine. This is detailed in the Building Mobile SDKs tutorial.
Copy the JAR into your Android project’s
If you’re manually installing Liferay’s prebuilt Mobile SDK, you also need to download and copy these dependencies to your Android Project’s
Start using it!
Great! Now you know how to manually install a Mobile SDK in your Android apps.
If you want to invoke remote web services for your custom portlet, then you need to generate its client libraries by building an Android Mobile SDK yourself. Building an SDK is covered in the tutorial Building Mobile SDKs. Once you build an SDK to a JAR file, you can install it using the manual installation steps above (make sure to use the JAR file you built instead of Liferay’s prebuilt JAR file). Note that because your custom built SDKs contain only the client libraries for calling your custom portlet services, you must install them alongside Liferay’s prebuilt SDK. Liferay’s prebuilt SDK contains additional classes that are required to construct any remote service call.
Super! Now that the remote services you need are available in your app, you’re ready to call them.