当我将其添加到“视频纹理视图” xml文件中时,出现此错误java.lang.BootstrapMethodError:调用站点#72引导程序方法异常

问题描述

我想用Twilio库中的VideoTextureView播放本地视频。你能帮我吗?

package com.bariskarapelit.touchcontrol;

import androidx.appcompat.app.AppCompatActivity;

import android.annotation.SuppressLint;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.Toast;
import android.widget.VideoView;

import com.twilio.video.VideoTextureView;

public class MainActivity extends AppCompatActivity
{
    ImageButton circleButton,likeButton,dislikeButton;
    VideoView videoView;
    String videoPath;
    VideoTextureView videoTextureView;
    Uri uri;
    ImageView imageView ;


    int selectedImage = R.drawable.circlepng;



    @SuppressLint("ClickableViewAccessibility")
    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        imageView = new ImageView(this);






        //Burası defult resim. Butonlara tıklamadğında ilk olarak varsayılan olarka koaycağınız resim olacak.
        imageView.setimageResource(R.drawable.circlepng);



        final FrameLayout frameLayout = findViewById(R.id.frame_layout);
        LinearLayout linearLayout= findViewById(R.id.linearlayout);

        circleButton=findViewById(R.id.circle);
        dislikeButton=findViewById(R.id.dislike);
        likeButton=findViewById(R.id.like);

        videoTextureView=findViewById(R.id.video_view_top_right);

        


        //Burdaki hangi viewi dinleyeceği hocam.
        MultiTouchControl multiTouchControl = new MultiTouchControl(frameLayout,new MultiTouchControl.ComponentView() {
            @Override
            public View onCreateComponent() {
                ImageView image = new ImageView(frameLayout.getContext());
                image.setimageResource(selectedImage);

                return image;
            }
        });

        multiTouchControl.startListener();

        setupButtons();
    }

    private void setupButtons(){
        circleButton.setonClickListener(new View.OnClickListener()
        {
            @Override
            public void onClick(View view)
            {
                Toast.makeText(MainActivity.this,"Circle",Toast.LENGTH_LONG).show();
              selectedImage = R.drawable.circlepng;


            }
        });

        dislikeButton.setonClickListener(new View.OnClickListener()
        {
            @Override
            public void onClick(View view)
            {
                Toast.makeText(MainActivity.this,"dislike",Toast.LENGTH_LONG).show();
                selectedImage = R.drawable.dislike;



            }
        });
        likeButton.setonClickListener(new View.OnClickListener()
        {
            @Override
            public void onClick(View view)
            {
                Toast.makeText(MainActivity.this,"Like",Toast.LENGTH_LONG).show();

                selectedImage = R.drawable.like;


            }
        });
    }


}

MultiTouchControl代码

package com.bariskarapelit.touchcontrol;

import android.annotation.SuppressLint;
import android.os.Handler;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;

import java.util.ArrayList;
import java.util.List;

public class MultiTouchControl implements View.OnTouchListener {

    private ViewGroup root;
    private ComponentView componentView;
    private float circleSize = 100;
    private int duration = 1500;
    private List<Vector3> fingerTips = new ArrayList<>();
    private boolean enabled = true;

    public MultiTouchControl(ViewGroup root,ComponentView componentView,float circleSize,int duration) {
        this.root = root;
        this.componentView = componentView;
        this.circleSize = circleSize;
        this.duration = duration;
    }

    public MultiTouchControl(ViewGroup root,ComponentView componentView) {
        this.root = root;
        this.componentView = componentView;
    }


    public void startListener(){
        root.setonTouchListener(this);
    }


