javaandroidmedia-playerbrightcove

Cannot resolve symbol BrightcovePlayer


I am following the quick start of brightcove-native-sdk-android to implement a media player.

The Sync with the build.gradle passes ok but then when building my App, I got the error:

Cannot resolve symbol 'BrightcovePlayer'.

I think this is related with the repository mentioned in the quick-start but cannot hack the root cause. Have followed these questions too:

Currently my code looks like:

MainActivity.java

package com.example.jchavarr.helloworld;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.R;

public class MainActivity extends BrightcovePlayer  {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        brightcoveVideoView  = (BrightcoveExoPlayerVideoView) findViewById(R.id.brightcove_video_view);
    }
}

Activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.brightcove.playvideos.MainActivity">

    <!-- Implementing the player from HLS Brightcove-->
    <!-- https://support.brightcove.com/hls-playback-native-sdk-android -->
    <com.brightcove.player.view.BrightcoveExoPlayerVideoView
        android:id="@+id/brightcove_video_view"
        android:layout_width="match_parent"
        android:layout_height="280dp"
        android:layout_gravity="center"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintBottom_toBottomOf="parent"
    />

</android.support.constraint.ConstraintLayout>

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.jchavarr.helloworld">

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
    <uses-permission android:name="android.permission.INTERNET"/>
</manifest>

build.gradle (app)

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.3"
    defaultConfig {
        applicationId "com.example.jchavarr.helloworld"
        minSdkVersion 23
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

repositories {
    maven {
        url 'http://repo.brightcove.com/releases'
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:25.3.1'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile "com.brightcove.player:exoplayer:4.4+" //**
    //compile 'com.brightcove.player:android-sdk:6.+'
    //compile "com.brightcove.player:android-appcompat-plugin:${anpVersion}"
    testCompile 'junit:junit:4.12'
}

Do I need to download any AAR of some file? Is the URL http://repo.brightcove.com/releases the correct repository? Do I need to place the package: package com.brightcove.playvideos; in the MainActivity.java


Solution

  • The fix is importing some required packaged not mentioned in the quick start guide:

    import com.brightcove.player.model.DeliveryType;
    import com.brightcove.player.model.Video;
    import com.brightcove.player.view.BrightcoveExoPlayerVideoView;
    import com.brightcove.player.view.BrightcovePlayer;