javaandroidbuild.gradle

How can I use androidx libraries with exoplayer libraries?


My build failed after migrating to androidx and cannot find exoplayer dependency. It's not also finding my exoplayer dependency class, I have tried to fix by enabling jetifier true but still, it doesn't work It's syncing properly but cant build Here is my error for the build How can I use androidx libraries with exoplayer libraries? Please help

       import com.google.android.exoplayer2.ExoPlayerFactory;
                                ^
       symbol:   class ExoPlayerFactory
      location: package com.google.android.exoplayer2
      C:\Users\DEV\Desktop\players - Copy\app\src\main\java\umo\com\players\opengl\MyGLRenderer.java:32: error: cannot find symbol
      import com.google.android.exoplayer2.Player;
                                ^
      symbol:   class Player
      location: package com.google.android.exoplayer2
      C:\Users\DEV\Desktop\players - Copy\app\src\main\java\umo\com\players\opengl\MyGLRenderer.java:33: error: cannot find symbol
      import com.google.android.exoplayer2.SimpleExoPlayer;
                                ^
      symbol:   class SimpleExoPlayer
      location: package com.google.android.exoplayer2
      C:\Users\DEV\Desktop\players - Copy\app\src\main\java\umo\com\players\opengl\MyGLRenderer.java:34: error: package com.google.android.exoplayer2.extractor does not exist
      import com.google.android.exoplayer2.extractor.DefaultExtractorsFactory;
                                          ^
      C:\Users\DEV\Desktop\players - Copy\app\src\main\java\umo\com\players\opengl\MyGLRenderer.java:35: error: package com.google.android.exoplayer2.source does not exist
      import com.google.android.exoplayer2.source.ExtractorMediaSource;
                                       ^
     C:\Users\DEV\Desktop\players - Copy\app\src\main\java\umo\com\players\opengl\MyGLRenderer.java:36: error: package com.google.android.exoplayer2.source does not exist
     import com.google.android.exoplayer2.source.MediaSource;
                                       ^
    C:\Users\DEV\Desktop\players - Copy\app\src\main\java\umo\com\players\opengl\MyGLRenderer.java:37: error: package com.google.android.exoplayer2.trackselection does not exist
    import com.google.android.exoplayer2.trackselection.AdaptiveTrackSelection;
                                               ^
    C:\Users\DEV\Desktop\players - Copy\app\src\main\java\umo\com\players\opengl\MyGLRenderer.java:38: error: package com.google.android.exoplayer2.trackselection does not exist
    import com.google.android.exoplayer2.trackselection.DefaultTrackSelector;
                                               ^

when I try to use target SDK version 26 the class does well and it builds but it cannot be uploaded to the google play store How can I use androidx libraries with exoplayer libraries? Here is my build.Gradle

      apply plugin: 'com.android.application'

android {
compileSdkVersion 29
defaultConfig {
    vectorDrawables.useSupportLibrary = true
    applicationId "umo.com.players"
    minSdkVersion 17
    targetSdkVersion 29
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
    multiDexEnabled true
}
lintOptions{
    checkReleaseBuilds false
    abortOnError false
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }    }
              }

dependencies {
implementation 'androidx.constraintlayout:constraintlayout:2.0.2'
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('androidx.test.espresso:espresso-core:3.1.0', {
    exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'androidx.legacy:legacy-support-v4:1.0.0-rc02'

testCompile 'junit:junit:4.12'

//Design library for Coordinator Layout and Toolbars
implementation 'com.google.android.material:material:1.0.0'

//ExifInterface support
implementation 'androidx.exifinterface:exifinterface:1.0.0'

//design library for Coordinator Layout
implementation 'com.google.android.material:material:1.0.0'
//Exo Player
implementation 'com.google.android.exoplayer:exoplayer:2.6.0'
//cardview
implementation 'androidx.cardview:cardview:1.0.0-rc02'

//recyclerview
implementation 'androidx.recyclerview:recyclerview:1.0.0-rc02'

//BottomNavigationViewEx library
compile 'com.github.ittianyu:BottomNavigationViewEx:1.1.9'
//Circle ImageView
compile 'de.hdodenhof:circleimageview:2.1.0'
//elastic header
compile 'com.github.eschao:android-ElasticListView:v1.0'
//material dialogs
implementation 'com.afollestad.material-dialogs:core:0.9.6.0'
//glide
implementation 'com.github.bumptech.glide:glide:4.4.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.4.0'
implementation files('libs/aspectjrt-1.7.3 (1).jar')
//Universal image loader
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
//firebase authentication
compile 'com.google.firebase:firebase-auth:10.2.6'
//firebase database
compile 'com.google.firebase:firebase-database:10.2.6'
//firebase storage
compile 'com.google.firebase:firebase-storage:10.2.6'
compile files('libs/aspectjrt-1.7.3 (1).jar')

compile 'com.google.firebase:firebase-messaging:10.2.6'
implementation 'com.squareup.retrofit2:retrofit:2.3.0'
implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
compile 'androidx.multidex:multidex:2.0.0'
}

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

Here is My Gradle. properties

    # The setting is particularly useful for tweaking memory settings.
    android.enableJetifier=true
    android.useAndroidX=true
    org.gradle.jvmargs=-Xmx512m

Solution

  • Change the dependency of exoplayer from 2.6.0 to 2.7.3