    @SuppressLint("ClickableViewAccessibility")
    @Override
    public boolean onTouch(View v,MotionEvent event) {
        if (!enabled)
            return false;
        final int points = event.getPointerCount();
        int removedPoint = -1;
        final int action = event.getAction() & MotionEvent.ACTION_MASK;
        if (event.getAction() == MotionEvent.ACTION_MOVE) {
            fingerTips.clear();
            return false;
        }
        if (action == MotionEvent.ACTION_POINTER_UP || action == MotionEvent.ACTION_UP)
            removedPoint = (action & MotionEvent.ACTION_POINTER_INDEX_MASK)
                    >> MotionEvent.ACTION_POINTER_INDEX_SHIFT;

        fingerTips.clear();

        for (int i = 0; i < points; i++) {
            int pointerID = event.getPointerId(i);
            if (pointerID == MotionEvent.INVALID_POINTER_ID) {
                continue;
            }
            if (removedPoint == i) {
                continue;
            }
            fingerTips.add(new Vector3(event.getX(i),event.getY(i),pointerID));
        }
        for (Vector3 fingerTip : fingerTips) {
            createCircle(fingerTip.x,fingerTip.y);
        }

        return true;
    }

    private void createCircle(float x,float y) {
        if (componentView != null) {
            View view = componentView.onCreateComponent();
            ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,ViewGroup.LayoutParams.WRAP_CONTENT);
            view.setX(x - circleSize / 2);
            view.setY(y - circleSize / 2);
            params.width = (int) circleSize;
            params.height = (int) circleSize;
            view.setLayoutParams(params);
            root.addView(view);
            dieAfter(view);
        }
    }

    private void dieAfter(final View view) {
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                root.removeView(view);
            }
        },duration);
    }

    static class Vector3 {
        public float x,y;
        public int id;

        public Vector3(float x,float y,int id) {
            this.x = x;
            this.y = y;
            this.id = id;
        }
    }

    interface ComponentView {
        View onCreateComponent();
    }

    public ViewGroup getRoot() {
        return root;
    }

    public MultiTouchControl setRoot(ViewGroup root) {
        this.root = root;
        return this;
    }

    public ComponentView getComponentView() {
        return componentView;
    }

    public MultiTouchControl setComponentView(ComponentView componentView) {
        this.componentView = componentView;
        return this;
    }

    public float getCircleSize() {
        return circleSize;
    }

    public MultiTouchControl setCircleSize(float circleSize) {
        this.circleSize = circleSize;
        return this;
    }

    public int getDuration() {
        return duration;
    }

    public MultiTouchControl setDuration(int duration) {
        this.duration = duration;
        return this;
    }

    public MultiTouchControl setEnabled(boolean enabled) {
        this.enabled = enabled;
        return this;
    }
}

Xml代码

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/linearlayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <FrameLayout
        android:id="@+id/frame_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        <com.twilio.video.VideoTextureView
            android:id="@+id/video_view_top_right"
            android:layout_width="match_parent"
            android:layout_height="match_parent"

            />


        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom"
            android:layout_marginBottom="10dp"
            android:gravity="center"
            android:orientation="horizontal">


            <ImageButton
                android:id="@+id/circle"
                android:layout_width="51dp"
                android:layout_height="51dp"
                android:layout_marginRight="50dp"

                android:background="@mipmap/launch1" />


            <ImageButton
                android:id="@+id/dislike"
                android:layout_width="51dp"
                android:layout_height="51dp"
                android:layout_marginRight="50dp"
                android:background="@mipmap/launch2"></ImageButton>


            <ImageButton
                android:id="@+id/like"
                android:layout_width="51dp"
                android:layout_height="51dp"

                android:background="@mipmap/launch3"

                ></ImageButton>


        </LinearLayout>


    </FrameLayout>

</LinearLayout>

将其添加到“视频纹理视图” xml文件中时出现此错误

错误代码

E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.bariskarapelit.touchcontrol,PID: 6041
java.lang.BootstrapMethodError: Exception from call site #72 bootstrap method
    at tvi.webrtc.Eglrenderer.init(Eglrenderer.java:181)
    at com.twilio.video.VideoTextureView.init(VideoTextureView.java:223)
    at com.twilio.video.VideoTextureView.init(VideoTextureView.java:208)
    at com.twilio.video.VideoTextureView.onAttachedToWindow(VideoTextureView.java:109)
   

我想使用“视频纹理视图”播放本地视频,但是当我将“视频纹理视图”添加到xml文件时,会出现此错误

解决方法

至少Twilio库支持Android 8。 我项目的版本从属于Android 8