react native报错包android.support.v7.app不存在
react native error package android.support.v7.app does not exist
在 react-native-video 中 react-native 运行-android 时会出现这些错误
而且我无法删除这些
android.useAndroidX=真
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"
}
在 react-native-video 中 react-native 运行-android 时会出现这些错误 而且我无法删除这些
android.useAndroidX=真 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"
}