首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >错误充气类edmt.dev.videoplayer.VideoPlayerRecyclerView

错误充气类edmt.dev.videoplayer.VideoPlayerRecyclerView
EN

Stack Overflow用户
提问于 2022-02-04 18:44:45
回答 1查看 230关注 0票数 0

我试图在我的安卓应用程序中加入edmt.dev.videoplayer.VideoPlayerRecyclerView来显示多个视频。构建没有错误。但是得到错误膨胀类edmt.dev.videoplayer.VideoPlayerRecyclerView。无法察觉我做错了什么。提前感谢你的帮助。

错误逻辑:

代码语言:javascript
复制
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.gogon.wetest, PID: 15582
android.view.InflateException: Binary XML file line #22: Binary XML file line #22: Error inflating class edmt.dev.videoplayer.VideoPlayerRecyclerView
    Caused by: android.view.InflateException: Binary XML file line #22: Error inflating class edmt.dev.videoplayer.VideoPlayerRecyclerView
    Caused by: java.lang.reflect.InvocationTargetException
        at java.lang.reflect.Constructor.newInstance0(Native Method)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:334)
        at android.view.LayoutInflater.createView(LayoutInflater.java:647)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:790)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:863)
        at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
        at com.gogon.wetest.ui.watch.WatchFragment.onCreateView(WatchFragment.java:38)

fragment_watch.xml

代码语言:javascript
复制
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:tools="http://schemas.android.com/tools"
    android:background="@color/success_green"
    tools:context="com.gogon.wetest.ui.watch.WatchFragment">

    <edmt.dev.videoplayer.VideoPlayerRecyclerView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/video_player_id"
        android:orientation="vertical"/>
</RelativeLayout>

WatchFragment.java

代码语言:javascript
复制
package com.gogon.wetest.ui.watch;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;

import com.bumptech.glide.Glide;
import com.bumptech.glide.RequestManager;
import com.bumptech.glide.request.RequestOptions;
import com.gogon.wetest.R;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;

import butterknife.BindView;
import butterknife.ButterKnife;
import edmt.dev.videoplayer.VideoPlayerRecyclerView;
import edmt.dev.videoplayer.adapter.VideoPlayerRecyclerAdapter;
import edmt.dev.videoplayer.model.MediaObject;
import edmt.dev.videoplayer.utils.VerticalSpacingItemDecorator;

public class WatchFragment extends Fragment {

    VideoPlayerRecyclerView videoPlayerRecyclerView;

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view =  inflater.inflate(R.layout.fragment_watch, container, false);

        videoPlayerRecyclerView = view.findViewById(R.id.video_player_id);

        ButterKnife.bind(requireActivity());
        init();

        return view;
    }

    private void init() {
        LinearLayoutManager layoutManager = new LinearLayoutManager(getContext());
        videoPlayerRecyclerView.setLayoutManager(layoutManager);
        VerticalSpacingItemDecorator verticalSpacingItemDecorator = new VerticalSpacingItemDecorator(10);
        videoPlayerRecyclerView.addItemDecoration(verticalSpacingItemDecorator);

        ArrayList<MediaObject> sourceVideos = new ArrayList<>(sampleVideoList());
        videoPlayerRecyclerView.setMediaObjects(sourceVideos);

        VideoPlayerRecyclerAdapter videoAdapter = new VideoPlayerRecyclerAdapter(sourceVideos, initGlide());
        videoPlayerRecyclerView.setAdapter(videoAdapter);
    }

    private RequestManager initGlide() {

        RequestOptions requestOptions = new RequestOptions()
                .placeholder(R.drawable.white_background)
                .error(R.drawable.white_background);

        return Glide.with(getContext()).setDefaultRequestOptions(requestOptions);
    }

    private List<MediaObject> sampleVideoList() {

        return Arrays.asList(
                //title, media-url, thumbnail, description
                new MediaObject(
                        "For Bigger Blazes",
                        "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ForBiggerBlazes.mp4",
                        "https://i.ytimg.com/vi/Dr9C2oswZfA/maxresdefault.jpg",
                        "Big Buck Bunny tells the story of a giant rabbit with a heart bigger than himself. When one sunny day three rodents rudely harass him, something snaps... and the rabbit ain't no bunny anymore! In the typical cartoon tradition he prepares the nasty rodents a comical revenge.\\n\\nLicensed under the Creative Commons Attribution license\\nhttp://www.bigbuckbunny.org"
                ),
                new MediaObject(
                        "Tears of Steel",
                        "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/TearsOfSteel.mp4",
                        "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTSNuOK0PKeBYclnOvqAmKtUlJ_nQsN0YPYZ8gL7u-wKilHYs2S",
                        "Big Buck Bunny tells the story of a giant rabbit with a heart bigger than himself. When one sunny day three rodents rudely harass him, something snaps... and the rabbit ain't no bunny anymore! In the typical cartoon tradition he prepares the nasty rodents a comical revenge.\\n\\nLicensed under the Creative Commons Attribution license\\nhttp://www.bigbuckbunny.org"
                ),
                new MediaObject(
                        "What care can you get for a grand?",
                        "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/WhatCarCanYouGetForAGrand.mp4",
                        "https://www.jeep.com/content/dam/fca-brands/na/jeep/en_us/2021/grand-cherokee/gallery/exterior/MY21-Grand-Cherokee-Gallery-Exterior-Overland-Granite-Crystal-Desktop.jpg.image.1440.jpg",
                        "Big Buck Bunny tells the story of a giant rabbit with a heart bigger than himself. When one sunny day three rodents rudely harass him, something snaps... and the rabbit ain't no bunny anymore! In the typical cartoon tradition he prepares the nasty rodents a comical revenge.\\n\\nLicensed under the Creative Commons Attribution license\\nhttp://www.bigbuckbunny.org"
                )
        );
    }
}

build.gradle:

代码语言:javascript
复制
plugins {
    id 'com.android.application'
    id 'com.google.gms.google-services'
    id 'androidx.navigation.safeargs'
}

repositories {
    google() 
    mavenCentral()
}


android {
    compileSdkVersion 31
    buildToolsVersion "30.0.3"

    defaultConfig {
        applicationId "com.gogon.wetest"
        minSdkVersion 21
        targetSdkVersion 30
        versionCode 5
        versionName "1.0.1"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    //enable view binding
    buildFeatures {
        viewBinding true
    }
}

dependencies {

    //for video player
    implementation "com.google.android.exoplayer:exoplayer:2.16.1"
    implementation 'com.jakewharton:butterknife:10.2.3'
    annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.3'
    implementation 'com.github.eddydn:videoplayer:1.10'
    
    //glide- for image loading and caching library
    implementation 'com.github.bumptech.glide:glide:4.12.0'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0'
}
EN

回答 1

Stack Overflow用户

发布于 2022-02-04 19:15:17

我找到了原因, --这是项目中的VideoPlayerRecyclerView类目录,edmt.dev.videoplayer前缀是您复制的源代码的包名,用您的包目录复制,(代码中的VideoPlayerRecyclerView类目录)

对于类似于com.gogon.wetest.VideoPlayerRecyclerView的内容,请为VideoPlayerRecyclerView类检查正确的目录地址。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70991373

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档