Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Symbol ExoPlayerFactory not found

I am going insane trying to figure this out. It makes no sense at all. I have added the required implementation in my build.gradle file and synced it up just fine, but when I try to use ExoPlayer it isn't found. I have even tried manually entering in the import line using auto-complete and the only things available in auto-complete for com.google.android.exoplayer2 are Buildconfig and R. I don't know what is going on. I had a project that used it and everything was great. I hadn't opened it in a long time, but wanted to re-learn it, so I opened it, now no matter what I do it can't find the symbol for ExoPlayer.

Here is my build.gradle file...

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "test.notreal.justatext"
        minSdkVersion 21
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    sourceSets {
        main {
            jniLibs.srcDirs = ['libs']
        }
    }
    compileOptions {
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })

    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support:animated-vector-drawable:28.0.0'
    implementation 'com.android.support:cardview-v7:28.0.0'
    implementation 'com.android.support:recyclerview-v7:28.0.0'
    implementation 'com.android.support:design:28.0.0'
    implementation 'com.android.support:support-v13:28.0.0' //THIS
    implementation 'com.android.support:support-media-compat:28.0.0' //AND THIS
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.google.firebase:firebase-core:16.0.9'
    implementation 'com.google.firebase:firebase-auth:17.0.0'
    implementation 'com.google.firebase:firebase-database:17.0.0'
    implementation 'com.google.firebase:firebase-storage:17.0.0'
    implementation 'de.hdodenhof:circleimageview:1.3.0'
    implementation 'com.soundcloud.android:android-crop:1.0.1@aar'
    implementation 'com.jakewharton:butterknife:9.0.0-rc2'
    annotationProcessor 'com.jakewharton:butterknife-compiler:9.0.0-rc2'
    implementation 'com.github.jd-alexander:LikeButton:0.2.3'
    implementation 'com.github.bumptech.glide:glide:4.8.0'
    implementation 'fr.tvbarthel.blurdialogfragment:lib:2.2.0'
    implementation 'com.android.support:support-v4:28.0.0'
    implementation 'com.squareup.picasso:picasso:2.5.2'
    implementation 'com.nineoldandroids:library:2.4.0'
    implementation 'com.scottyab:aescrypt:0.0.1'
    implementation 'com.daimajia.slider:library:1.1.5@aar'
    implementation 'com.google.firebase:firebase-messaging:18.0.0'
    implementation 'com.google.android.exoplayer:exoplayer:r2.5.0' //RIGHT HERE
    implementation 'com.bignerdranch.android:recyclerview-multiselect:0.2'
    implementation 'com.theartofdev.edmodo:android-image-cropper:2.5.+'
    testImplementation 'junit:junit:4.12'
    implementation 'jp.co.cyberagent.android.gpuimage:gpuimage-library:1.4.1'
    implementation 'jp.wasabeef:glide-transformations:3.0.1'

}





apply plugin: 'com.google.gms.google-services'

In it you can see ...

implementation 'com.google.android.exoplayer:exoplayer:r2.5.0'

and the app will do gradle sync properly, but in my app all of the following is red...

import com.google.android.exoplayer2.ExoPlayerFactory;
import com.google.android.exoplayer2.SimpleExoPlayer;
import com.google.android.exoplayer2.extractor.DefaultExtractorsFactory;
import com.google.android.exoplayer2.extractor.ExtractorsFactory;
import com.google.android.exoplayer2.source.ExtractorMediaSource;
import com.google.android.exoplayer2.source.MediaSource;
import com.google.android.exoplayer2.trackselection.AdaptiveTrackSelection;
import com.google.android.exoplayer2.trackselection.DefaultTrackSelector;
import com.google.android.exoplayer2.trackselection.TrackSelection;
import com.google.android.exoplayer2.trackselection.TrackSelector;
import com.google.android.exoplayer2.ui.SimpleExoPlayerView;
import com.google.android.exoplayer2.upstream.BandwidthMeter;
import com.google.android.exoplayer2.upstream.DataSource;
import com.google.android.exoplayer2.upstream.DefaultBandwidthMeter;
import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory;
import com.google.android.exoplayer2.util.Util;

Everything after the exoplayer2. is red. It can't find the symbol for anything. In an attempt to assure myself I wasn't going nuts I started a new project, added the implementation for exoplayer in my fresh clean build.gradle file, opened up the main activity and type in

SimpleExoPlayer player = ExoPlayerFactory.newSimpleInstance(this);

And it cannot find the symbol. Can't import it, it still just shows the BuildConfig and R symbols for everything after the com.google.android.exoplayer2. I have tried updating to a newer version like 2.10.1, which causes build failures something about merging the android manifests failing, on a brand new clean app. So I can't update the version, but all of a sudden no matter what I do Android Studio can't find ExoPlayer symbols.

like image 950
Neglected Sanity Avatar asked Jun 04 '19 23:06

Neglected Sanity


2 Answers

The version you are using is pretty old one, and it maybe possible that it is conflicting with the Gradle version. What you can try is to downgrade the Gradle version or upgrade the Exoplayer to a more recent version, which is recommended.

like image 144
Kartik Shandilya Avatar answered Sep 22 '22 03:09

Kartik Shandilya


EDIT 10-06-2022

From version 2.16.0 of Exoplayer.

SimpleExoPlayer is deprecated. All functionality has been moved to ExoPlayer instead. ExoPlayer.Builder can be used instead of SimpleExoPlayer.Builder.

OLDER SOLUTION

Who still not found the ExoPlayerFactory class in the package even after updating, it's removed from version 2.14.0

you should use SimpleExoPlayer.Builder

Check here: https://github.com/google/ExoPlayer/releases

like image 23
Piyush Kumar Avatar answered Sep 21 '22 03:09

Piyush Kumar