我正在做一个Expo 项目。我已经通过使用安装了@volst/react-native-tuya
yarn add @volst/react-native-tuya
我正在使用他们的0.3.14 版本。我从 Here 阅读了所有这些文档 并遵循所有步骤。
但是在我安装并尝试在 android 上运行后,我遇到了一个问题:
A problem occurred configuring project ':@volst_react-native-tuya'. Could not determine the dependencies of null. Could not resolve all dependencies for configuration ':@volst_react-native-tuya:classpath'. > Using insecure protocols with repositories, without explicit opt-in, is unsupported. Switch Maven repository 'maven(http://maven.aliyun.com/nexus/content/groups/public/)' to redirect to a secure protocol (like HTTPS) or allow insecure protocols. See https://docs.gradle.org/7.3.3/dsl/org.gradle.api.artifacts.repositories.UrlArtifactRepository.html#org.gradle.api.artifacts.repositories.UrlArtifactRepository:allowInsecureProtocol for more details.
我尽我所能,但无法解决这个问题。
我的 Package.json 文件
{
"name": "@mevris/client-plugin-installation-components",
"description": "The Add flow driver",
"author": "BlueEast Team <code@blueeast.com>",
"version": "3.0.0-alpha.8",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"module": "dist/index.js",
"repository": {
"type": "git",
"url": "https://github.com/BlueEastCode/mevris-client-plugin-installation-components"
},
"remarkConfig": {
"plugins": [
"remark-preset-lint-recommended"
]
},
"config": {
"react-native-storybook-loader": {
"searchDir": [
"src"
],
"pattern": "**/*.stories.tsx",
"outputFile": "./storybook/storyLoader.js"
}
},
"scripts": {
...
},
"dependencies": {
...
"@volst/react-native-tuya": "^0.3.0",
"expo": "~45.0.0",
"expo-barcode-scanner": "^11.4.0",
"expo-location": "~14.2.2",
"expo-splash-screen": "~0.15.1",
"expo-status-bar": "~1.3.0",
"react": "17.0.2",
"react-dom": "17.0.2",
"react-native": "0.68.2",
"react-native-web": "0.17.7",
"react-native-wifi-reborn": "^4.7.0",
"yup": "^0.32.11"
},
"resolutions": {
"@types/react": "17.0.2",
"@types/react-dom": "17.0.2",
"graphql": "^16.5.0"
},
"devDependencies": {
...
},
"prettier": {
"singleQuote": true,
"useTabs": true,
"trailingComma": "es5"
},
"publishConfig": {
"access": "public"
},
"peerDependencies": {
"yup": "^0.32.11"
}
}
我的 Settings.gradle 文件 我的android/build.gradle
import org.apache.tools.ant.taskdefs.condition.Os
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
buildToolsVersion = findProperty('android.buildToolsVersion') ?: '31.0.0'
minSdkVersion = Integer.parseInt(findProperty('android.minSdkVersion') ?: '21')
compileSdkVersion = Integer.parseInt(findProperty('android.compileSdkVersion') ?: '31')
targetSdkVersion = Integer.parseInt(findProperty('android.targetSdkVersion') ?: '31')
if (findProperty('android.kotlinVersion')) {
kotlinVersion = findProperty('android.kotlinVersion')
}
frescoVersion = findProperty('expo.frescoVersion') ?: '2.5.0'
if (System.properties['os.arch'] == 'aarch64') {
// For M1 Users we need to use the NDK 24 which added support for aarch64
ndkVersion = '24.0.8215888'
} else {
// Otherwise we default to the side-by-side NDK version from AGP.
ndkVersion = '21.4.7075529'
}
}
repositories {
google()
mavenCentral()
}
dependencies {
classpath('com.android.tools.build:gradle:7.0.4')
classpath('com.facebook.react:react-native-gradle-plugin')
classpath('de.undercouch:gradle-download-task:4.1.2')
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenLocal()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url(new File(['node', '--print', "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim(), '../android'))
}
maven {
// Android JSC is installed from npm
url(new File(['node', '--print', "require.resolve('jsc-android/package.json')"].execute(null, rootDir).text.trim(), '../dist'))
}
google()
maven { url "https://maven.google.com" }
jcenter() {
allowInsecureProtocol = true
}
mavenCentral {
// We don't want to fetch react-native from Maven Central as there are
// older versions over there.
content {
excludeGroup 'com.facebook.react'
}
}
maven { url 'https://www.jitpack.io' }
}
}
最佳答案
问题出在包本身,因为它调用了问题中提到的 url 而没有将 allowInsecureProtocol 设置为 true,当然基于 https 的 url 是不可用的。您可以通过这种方式修复它,它有点老套,但只要开发人员不推送更新,就没有人能做任何事情。
进入包文件夹
node_modules/@volst/react-native-tuya/android
并打开build.gradle
文件。替换
maven{url 'http://maven.aliyun.com/nexus/content/groups/public/'}
用这个:
maven {
url 'http://maven.aliyun.com/nexus/content/groups/public/'
allowInsecureProtocol = true
}
- 一个额外但推荐的步骤,使用补丁包创建一个临时修复 (https://www.npmjs.com/package/patch-package)
关于android - 配置项目 ':@volst_react-native-tuya' 时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73565820/