库源与使用 ExoPlayer 的类 ImaAdsLoader 的字节码不匹配



在显示带有IMA扩展名和渐进式媒体源的广告时,我收到以下错误。应用在前贴片广告完成后崩溃。 导航到类 ImaAdsLoader 时,出现错误"库源与类 ImaAdsLoader 的字节码不匹配" java.lang.NoSuchMethodError: No virtual method getAdGroupIndexAfterPositionUs(J)I in class Lcom/google/android/exoplayer2/source/ads/AdPlaybackState; or its super classes (declaration of 'com.google.android.exoplayer2.source.ads.AdPlaybackState' appears in /data/app/com.example.exomedia-pEwo-P6MjYGRL3PeKbTLiw==/base.apk) at com.google.android.exoplayer2.ext.ima.ImaAdsLoader.getContentProgress(ImaAdsLoader.java:758) at com.google.ads.interactivemedia.v3.internal.iu.a(IMASDK:4) at com.google.ads.interactivemedia.v3.internal.jh.handleMessage(IMASDK:27) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:193) at android.app.ActivityThread.main(ActivityThread.java:6692) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858) 重现步骤: 使用以下属性

implementation 'com.google.android.exoplayer:exoplayer-core:2.10.7' implementation 'com.google.android.exoplayer:exoplayer-ui:2.10.7' implementation 'com.google.android.exoplayer:extension-ima:2.9.6'

并使用以下代码启动播放:

player=ExoPlayerFactory.newSimpleInstance(this,DefaultTrackSelector())
player_view.player=player
adsLoader?.setPlayer(player)

val dataSourceFactory = DefaultDataSourceFactory(
this,
"ExoDemo")
val mediaSource:MediaSource=ProgressiveMediaSource.Factory(dataSourceFactory)
.createMediaSource(Uri.parse(resources.getString(R.string.media_url_mp4)))
val adsMediaSource = AdsMediaSource(mediaSource, dataSourceFactory, adsLoader, player_view)

player?.prepare(adsMediaSource)
player?.setPlayWhenReady(true)

在以下版本的库和使用 ExtractorMediaSource 时,没有任何错误:

implementation 'com.google.android.exoplayer:exoplayer-core:2.9.6' implementation 'com.google.android.exoplayer:exoplayer-ui:2.9.6' implementation 'com.google.android.exoplayer:extension-ima:2.9.6'

我终于发现extension_ima的版本必须与正在使用的ExoPlayer库的版本相匹配。 或者,可以克隆ExoPlayer存储库并在本地依赖该模块。

https://github.com/google/ExoPlayer/tree/release-v2/extensions/ima

最新更新