google / ExoPlayer

This project is deprecated and stale. The latest ExoPlayer code is available in https://github.com/androidx/media
https://developer.android.com/media/media3/exoplayer
Apache License 2.0
21.74k stars 6.03k forks source link

Library source does not match the bytecode for class ImaAdsLoader #6707

Closed droidmonktutorials closed 4 years ago

droidmonktutorials commented 4 years ago

While displaying ads with IMA extension and the ProgressiveMediaSource, I am getting the following error. The app crashed just after the preroll ad completes. On navigating to the class ImaAdsLoader I get the error "Library source does not match the bytecode for class 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) Steps to reproduce : Use the following dependencies

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'

And initiate the playback with the following code:

` 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)`

The works without any error with the following versions of the libraries and using 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'

andrewlewis commented 4 years ago

Does the error go away if you use the same version number for all the modules?

droidmonktutorials commented 4 years ago

Yes it works, and I have realized that if I want to use exoplayer-core:2.10.7 then I can clone the ExoPlayer repository and depend on the module locally. But it would have been great if we could use the latest version of exoplayer_core with extension_ima without cloning the repository. Is that not possible?

andrewlewis commented 4 years ago

It shouldn't be necessary to clone the sources. It looks like the maven repository has both exoplayer-core:2.10.7 and extension-ima:2.10.7. Could you give some more details on what goes wrong if you try to depend on those?

droidmonktutorials commented 4 years ago

My bad, it works. I am extremely sorry.