Updated MoPub and now I get “can’t find referenced field” for ExoPlayer when building the signed apk Code Answer

Hello Developer, Hope you guys are doing great. Today at Tutorial Guruji Official website, we are sharing the answer of Updated MoPub and now I get “can’t find referenced field” for ExoPlayer when building the signed apk without wasting too much if your time.

The question is published on by Tutorial Guruji team.

The latest MoPub SDK (5.3) I guess updated the version of ExoPlayer. My app also uses ExoPlayer. I’m getting now the warning below when generating the signed apk. If I add a dontwarn to proguard then my code fails because it can’t find those fields at runtime.

I have this on my proguard and this has been working for a long while, it only started failing after updating MoPub today.

-keep class com.google.android.exoplayer2.** { *; }
-keep interface com.google.android.exoplayer2.**{ *; }
-keepclassmembers class com.google.android.exoplayer2.** { *; }

This is the error:

Warning: MyClass: can't find referenced field 'int mediaSequence' in program class com.google.android.exoplayer2.source.hls.playlist.HlsMediaPlaylist
Warning: MyClass: can't find referenced field 'boolean isEncrypted' in program class com.google.android.exoplayer2.source.hls.playlist.HlsMediaPlaylist$Segment
Warning: MyClass: can't find referenced field 'java.lang.String encryptionKeyUri' in program class com.google.android.exoplayer2.source.hls.playlist.HlsMediaPlaylist$Segment

What can I do to get around this error?

UPDATE: The field are defined like this:

public final int mediaSequence;
public final boolean isEncrypted;
public final String encryptionKeyUri;

Answer

Turns out I was compiling an old version of ExoPlayer and MoPub somehow was including a new one but only for a small part of it, the HLS part. This appears to have caused the issue because once I started compiling the new one on my own code everything started working again. It was very strange as the new version even made me change the code a bit so I have no idea how it was even compiling before.

We are here to answer your question about Updated MoPub and now I get “can’t find referenced field” for ExoPlayer when building the signed apk - If you find the proper solution, please don't forgot to share this with your team members.

Related Posts

Tutorial Guruji