React Native-React Native更新渐变-错误



我的React Native Project for Android出现错误。

我的第一个错误是:

我添加了"react native location"库。在我运行命令"react native link"之后,抛出了错误"compileOnly"。所以我的第一次尝试是更新NPM和Node.JS。但这不是解决我问题的正确方法。

之后,我在谷歌上搜索了错误,我想用"react native update gradle"更新grandle。我现在的主要问题是,当我运行"react native link"命令时,我会得到以下错误:

C:ComputerAppsProjectsXXX>react-native link
Scanning folders for symlinks in C:ComputerAppsProjectsXXXnode_modules (70ms)
rnpm-install info Platform 'ios' module react-native-orientation is already linked
rnpm-install info Platform 'android' module react-native-orientation is already linked
internal/validators.js:125
throw new ERR_INVALID_ARG_TYPE(name, 'string', value);
^
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type undefined
at validateString (internal/validators.js:125:11)
at Object.join (path.js:427:7)
at getSDKPath (C:ComputerAppsProjectsXXXnode_modulesreact-native-update-gradleindex.js:13:12)
at getPTPath (C:ComputerAppsProjectsXXXnode_modulesreact-native-update-gradleindex.js:17:20)
at Object.activateADB (C:ComputerAppsProjectsXXXnode_modulesreact-native-update-gradleindex.js:5:42)
at Object.<anonymous> (C:ComputerAppsProjectsXXXnode_modulesreact-native-update-gradlecli.js:101:6)
at Module._compile (internal/modules/cjs/loader.js:734:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:745:10)
at Module.load (internal/modules/cjs/loader.js:626:32)
at tryModuleLoad (internal/modules/cjs/loader.js:566:12)
C:ComputerAppsProjectsXXXnode_modulesreact-nativelocal-clicoremakeCommand.js:27
throw new Error(`Error occurred during executing "${command}" command`);
^
Error: Error occurred during executing "node ./node_modules/react-native-update-gradle/cli.js" command
at ChildProcess.prelink (C:/Computer/Apps/Projects/XXX/node_modules/react-native/local-cli/core/makeCommand.js:27:15)
at ChildProcess.emit (events.js:197:13)
at maybeClose (internal/child_process.js:978:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:265:5)

我试图修复错误,但错误仍然存在。

我有以下环境

  • 窗口10
  • React Native 0.55.4
  • React Native Cli 2.0.1
  • NodeJS v11.9.0
  • npm 4.6.0

android/build.gradle

buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
}
}
allprojects {
repositories {
mavenLocal()
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.google.com'
}
}
}
ext {
compileSdkVersion   = 28
targetSdkVersion    = 28
buildToolsVersion   = "28.0.3"
supportLibVersion   = "28.1.1"
playServicesVersion = "15.0.1"
}

package.json

{
"name": "XXX",
"version": "1.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest",
"run-android": "react-native run-android"
},
"dependencies": {
"react": "16.3.1",
"react-native": "0.55.4",
"react-native-image-slider": "^2.0.3",
"react-native-image-zoom-viewer": "^2.2.25",
"react-native-orientation": "^3.1.3",
"react-native-pinch-zoom-view": "^0.1.6",
"react-native-responsive-image": "^2.3.1",
"react-native-router-flux": "^4.0.0-beta.28",
"react-native-scrolltotop": "0.0.6",
"react-native-slideshow": "^1.0.1",
"react-native-swipe-gestures": "^1.0.2",
"react-native-update-gradle": "^1.1.0",
"react-native-vector-icons": "^4.6.0",
"react-native-zoom-view": "^1.0.2"
},
"devDependencies": {
"babel-jest": "22.4.3",
"babel-preset-react-native": "4.0.0",
"jest": "22.4.3",
"react-test-renderer": "16.3.1"
},
"jest": {
"preset": "react-native"
}
}

如果你需要更多的信息来帮助我,请告诉我。

谢谢你的帮助。

致以最诚挚的问候

你好,Sebastian!运行命令react-native link之后,必须运行命令react-native run-androidreact-native run-ios。以便您安装的库能够根据您的react本机设置进行调整。这对我来说是工作,在我安装了库或包之后。希望这能有所帮助。

最新更新