如何在使用 ExoPlayer 库时使用 AndroidX 库?

huangapple go评论89阅读模式
英文:

How can I use androidx libraries with exoplayer libraries?

问题

我的构建在迁移到AndroidX后失败了,找不到ExoPlayer依赖项。
它还找不到我的ExoPlayer依赖类,我尝试通过启用jetifier true来修复,但仍然不起作用。
同步是正确的,但构建不起来。
以下是构建错误:
如何在使用AndroidX库时集成ExoPlayer库?
请帮忙。

在尝试使用目标SDK版本26时,类能够构建成功,但无法上传到Google Play商店。
如何在AndroidX库中使用ExoPlayer库?
以下是我的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'
    
    // 其他依赖...

    implementation 'com.google.android.exoplayer:exoplayer:2.6.0'
    // 其他依赖...
}

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

这是我的gradle.properties文件:

android.enableJetifier=true
android.useAndroidX=true
org.gradle.jvmargs=-Xmx512m
英文:

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

答案1

得分: 0

将exoplayer的依赖从2.6.0更改为2.7.3。

英文:

Change the dependency of exoplayer from 2.6.0 to 2.7.3

huangapple
  • 本文由 发表于 2020年10月22日 18:10:53
  • 转载请务必保留本文链接:https://go.coder-hub.com/64480048.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定