Bug? [FIXED] Using a second identical layout in ExoPlayer Example crashes the app

Andris

Active Member
Licensed User
Longtime User
I found myslf unable to add an ExoPlayer to my project so I went back to the simplest example, found at the end of the ExoPlayer Library post, to try to duplicate the problem. ExoPlayerExample as downloaded there compiles and runs perfectly on my device.

I then did a Save As on layout "1" and saved it as layout "2." I changed one line of code to "2" to use layout "2" instead of the original "1" :
ExoPlayer Example Code:
Sub Activity_Create(FirstTime As Boolean)
    If FirstTime Then
        player1.Initialize("player")
        Dim sources As List
        sources.Initialize
        sources.Add(player1.CreateUriSource("https://html5demos.com/assets/dizzy.mp4"))
        player1.Prepare(player1.CreateListSource(sources))
      
    End If
'    Activity.LoadLayout("1")
    Activity.LoadLayout("2")
    SimpleExoPlayerView1.Player = player1
    player1.Play
End Sub

This also ran perfectly. No problem.

Then I created a third layout from scratch, without duplicating the original one. I placed a SimpleExoPlayer view onto a new layout. I kept the name at the default, the same as views "1" and "2". I changed the line of code to "3" to load the new layout instead of layout "2":
ExoPlayer Example Code:
Sub Activity_Create(FirstTime As Boolean)
    If FirstTime Then
        player1.Initialize("player")
        Dim sources As List
        sources.Initialize
        sources.Add(player1.CreateUriSource("https://html5demos.com/assets/dizzy.mp4"))
        player1.Prepare(player1.CreateListSource(sources))
      
    End If
'    Activity.LoadLayout("1")
'    Activity.LoadLayout("2")
    Activity.LoadLayout("3")
    SimpleExoPlayerView1.Player = player1
    player1.Play
End Sub

This time, the project crashes. The layout is unable to load, with the following error message at the end of the debugger:
Caused by: java.lang.NoSuchFieldException: RESIZE_MODE_null
at java.lang.Class.getField(Class.java:1604)
at anywheresoftware.b4a.objects.SimpleExoPlayerViewWrapper.setResizeMode(SimpleExoPlayerViewWrapper.java:69)

This looks like it explains why I can't add an ExoPlayer to my project. Am I missing a step somewhere, or is this a bug that has appeared recently? Library versions are the latest ones.
 

DonManfred

Expert
Licensed User
Longtime User
Reproduce it in a small project and upload the project.
Hard to say what you have missed.
 

Andris

Active Member
Licensed User
Longtime User
Reproduce it in a small project and upload the project.
Hard to say what you have missed.

Here's the crash illustration project. It is IDENTICAL to Erel's ExoPlayer Library example, except that I've added 2.bal and 3.bal to Files through Designer. 2.bal is a "Save As" of 1.bal and doesn't crash. 3.bal is created from scratch but identical to 1.bal and crashes. See the ##### NOTES ###### section in the code.
 

Attachments

  • ExoPlayerCrash.zip
    11.3 KB · Views: 159

Erel

B4X founder
Staff member
Licensed User
Longtime User
It is related to a bug in ExoPlayer v1.40. Update to v1.41 and click on the ExoPlayer custom view. It will add the missing properties.


Should look like this:
B4A_KkMqc2pQ1u.png
 
Top