繁体   English   中英

反应原生错误包android.support.v7.app不存在

[英]react native error package android.support.v7.app does not exist

在 react-native-video 中,当 react-native run-android 发生这些错误时,我无法删除这些

android.useAndroidX=true android.enableJetifier=true 来自 gradle.properties

我需要它们来响应本机手势处理程序

尝试添加实现 'androidx.appcompat:appcompat:${rootProject.ext.supportLibVersion}'

但它不起作用

在此处输入图片说明

package com.sales_crm;

import android.app.ProgressDialog;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.graphics.PixelFormat;
import android.media.MediaPlayer;
import android.net.Uri;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.widget.MediaController;
import android.widget.Toast;
import android.widget.VideoView;

public class VideoActivity extends AppCompatActivity {
    private String videoPath;

    private static ProgressDialog progressDialog;
    VideoView myVideoView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
        setContentView(R.layout.player_fullscreen);
        Intent i = getIntent();
        if(i != null){
            myVideoView = (VideoView) findViewById(R.id.videoView);
            videoPath = i.getStringExtra("VIDEO_URL");
            progressDialog = ProgressDialog.show(VideoActivity.this, "", "Buffering video...", true);
            progressDialog.setCancelable(true);
            PlayVideo();
        }
        else{
            Toast.makeText(VideoActivity.this, "VideoURL not found", Toast.LENGTH_SHORT).show();
        }


    }

    private void PlayVideo() {
        try {
            getWindow().setFormat(PixelFormat.TRANSLUCENT);
            MediaController mediaController = new MediaController(VideoActivity.this);
            mediaController.setAnchorView(myVideoView);

            Uri video = Uri.parse(videoPath);
            myVideoView.setMediaController(mediaController);
            myVideoView.setVideoURI(video);
            myVideoView.requestFocus();
            myVideoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
                public void onPrepared(MediaPlayer mp) {
                    progressDialog.dismiss();
                    if(BridgeModule.duration!=0)
                     myVideoView.seekTo(BridgeModule.duration);
                    myVideoView.start();
                }
            });


        } catch (Exception e) {
            progressDialog.dismiss();
            System.out.println("Video Play Error :" + e.toString());
            finish();
        }

    }
}

我的依赖

dependencies {
    implementation project(':react-native-share')
    implementation project(':react-native-sound')
    implementation project(':react-native-sound-player')
    implementation project(':react-native-orientation-locker')
    implementation project(':react-native-document-picker')
    implementation project(':react-native-image-picker')
    implementation project(':rn-fetch-blob')
    implementation project(':react-native-pdf')
    implementation project(':react-native-maps')
    implementation project(':react-native-video')
    implementation project(':react-native-vector-icons')
    implementation project(':react-native-gesture-handler')
    implementation project(':@react-native-community_async-storage')
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
    implementation "com.facebook.react:react-native:+"  // From node_modules

}

首先,请使用以下命令安装 jetifier:

npm install --save-dev jetifier

之后请运行以下命令:

npx jetify

您可以在package.json添加此脚本

"scripts": {
  "postinstall": "npx jetify"
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM