Skip to content

Compiling & Importing PBD SDK

Guanjie-Liu edited this page Sep 18, 2016 · 7 revisions

###Compile Pay-by-Data SDK Make sure the PBD code and the original AOSP is merged correctly.
Go the the root directory of you AOSP folder, and execute the followings:
. build/envsetup.sh
lunch sdk-eng or lunch sdk_x86-eng
make update-api
make sdk or make -j6 sdk

###Import PBD SDK into Android Studio

  1. The compiled sdk should be in out/host/linux-x86/sdk. Copy the sdk to another location to avoid it being overwritten by future build.

  2. Go to your copied custom sdk directory, enter the subfolder called platforms, you will see another subfolder(probably named android-5.0.2). Change the subfolder's name to android-, being your sdk api level. In this case(for android-5.0.2): android-21.

  3. Open Android Studio, create a new project, go to Project Structure under Files tab, to change the SDK path to the one you built.

  4. Then update build.Gradle(Module:app) file: update compileSdkVersion & targetSdkVersion to the custom sdk api level(21). update the support library in the dependencies block to a version that matched the compileSdkVersion(21.0.2).

After the indexing is completed, you should be able to access the PBD API within Android Studio. If not, try Invalidate cache and restart in Files tab. After the restart it should be working.

###Running PBD Emulator The PBD versions of emulator will be compiled together with the SDK. It's located in /system_images. For this android-5.0.2_r1 source code, if you used lunch sdk-eng you will build an emulator system image with ABI armeabi-v7a. This is ABI is declared to be 10x slower than the x86 ABI, so it's better to use lunch sdk_x86-eng.

You need to install Emulator first if you haven't done so. Then create a new emulator, choose Nexus 7 device and choose a Lollipop system image. You should notice that's the only one you don't need to download, because it has been built together with your SDK.

###Testing your App I recommend you to use a Nexus 7 device to test your app if you have one. Because it gives you a more genuine testing environment and faster performance than using emulator(as least for me).

However regardless what you use to test your app, if you app requires access to the PBD API, you will need to create your own DPA file for you app, and install it to your device or emulator in order to pass authentications.
It's simple to do that:

  1. create your DPA json file using the format provided by this project.
  2. Then get the start ADB as root users:
    abd root
    adb remount
  3. Finally push the DPA to the device:
    adb push <your DPA> /data/data/

Now your app should have the permissions to use the PBD API.