上传图片和Vedio的第三方库react-native-image-crop-picker
github地址
$ yarn add react-native-image-crop-picker
$ react-native link react-native-image-crop-picker
运行遇到报错:
Execution failed for task ':app:preDebugBuild'.
> Could not resolve all files for configuration ':app:debugCompileClasspath'.
> Could not find com.github.yalantis:ucrop:2.2.2-native.
Required by:
project :app > project :react-native-image-crop-picker
无法读取到外服的数据,只能用VPN或者添加如下服务。
1.android/build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
buildToolsVersion = "28.0.3"
minSdkVersion = 16
compileSdkVersion = 28
targetSdkVersion = 28
supportLibVersion = "28.0.0"
}
repositories {
google()
jcenter()
maven { url "http://dl.bintray.com/lukaville/maven"}
maven { url "$rootDir/../node_modules/react-native/android" }
maven { url 'https://maven.aliyun.com/repository/google'}
maven { url "https://jitpack.io" }
}
dependencies {
classpath("com.android.tools.build:gradle:3.4.0")
classpath 'com.google.gms:google-services:4.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
maven { url "https://jitpack.io" }// 关键
mavenLocal()
google()
jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
// 阿里提供
maven { url 'https://maven.aliyun.com/repository/google'}
}
}
2.在android/app/build.gradle添加
android {
...
defaultConfig {
//我是要添加的....
vectorDrawables.useSupportLibrary = true
...
}
...
}
Ios配置:
1.在info.plist内添加以下内容
Privacy - Photo Library Usage Description
Privacy - Camera Usage Description