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

问题描述 投票:0回答:1

同时显示带有IMA扩展名和ProgressiveMediaSource的广告时,出现以下错误。前置广告完成后,应用程序崩溃了。导航到类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'

exoplayer exoplayer2.x
1个回答
0
投票

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

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

© www.soinside.com 2019 - 2024. All rights reserved.