react native报错包android.support.v7.app不存在
Posted
技术标签:
【中文标题】react native报错包android.support.v7.app不存在【英文标题】:react native error package android.support.v7.app does not exist 【发布时间】:2019-09-11 14:00:45 【问题描述】:在 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
【问题讨论】:
【参考方案1】:首先,请使用以下命令安装jetifier:
npm install --save-dev jetifier
之后请运行以下命令:
npx jetify
您可以将此脚本添加到您的package.json
"scripts":
"postinstall": "npx jetify"
【讨论】:
以上是关于react native报错包android.support.v7.app不存在的主要内容,如果未能解决你的问题,请参考以下文章
react-native 使用react-native run-android 启动项目 报错 Android project not found