感谢您的访问。此页面目前仅提供英语版本。我们正在开发中文版本。谢谢您的理解。

Add or Remove Component in Your App

 IV: Add Components for More Functionality

As desired, add one or more of the following components to your app. These components are introduced in more detail in Components Overview. Instructions for adding the component are available within the component's page. Although documentation for each component is specific, you load all components in the same way.

Component Quick Reference

The following table provides a quick reference list of all components.

Interface Component Description
Authentication AdobepassAuthComponent Uses Adobe Pass (Primetime) to authenticate users.
FacebookAuthComponent Uses Facebook to authenticate users.
LoginWithAmazon Component Uses Login with Amazon to authenticate users.
PassThroughLoginComponent Default. Dummy authentication component.
Analytics FlurryAnalyticsComponent Uses Flurry Analytics to provide analytics.
OmnitureAnalyticsComponent Uses Omniture to provide analytics.
CrashlyticsComponent Uses Crashlytics to provide analytics.
GoogleAnalyticsComponent Uses Google Analytics to provide analytics.
ComScoreAnalyticsComponent Uses comScore to provide analytics.
LoggerAnalyticsComponent Default. Dummy analytics component.
Ads components FreeWheelAdsComponent Used for displaying Freewheel ads in your app.
VastAdsComponent Used for displaying VAST ads in your app.
PassThroughAdsComponent Default. Dummy ads component.
Purchasing component AmazonInAppPurchasingComponent Uses Amazon In-App Purchasing to allow users to choose Daily Pass (24-hour access) or Go Premium (subscription) to view the media in your app. This component is loaded by default but not configured.
UAMP AMZNMediaPlayerComponent Default. Uses the Amazon media player, based on ExoPlayer.
BrightCoveMediaPlayerComponent Uses the BrightCove media player.

Component Requirements: One Component per Interface

With the exception of analytics components, you can load only one component per interface. For example, you cannot load both the VAST Ads component and the Freewheel Ads component, because both components use the same IAds interface.

Additionally, all components require you to have a component loaded in your app for that interface. Because of this requirement, some components are dummy components that simply fulfill the requirements of having a component. The following are dummy components:

  • LoggerAnalyticsComponent
  • PassThroughAdsComponent
  • PassThroughLoginComponent

These dummy components don't do anything. Note that the InAppPurchasingComponent is loaded by default but not configured (so it has no impact unless configured). For a list of the component interface groups, see Available Components and Interfaces in Components Overview.

Add or Remove a Component in Your App

Adding or removing a component follows the same general steps. When adding a component, you add a component name. When removing a component, you remove the component name.

  1. In Android Studio, in the Android view, expand Gradle Scripts (in the left sidebar) and open the settings.gradle (Project Settings) file. (This file appears near the bottom of the list.)
  2. In the two sections where /* Implementations \*/ appears, add or remove the components that you want. (You're required to list one and only one component per interface type — ads, authorization, analytics, purchasing, and UAMP.)

    Note that in the /* Implementations */ sections, the component name appears three times.

    include ':app',
            /* Frameworks */
            ':TVUIComponent',
            ':UAMP',
            /* Libraries */
            ':Calligraphy',
            ':ContentModel',
            ':ContentBrowser',
            ':DynamicParser',
            ':DataLoader',
            ':Utils',
            // Uncomment when using ComScore Analytics
            //':comscore',
            /* Interfaces */
            ':PurchaseInterface',
            ':AuthInterface',
            ':AdsInterface',
            ':AnalyticsInterface',
            ':ModuleInterface',
            /* Implementations */
            ':PassThroughAdsComponent',
            ':AMZNMediaPlayerComponent',
            ':PassThroughLoginComponent',
            ':LoggerAnalyticsComponent'
    
    ...
    
    /* Implementations */
    project(':AMZNMediaPlayerComponent').projectDir = new File(rootProject.projectDir, '../AMZNMediaPlayerComponent')
    project(':PassThroughAdsComponent').projectDir = new File(rootProject.projectDir, '../PassThroughAdsComponent')
    project(':PassThroughLoginComponent').projectDir = new File(rootProject.projectDir, '../PassThroughLoginComponent')
    project(':LoggerAnalyticsComponent').projectDir = new File(rootProject.projectDir, '../LoggerAnalyticsComponent')
    

    For the component names, use the component's name as shown below:

    Ads interface components:

    Analytics interface components:

    Authentication interface components:

    Purchase interface components:

    UAMP interface components:

  3. Expand Gradle Scripts and open the build.gradle (Module: app) file.
  4. In the dependencies object, add or remove the components you want to include in your app. For example:

    compile project(':TVUIComponent')
    compile project(':UAMP')
    compile project(':AMZNMediaPlayerComponent')
    compile project(':PassThroughAdsComponent')
    compile project(':PassThroughLoginComponent')
    compile project(':LoggerAnalyticsComponent')
    
  5. Resync your project with Gradle by clicking Sync Now (which appears in the upper-right corner when Android Studio detects a change in the Gradle files). You can also click the Sync Project with Gradle Files button Sync Gradle button .

    When you're be notified that some modules are no longer imported from Gradle anymore, click OK.

    When the project syncs, you will see the new components reflected in the Project pane. (For example, if you enable the VastAdsComponent, after the sync finishes, you will see VastAdsComponent in Android's project pane.)

  6. You can remove old build artifacts from previous components by going to Build > Rebuild Project.

Configure the Component's Values

Each component has a list of customizable strings that have been extracted out into an XML file. Because of this, to customize a component with your app, you merely need supply the right values for the strings. You don't need to modify the Java classes.

However, different components may require a little more setup than others, especially because they usually involve implementing and setting up a third-party service. Because of this, see the documentation for each component for the specifics of how to configure the component:

The strings that have been extracted for each component are the most common parameters only. If you need an additional feature within the component that hasn't been extracted out into a string, you will need to customize it in the component's class that implements the interface.

The XML files for each component are usually located in the component's res > values folder.

The most common values that you would need to customize for each component are extracted out into XML files.

Next Steps

After you've added all the components you want, go to the next map: V: Add Recommendations. The first topic in Recommendations is Recommendations Overview. Note that adding recommendations functionality to your app is optional. However, your app will probably get more usage if you can send recommended media from your app to the user's Home screen.